diff --git a/src/dawn/native/opengl/TextureGL.cpp b/src/dawn/native/opengl/TextureGL.cpp index cbbe1db878..d7f1c10a2a 100644 --- a/src/dawn/native/opengl/TextureGL.cpp +++ b/src/dawn/native/opengl/TextureGL.cpp @@ -612,8 +612,12 @@ namespace dawn::native::opengl { 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 @@ namespace dawn::native::opengl { 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 2b85f54413..33beacf4f3 100644 --- a/src/dawn/tests/end2end/TextureViewTests.cpp +++ b/src/dawn/tests/end2end/TextureViewTests.cpp @@ -435,7 +435,7 @@ TEST_P(TextureViewSamplingTest, Texture2DArrayViewOnOneLevelOf2DArrayTexture) { // 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_P(TextureViewRenderingTest, Texture2DArrayViewOnALayerOf2DArrayTextureAsCol // 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 @@ TEST_P(TextureViewRenderingTest, SRGBReinterpretationRenderAttachment) { // 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