From dfa5400a7881fb0f7e2ccfda0d2b428b3029ab8a Mon Sep 17 00:00:00 2001 From: liquidev Date: Tue, 6 Jun 2023 19:59:00 +0200 Subject: [PATCH] GLES: on EGL, respect the user requesting a non-sRGB surface format (#3817) * EGL: respect the user requesting a non-sRGB surface format What used to happen was that sRGB was used whether you requested it or not. This commit fixes that and now passing in a non-sRGB texture format in SurfaceConfiguration will result in a non-sRGB surface being created. * add changelog entry about the EGL non-sRGB support change --- CHANGELOG.md | 1 + wgpu-hal/src/gles/egl.rs | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5985745817..2f9892550d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Bottom level categories: ### Bug Fixes - Fix order of arguments to glPolygonOffset by @komadori in [#3783](https://github.com/gfx-rs/wgpu/pull/3783). +- Fix OpenGL/EGL backend not respecting non-sRGB texture formats in `SurfaceConfiguration`. by @liquidev in [#3817](https://github.com/gfx-rs/wgpu/pull/3817) #### Metal diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 13e217f9d9..e5e2572cf1 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -1152,15 +1152,17 @@ impl crate::Surface for Surface { khronos_egl::SINGLE_BUFFER }, ]; - match self.srgb_kind { - SrgbFrameBufferKind::None => {} - SrgbFrameBufferKind::Core => { - attributes.push(khronos_egl::GL_COLORSPACE); - attributes.push(khronos_egl::GL_COLORSPACE_SRGB); - } - SrgbFrameBufferKind::Khr => { - attributes.push(EGL_GL_COLORSPACE_KHR as i32); - attributes.push(EGL_GL_COLORSPACE_SRGB_KHR as i32); + if config.format.is_srgb() { + match self.srgb_kind { + SrgbFrameBufferKind::None => {} + SrgbFrameBufferKind::Core => { + attributes.push(khronos_egl::GL_COLORSPACE); + attributes.push(khronos_egl::GL_COLORSPACE_SRGB); + } + SrgbFrameBufferKind::Khr => { + attributes.push(EGL_GL_COLORSPACE_KHR as i32); + attributes.push(EGL_GL_COLORSPACE_SRGB_KHR as i32); + } } } attributes.push(khronos_egl::ATTRIB_NONE as i32);