From: Matteo Bruni Subject: [PATCH 1/5] wined3d: Add a quirk for GL implementations not supporting sRGB FBO attachments. Message-Id: <1476396217-26826-1-git-send-email-mbruni@codeweavers.com> Date: Fri, 14 Oct 2016 00:03:33 +0200 Signed-off-by: Matteo Bruni --- As it seems to be the case for i915 (at least with some Mesa versions). This is only a problem because the GL implementation also exposes EXT_texture_sRGB_decode and when that extension is available we always use the sRGB format. For bug 41052. dlls/wined3d/directx.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 5d324f3..052321a 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -887,6 +887,37 @@ static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, const ch return data[0] != 0x00ff0000 || data[3] != 0x0000ff00; } +static BOOL match_no_srgb_fbo_attachments(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) +{ + GLuint fbo, rb; + GLenum status; + + if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) + return FALSE; + if (!gl_info->supported[EXT_TEXTURE_SRGB_DECODE]) + return FALSE; + + gl_info->fbo_ops.glGenFramebuffers(1, &fbo); + gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo); + gl_info->gl_ops.gl.p_glDrawBuffer(GL_COLOR_ATTACHMENT0); + gl_info->gl_ops.gl.p_glReadBuffer(GL_COLOR_ATTACHMENT0); + + gl_info->fbo_ops.glGenRenderbuffers(1, &rb); + gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, rb); + gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_SRGB8_ALPHA8, 16, 16); + gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rb); + + status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER); + TRACE("Framebuffer status %s (%#x).\n", debug_fbostatus(status), status); + + gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0); + gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo); + gl_info->fbo_ops.glDeleteRenderbuffers(1, &rb); + + return status != GL_FRAMEBUFFER_COMPLETE; +} + static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info) { /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms. @@ -1015,6 +1046,12 @@ static void quirk_broken_arb_fog(struct wined3d_gl_info *gl_info) gl_info->quirks |= WINED3D_QUIRK_BROKEN_ARB_FOG; } +static void quirk_no_srgb_fbo_attachments(struct wined3d_gl_info *gl_info) +{ + TRACE("sRGB FBO attachments not supported, disabling EXT_texture_sRGB_decode codepaths.\n"); + gl_info->supported[EXT_TEXTURE_SRGB_DECODE] = FALSE; +} + struct driver_quirk { BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, @@ -1105,6 +1142,11 @@ static const struct driver_quirk quirk_table[] = quirk_broken_arb_fog, "ARBfp fogstart == fogend workaround" }, + { + match_no_srgb_fbo_attachments, + quirk_no_srgb_fbo_attachments, + "sRGB FBO attachments unavailable" + }, }; /* Certain applications (Steam) complain if we report an outdated driver version. In general, @@ -3836,6 +3878,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, DWORD /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode * we never render to sRGB surfaces). */ + TRACE("EXT_texture_sRGB_decode is not supported, disabling ARB_framebuffer_sRGB.\n"); gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE; } if (gl_info->supported[ARB_OCCLUSION_QUERY]) -- 2.7.3