[Bug 59436] New: Wayland/EGL: Washed-out colors caused by double sRGB conversion on default framebuffer (GL_FRAMEBUFFER_SRGB)
http://bugs.winehq.org/show_bug.cgi?id=59436 Bug ID: 59436 Summary: Wayland/EGL: Washed-out colors caused by double sRGB conversion on default framebuffer (GL_FRAMEBUFFER_SRGB) Product: Wine Version: 11.3 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winewayland Assignee: wine-bugs@list.winehq.org Reporter: tpaniaki@protonmail.com Distribution: --- Created attachment 80417 --> http://bugs.winehq.org/attachment.cgi?id=80417 Patch Fixes https://bugs.winehq.org/show_bug.cgi?id=59073 Summary When running Wine with the Wayland driver (winewayland.drv) using EGL, colors may appear washed out / desaturated in OpenGL applications. The issue is caused by GL_FRAMEBUFFER_SRGB remaining enabled while rendering to the default framebuffer (FBO 0), leading to a double gamma/sRGB conversion in some Wayland/EGL pipelines. Disabling GL_FRAMEBUFFER_SRGB only when rendering to the default framebuffer fixes the color output. Environment Wine: wine-git (tested on 11.x, reproducible on current master) Backend: winewayland.drv (Wayland native, not XWayland) GPU: AMD (Mesa) Compositor: wlroots-based (qtile Wayland) EGL backend in use Application tested: Roon (Chromium/CEF-based UI, OpenGL rendering) Observed behavior Colors appear faded / washed out Gamma looks incorrect (as if double sRGB conversion occurs) Issue only occurs under Wayland/EGL Colors are correct: Under X11/XWayland Or if GL_FRAMEBUFFER_SRGB is manually disabled for FBO 0 Root cause hypothesis Some Wayland/EGL compositors already perform colorspace handling for the window surface. If GL_FRAMEBUFFER_SRGB remains enabled when rendering to the default framebuffer, the pipeline applies sRGB conversion twice: App → GL_FRAMEBUFFER_SRGB → EGL/Compositor colorspace → Display This results in desaturated output. Minimal fix Disable GL_FRAMEBUFFER_SRGB only when binding the default framebuffer (FBO 0), while preserving the application's requested sRGB state for non-default FBOs. Example patch (conceptual) Inside framebuffer binding path: if (!framebuffer && gl_info->supported[ARB_FRAMEBUFFER_SRGB]) { TRACE("glBindFramebuffer disabling GL_FRAMEBUFFER_SRGB on default framebuffer\n"); glDisable(GL_FRAMEBUFFER_SRGB); } else if (framebuffer && app_framebuffer_srgb_enabled) { TRACE("glBindFramebuffer restoring GL_FRAMEBUFFER_SRGB on non-default framebuffer\n"); glEnable(GL_FRAMEBUFFER_SRGB); } Results Colors become correct under Wayland/EGL No regression observed in tested OpenGL apps Behavior matches X11 output sRGB still works correctly for offscreen FBO rendering -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #1 from tpaniaki <tpaniaki@protonmail.com> --- Comment on attachment 80417 --> http://bugs.winehq.org/attachment.cgi?id=80417 Patch wrong_upload -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #2 from tpaniaki <tpaniaki@protonmail.com> --- Comment on attachment 80417 --> http://bugs.winehq.org/attachment.cgi?id=80417 Patch
diff --git a/dlls/opengl32/thunks.c b/dlls/opengl32/thunks.c index 3c60ec5d6bb..7145c2c1b7f 100644 --- a/dlls/opengl32/thunks.c +++ b/dlls/opengl32/thunks.c @@ -3207,8 +3207,45 @@ static void WINAPI glBindFramebuffer( GLenum target, GLuint framebuffer ) { struct glBindFramebuffer_params args = { .teb = NtCurrentTeb(), .target = target, .framebuffer = framebuffer }; NTSTATUS status; + static BOOL srgb_disabled_for_default_fb; + TRACE( "target %d, framebuffer %d\n", target, framebuffer ); if ((status = UNIX_CALL( glBindFramebuffer, &args ))) WARN( "glBindFramebuffer returned %#lx\n", status ); + + if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) + { + struct glIsEnabled_params is_enabled_args = { .teb = NtCurrentTeb(), .cap = GL_FRAMEBUFFER_SRGB }; + GLboolean srgb_enabled; + + if ((status = UNIX_CALL( glIsEnabled, &is_enabled_args ))) WARN( "glIsEnabled returned %#lx\n", status ); + srgb_enabled = is_enabled_args.ret; + + if (!framebuffer) + { + /* Avoid double sRGB/gamma conversion on the onscreen framebuffer. */ + if (srgb_enabled) + { + struct glDisable_params disable_args = { .teb = NtCurrentTeb(), .cap = GL_FRAMEBUFFER_SRGB }; + + TRACE( "disabling GL_FRAMEBUFFER_SRGB on default framebuffer\n" ); + if ((status = UNIX_CALL( glDisable, &disable_args ))) WARN( "glDisable returned %#lx\n", status ); + srgb_disabled_for_default_fb = TRUE; + } + else + { + srgb_disabled_for_default_fb = FALSE; + } + } + else if (srgb_disabled_for_default_fb) + { + /* Restore sRGB state for offscreen FBOs if we disabled it for FBO 0. */ + struct glEnable_params enable_args = { .teb = NtCurrentTeb(), .cap = GL_FRAMEBUFFER_SRGB }; + + TRACE( "restoring GL_FRAMEBUFFER_SRGB on non-default framebuffer\n" ); + if ((status = UNIX_CALL( glEnable, &enable_args ))) WARN( "glEnable returned %#lx\n", status ); + srgb_disabled_for_default_fb = FALSE; + } + } }
static void WINAPI glBindFramebufferEXT( GLenum target, GLuint framebuffer )
-- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 Jonathan <joni.hilger@yahoo.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |joni.hilger@yahoo.de -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #3 from Jonathan <joni.hilger@yahoo.de> --- Would this patch maybe benefit from being proposed as a pull request on their Gitlab? Might help its visiblity. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 Stian Low <wineryyyyy@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wineryyyyy@gmail.com --- Comment #4 from Stian Low <wineryyyyy@gmail.com> --- Unable to reproduce for wine-11.9-68dd9ef2cb5 for latest trial version Roon downloaded for Windows 10 via: https://roon.app/en/downloads Please advise how to launch because the window currently has issues opening to confirm the bug. winetricks needed to workaround other bugs? renderer=vulkan rendering too dark seems related to this bug (renderer=gl too bright): https://bugs.winehq.org/show_bug.cgi?id=45364#c14 Merge request for that bug is still under development pending more tests but patch includes call to glDisable(GL_FRAMEBUFFER_SRGB) which was necessary to fix gl graphics rendering too bright after fixing bug causing vk to render too dark. diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 4c20587b81d..d2f540c547e 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -645,8 +645,10 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, wined3d_texture_load_location(back_buffer, 0, context, back_buffer->resource.draw_binding); - swapchain_blit(swapchain, context, src_rect, dst_rect); + if (gl_info->supported[ARB_FRAMEBUFFER_SRGB]) + gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB); Next patch push will include a better placed call to glDisable(GL_FRAMEBUFFER_SRGB) per @hverbeet suggestion: https://gitlab.winehq.org/wine/wine/-/merge_requests/10567/#note_139947 diff --git a/dlls/wined3d/texture_gl.c b/dlls/wined3d/texture_gl.c index 311ee954c23..68a731f3710 100644 --- a/dlls/wined3d/texture_gl.c +++ b/dlls/wined3d/texture_gl.c @@ -913,6 +913,12 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER); + if (gl_info->supported[ARB_FRAMEBUFFER_SRGB]) + { + gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB); + context_invalidate_state(context, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); + } + Unclear if Roon uses d3d as rendering backend until I'm able to launch but if so then Frostpunk bug/patch which also includes calls to glDisable(GL_FRAMEBUFFER_SRGB) may be related to this bug/patch. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #5 from Stian Low <wineryyyyy@gmail.com> --- (In reply to Stian Low from comment #4)
Unable to reproduce for wine-11.9-68dd9ef2cb5 for latest trial version Roon downloaded for Windows 10 via: https://roon.app/en/downloads
Please advise how to launch because the window currently has issues opening to confirm the bug. winetricks needed to workaround other bugs?
wine 10 Debian 13 apt pkg opens the window so I'll run a regression to fix for wine-11.9. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #6 from Stian Low <wineryyyyy@gmail.com> --- Created attachment 80992 --> http://bugs.winehq.org/attachment.cgi?id=80992 Screenshot of Roon running via wine10-debian-apt-pkg with MangoHUD reporting OpenGL and not D3D backend so Frostpunk renderer=vk too dark patch may be unrelated to this bug. (In reply to Stian Low from comment #4)
Unclear if Roon uses d3d as rendering backend until I'm able to launch but if so then Frostpunk bug/patch which also includes calls to glDisable(GL_FRAMEBUFFER_SRGB) may be related to this bug/patch.
Screenshot shows Roon via wine-10 with colors consistent with Roon website screenshots in background so multiple regression tests may be needed. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #7 from Jonathan <joni.hilger@yahoo.de> --- I usually use this script to install Roon which does all the workarounds for me: https://github.com/RoPieee/roon-on-wine/blob/master/install.sh But due to another issue that has not been fixed yet in master, I use this script from a fork instead: https://github.com/godlyfast/roon-on-wine/blob/7ab3c9bd76e8a261431a24f5b8698... Using this installation method I can still reproduce the issue on wine-staging-11.9 (Arch Linux package) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #8 from tpaniaki <tpaniaki@protonmail.com> --- Hi there, Glad to see people finally react to this. I think regular users can't post on GitLab. At least, the instructions ask to report bugs here. Please contradict me and I'll submit a ticket. I confirm Jonathan reply: use the roon-on-wine script. It should affect other applications as well. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #9 from Stian Low <wineryyyyy@gmail.com> --- (In reply to tpaniaki from comment #8)
I think regular users can't post on GitLab. At least, the instructions ask to report bugs here. Please contradict me and I'll submit a ticket.
Anyone may contribute to winehq gitlab. Just a matter of creating an account and requesting user verification: https://gitlab.winehq.org/wine/wine/-/wikis/Git-Wine-Tutorial#creating-a-for... -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #10 from Stian Low <wineryyyyy@gmail.com> --- (In reply to tpaniaki from comment #8)
I confirm Jonathan reply: use the roon-on-wine script. It should affect other applications as well.
Any other applications known with washed-out colors? Roon paywall makes for a less convenient test case. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla