[Mesa-dev] [PATCH 3/3] panfrost: Fix blend shader upload

Alyssa Rosenzweig alyssa at rosenzweig.io
Wed May 1 03:42:38 UTC 2019


Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
---
 .../drivers/panfrost/pan_blend_shaders.c       |  3 +--
 src/gallium/drivers/panfrost/pan_context.c     | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_blend_shaders.c b/src/gallium/drivers/panfrost/pan_blend_shaders.c
index 5367b7ccf5e..f716e85e3f5 100644
--- a/src/gallium/drivers/panfrost/pan_blend_shaders.c
+++ b/src/gallium/drivers/panfrost/pan_blend_shaders.c
@@ -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;
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 42db8317d37..c50c546a399 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -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));
                 }
-- 
2.20.1



More information about the mesa-dev mailing list