panfrost: Fix blend shader upload
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 1 May 2019 03:21:06 +0000 (03:21 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 1 May 2019 23:20:51 +0000 (23:20 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/pan_blend_shaders.c
src/gallium/drivers/panfrost/pan_context.c

index 5367b7ccf5e40d73383816c505cc2beb2eb46241..f716e85e3f5a29b74c930271f5b6dcf1523ae501 100644 (file)
@@ -96,7 +96,6 @@ void
 panfrost_make_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_state *cso, const struct pipe_blend_color *blend_color)
 {
         const struct pipe_rt_blend_state *blend = &cso->base.rt[0];
-        mali_ptr *out = &cso->blend_shader;
 
         /* Build the shader */
 
@@ -150,7 +149,7 @@ panfrost_make_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_s
                         hot_color[c] = blend_color->color[c];
         }
 
-        *out = panfrost_upload(&ctx->shaders, dst, size, true) | program.first_tag;
+        cso->blend_shader = panfrost_upload(&ctx->shaders, dst, size, true) | program.first_tag;
 
         /* We need to switch to shader mode */
         cso->has_blend_shader = true;
index 42db8317d3739795d0b960b5bf79499aeb6fd306..c50c546a3995a8cc60740200701632e4ee203b70 100644 (file)
@@ -960,15 +960,22 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                        (ctx->blend->equation.alpha_mode == 0x122) &&
                        (ctx->blend->equation.color_mask == 0xf);
 
+                /* Even on MFBD, the shader descriptor gets blend shaders. It's
+                 * *also* copied to the blend_meta appended (by convention),
+                 * but this is the field actually read by the hardware. (Or
+                 * maybe both are read...?) */
+
+                if (ctx->blend->has_blend_shader) {
+                        ctx->fragment_shader_core.blend_shader = ctx->blend->blend_shader;
+                }
+
                 if (ctx->require_sfbd) {
                         /* When only a single render target platform is used, the blend
                          * information is inside the shader meta itself. We
                          * additionally need to signal CAN_DISCARD for nontrivial blend
                          * modes (so we're able to read back the destination buffer) */
 
-                        if (ctx->blend->has_blend_shader) {
-                                ctx->fragment_shader_core.blend_shader = ctx->blend->blend_shader;
-                        } else {
+                        if (!ctx->blend->has_blend_shader) {
                                 memcpy(&ctx->fragment_shader_core.blend_equation, &ctx->blend->equation, sizeof(ctx->blend->equation));
                         }
 
@@ -1018,8 +1025,9 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                                 },
                         };
 
-                        if (ctx->blend->has_blend_shader)
-                                memcpy(&blend_meta[0].blend_equation_1, &ctx->blend->blend_shader, sizeof(ctx->blend->blend_shader));
+                        if (ctx->blend->has_blend_shader) {
+                                blend_meta[0].blend_shader = ctx->blend->blend_shader;
+                        }
 
                         memcpy(transfer.cpu + sizeof(struct mali_shader_meta), blend_meta, sizeof(blend_meta));
                 }