Skip to content

Commit

Permalink
GLES: on EGL, respect the user requesting a non-sRGB surface format (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
liquidev authored Jun 6, 2023
1 parent 2e4209c commit dfa5400
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 11 additions & 9 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,15 +1152,17 @@ impl crate::Surface<super::Api> 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);
Expand Down

0 comments on commit dfa5400

Please sign in to comment.