GLES: revert part of the view format reinterpretation on GLES.

View format reinterpretation doesn't work, but its implementation was causing failures on other content.

This patch came from: https://dawn-review.googlesource.com/c/dawn/+/84704/comments/339d5a75_5dce5ce3

Bug: dawn:1360
Change-Id: I76adc264d6f185f840d975b46b6e92a0e5a7b4a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86362
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/dawn/native/opengl/TextureGL.cpp b/src/dawn/native/opengl/TextureGL.cpp
index cbbe1db..d7f1c10 100644
--- a/src/dawn/native/opengl/TextureGL.cpp
+++ b/src/dawn/native/opengl/TextureGL.cpp
@@ -612,8 +612,12 @@
     void TextureView::BindToFramebuffer(GLenum target, GLenum attachment) {
         const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
 
+        // Use the base texture where possible to minimize the amount of copying required on GLES.
+        bool useOwnView = GetFormat().format != GetTexture()->GetFormat().format &&
+                          !GetTexture()->GetFormat().HasDepthOrStencil();
+
         GLuint handle, textarget, mipLevel, arrayLayer;
-        if (mOwnsHandle) {
+        if (useOwnView) {
             // Use our own texture handle and target which points to a subset of the texture's
             // subresources.
             handle = GetHandle();
@@ -622,7 +626,7 @@
             arrayLayer = 0;
         } else {
             // Use the texture's handle and target, with the view's base mip level and base array
-            // layer.
+
             handle = ToBackend(GetTexture())->GetHandle();
             textarget = ToBackend(GetTexture())->GetGLTarget();
             mipLevel = GetBaseMipLevel();
diff --git a/src/dawn/tests/end2end/TextureViewTests.cpp b/src/dawn/tests/end2end/TextureViewTests.cpp
index 2b85f54..33beacf 100644
--- a/src/dawn/tests/end2end/TextureViewTests.cpp
+++ b/src/dawn/tests/end2end/TextureViewTests.cpp
@@ -435,7 +435,7 @@
 // Test that an RGBA8 texture may be interpreted as RGBA8UnormSrgb and sampled from.
 // More extensive color value checks and format tests are left for the CTS.
 TEST_P(TextureViewSamplingTest, SRGBReinterpretation) {
-    // TODO(crbug.com/dawn/593): This test requires glTextureView, which is unsupported on GLES.
+    // TODO(crbug.com/dawn/1360): OpenGLES doesn't support view format reinterpretation.
     DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
 
     wgpu::TextureViewDescriptor viewDesc = {};
@@ -769,7 +769,7 @@
 // Test that an RGBA8 texture may be interpreted as RGBA8UnormSrgb and rendered to.
 // More extensive color value checks and format tests are left for the CTS.
 TEST_P(TextureViewRenderingTest, SRGBReinterpretationRenderAttachment) {
-    // TODO(crbug.com/dawn/593): This test requires glTextureView, which is unsupported on GLES.
+    // TODO(crbug.com/dawn/1360): OpenGLES doesn't support view format reinterpretation.
     DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
 
     // Test will render into an SRGB view
@@ -875,7 +875,7 @@
 // This test samples the RGBA8Unorm texture into an RGBA8Unorm multisample texture viewed as SRGB,
 // and resolves it into an RGBA8Unorm texture, viewed as SRGB.
 TEST_P(TextureViewRenderingTest, SRGBReinterpretionResolveAttachment) {
-    // TODO(crbug.com/dawn/593): This test requires glTextureView, which is unsupported on GLES.
+    // TODO(crbug.com/dawn/1360): OpenGLES doesn't support view format reinterpretation.
     DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
 
     // Test will resolve into an SRGB view