From 9fc607ddf2d2b656c69144ea13bf75b5c037dee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= Date: Thu, 11 Aug 2016 13:06:47 +0200 Subject: [PATCH] st/mesa: candidate fix for sRGB blit errors Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97285 --- src/mesa/state_tracker/st_cb_blit.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index cfcf3f7..8aa849b 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -38,29 +38,20 @@ #include "st_texture.h" #include "st_cb_bitmap.h" #include "st_cb_blit.h" #include "st_cb_fbo.h" #include "st_manager.h" #include "st_scissor.h" #include "util/u_format.h" static void -st_adjust_blit_for_srgb(struct pipe_blit_info *blit, bool framebuffer_srgb) -{ - if (!framebuffer_srgb) { - blit->dst.format = util_format_linear(blit->dst.format); - blit->src.format = util_format_linear(blit->src.format); - } -} - -static void st_BlitFramebuffer(struct gl_context *ctx, struct gl_framebuffer *readFB, struct gl_framebuffer *drawFB, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { const GLbitfield depthStencil = (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); struct st_context *st = st_context(ctx); @@ -192,73 +183,84 @@ st_BlitFramebuffer(struct gl_context *ctx, if (!srcObj || !srcObj->pt) { return; } for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) { struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[i]); if (dstRb) { - struct pipe_surface *dstSurf = dstRb->surface; + struct pipe_surface *dstSurf; + + st_update_renderbuffer_surface(st, dstRb); + + dstSurf = dstRb->surface; if (dstSurf) { blit.dst.resource = dstSurf->texture; blit.dst.level = dstSurf->u.tex.level; blit.dst.box.z = dstSurf->u.tex.first_layer; blit.dst.format = dstSurf->format; blit.src.resource = srcObj->pt; blit.src.level = srcAtt->TextureLevel; blit.src.box.z = srcAtt->Zoffset + srcAtt->CubeMapFace; blit.src.format = srcObj->pt->format; - st_adjust_blit_for_srgb(&blit, ctx->Color.sRGBEnabled); + if (!ctx->Color.sRGBEnabled) + blit.src.format = util_format_linear(blit.src.format); st->pipe->blit(st->pipe, &blit); dstRb->defined = true; /* front buffer tracking */ } } } } else { struct st_renderbuffer *srcRb = st_renderbuffer(readFB->_ColorReadBuffer); struct pipe_surface *srcSurf; GLuint i; - if (!srcRb || !srcRb->surface) { + if (!srcRb) + return; + + st_update_renderbuffer_surface(st, srcRb); + + if (!srcRb->surface) return; - } srcSurf = srcRb->surface; for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) { struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[i]); if (dstRb) { - struct pipe_surface *dstSurf = dstRb->surface; + struct pipe_surface *dstSurf; + + st_update_renderbuffer_surface(st, dstRb); + + dstSurf = dstRb->surface; if (dstSurf) { blit.dst.resource = dstSurf->texture; blit.dst.level = dstSurf->u.tex.level; blit.dst.box.z = dstSurf->u.tex.first_layer; blit.dst.format = dstSurf->format; blit.src.resource = srcSurf->texture; blit.src.level = srcSurf->u.tex.level; blit.src.box.z = srcSurf->u.tex.first_layer; blit.src.format = srcSurf->format; - st_adjust_blit_for_srgb(&blit, ctx->Color.sRGBEnabled); - st->pipe->blit(st->pipe, &blit); dstRb->defined = true; /* front buffer tracking */ } } } } } if (mask & depthStencil) { /* depth and/or stencil blit */ -- 2.7.4