summarylogtreecommitdiffstats
path: root/0001-st-mesa-candidate-fix-for-sRGB-blit-errors.patch
blob: b0ded6f3c5828fdfa766d2dccafd6a97edfff8e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
From 9fc607ddf2d2b656c69144ea13bf75b5c037dee8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= <nicolai.haehnle@amd.com>
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