From cedd55a9bfa4c84ed54144e8589f2090718e648f Mon Sep 17 00:00:00 2001 From: Stephen White Date: Tue, 12 Apr 2022 03:31:16 +0000 Subject: [PATCH] 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 Commit-Queue: Stephen White --- src/dawn/native/opengl/TextureGL.cpp | 8 ++++++-- src/dawn/tests/end2end/TextureViewTests.cpp | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) 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