From 095b46dbdbc487ec8ee138f736adfba55cafa7fc Mon Sep 17 00:00:00 2001 From: Zoxc Date: Fri, 20 Oct 2023 23:04:09 +0200 Subject: [PATCH] Fix sRGB issues with glBlitFramebuffer on WGL (#4273) Co-authored-by: Connor Fitzgerald --- wgpu-hal/src/gles/wgl.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index d46665c18..6054556de 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -532,6 +532,12 @@ impl Surface { unsafe { gl.bind_framebuffer(glow::DRAW_FRAMEBUFFER, None) }; unsafe { gl.bind_framebuffer(glow::READ_FRAMEBUFFER, Some(sc.framebuffer)) }; + if self.srgb_capable { + // 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. @@ -550,6 +556,10 @@ impl Surface { ) }; + if self.srgb_capable { + unsafe { gl.enable(glow::FRAMEBUFFER_SRGB) }; + } + unsafe { gl.bind_renderbuffer(glow::RENDERBUFFER, None) }; unsafe { gl.bind_framebuffer(glow::READ_FRAMEBUFFER, None) };