Skip to content

Commit

Permalink
Fix OpenGL non-srgb on Linux (gfx-rs#5642)
Browse files Browse the repository at this point in the history
  • Loading branch information
valaphee authored and vorporeal committed May 9, 2024
1 parent 44b2170 commit c10e796
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 39,43 @@ Bottom level categories:

## Unreleased

### Major Changes

#### Querying shader compilation errors

Wgpu now supports querying [shader compilation info](https://www.w3.org/TR/webgpu/#dom-gpushadermodule-getcompilationinfo).

This allows you to get more structured information about compilation errors, warnings and info:
```rust
...
let lighting_shader = ctx.device.create_shader_module(include_wgsl!("lighting.wgsl"));
let compilation_info = lighting_shader.get_compilation_info().await;
for message in compilation_info
.messages
.iter()
.filter(|m| m.message_type == wgpu::CompilationMessageType::Error)
{
let line = message.location.map(|l| l.line_number).unwrap_or(1);
println!("Compile error at line {line}");
}
```

By @stefnotch in [#5410](https://github.com/gfx-rs/wgpu/pull/5410)



### New features

#### General

#### Naga

### Bug Fixes

#### GLES / OpenGL

- Fix regression on OpenGL (EGL) where non-sRGB still used sRGB [#5642](https://github.com/gfx-rs/wgpu/pull/5642)

## v0.20.0 (2024-04-28)

### Major Changes
Expand Down
12 changes: 12 additions & 0 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 1130,13 @@ impl Surface {

unsafe { gl.bind_framebuffer(glow::DRAW_FRAMEBUFFER, None) };
unsafe { gl.bind_framebuffer(glow::READ_FRAMEBUFFER, Some(sc.framebuffer)) };

if !matches!(self.srgb_kind, SrgbFrameBufferKind::None) {
// Disable sRGB conversions for `glBlitFramebuffer` as behavior does diverge between
// drivers and formats otherwise and we want to ensure no sRGB conversions happen.
unsafe { gl.disable(glow::FRAMEBUFFER_SRGB) };
}

// Note the Y-flipping here. GL's presentation is not flipped,
// but main rendering is. Therefore, we Y-flip the output positions
// in the shader, and also this blit.
Expand All @@ -1147,6 1154,11 @@ impl Surface {
glow::NEAREST,
)
};

if !matches!(self.srgb_kind, SrgbFrameBufferKind::None) {
unsafe { gl.enable(glow::FRAMEBUFFER_SRGB) };
}

unsafe { gl.bind_framebuffer(glow::READ_FRAMEBUFFER, None) };

self.egl
Expand Down

0 comments on commit c10e796

Please sign in to comment.