panfrost: Pass blend RT number through
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sun, 24 Nov 2019 02:44:16 +0000 (21:44 -0500)
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Mon, 16 Dec 2019 09:10:33 +0000 (09:10 +0000)
We have to key the blend shader for the render target number due to
writeout silliness.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Visoso <tomeu.vizoso@collabora.com>
src/gallium/drivers/panfrost/pan_assemble.c
src/gallium/drivers/panfrost/pan_blend_cso.c
src/gallium/drivers/panfrost/pan_blend_shaders.c
src/gallium/drivers/panfrost/pan_blend_shaders.h
src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_compile.h

index e91b20df971e4b5b4096c0e3c81a9383b7eb3e33..62a4dd654b6ffbca42c4c63ec1539f076a515b76 100644 (file)
@@ -65,7 +65,7 @@ panfrost_shader_compile(
                 .alpha_ref = state->alpha_state.ref_value
         };
 
-        midgard_compile_shader_nir(s, &program, false, screen->gpu_id);
+        midgard_compile_shader_nir(s, &program, false, 0, screen->gpu_id);
 
         /* Prepare the compiled binary for upload */
         int size = program.compiled.size;
index 69683098c6818a05e2a831d5e16523b0feff852b..1dd211e6b4c6075e565dd05b1597bb849ee7956f 100644 (file)
@@ -75,11 +75,12 @@ panfrost_get_blend_shader(
         /* Prevent NULL collision issues.. */
         assert(fmt != 0);
 
-        /* Check the cache */
+        /* Check the cache. Key by the RT and format */
         struct hash_table_u64 *shaders = blend->rt[rt].shaders;
+        unsigned key = (fmt << 3) | rt;
 
         struct panfrost_blend_shader *shader =
-                _mesa_hash_table_u64_search(shaders, fmt);
+                _mesa_hash_table_u64_search(shaders, key);
 
         if (shader)
                 return shader;
@@ -87,10 +88,10 @@ panfrost_get_blend_shader(
         /* Cache miss. Build one instead, cache it, and go */
 
         struct panfrost_blend_shader generated =
-                panfrost_compile_blend_shader(ctx, &blend->base, fmt);
+                panfrost_compile_blend_shader(ctx, &blend->base, fmt, rt);
 
         shader = mem_dup(&generated, sizeof(generated));
-        _mesa_hash_table_u64_insert(shaders, fmt, shader);
+        _mesa_hash_table_u64_insert(shaders, key, shader);
         return  shader;
 }
 
index 5d7eb9573ebe3ee660e59ce191d1632af9b1c836..62177ccf7e443a0829e3f39c527ef8ec7dcb6a40 100644 (file)
@@ -129,7 +129,8 @@ struct panfrost_blend_shader
 panfrost_compile_blend_shader(
         struct panfrost_context *ctx,
         struct pipe_blend_state *cso,
-        enum pipe_format format)
+        enum pipe_format format,
+        unsigned rt)
 {
         struct panfrost_screen *screen = pan_screen(ctx->base.screen);
         struct panfrost_blend_shader res;
@@ -173,7 +174,7 @@ panfrost_compile_blend_shader(
         /* Compile the built shader */
 
         midgard_program program;
-        midgard_compile_shader_nir(shader, &program, true, screen->gpu_id);
+        midgard_compile_shader_nir(shader, &program, true, rt, screen->gpu_id);
 
         /* Allow us to patch later */
         res.patch_index = program.blend_patch_offset;
index 88ece5436a4e1e104d5a5d98166cff11d802d625..5931cbc41ce67ab8d460ee63ae1fb33558a076e2 100644 (file)
@@ -35,6 +35,7 @@ struct panfrost_blend_shader
 panfrost_compile_blend_shader(
         struct panfrost_context *ctx,
         struct pipe_blend_state *cso,
-        enum pipe_format format);
+        enum pipe_format format,
+        unsigned rt);
 
 #endif
index faeecf0150c7cdfa375417b2d2750563e0e2fc89..d087579f36d135c5a21f0e27a867f7019182c643 100644 (file)
@@ -224,6 +224,9 @@ typedef struct compiler_context {
         /* Is internally a blend shader? Depends on stage == FRAGMENT */
         bool is_blend;
 
+        /* Render target number for a keyed blend shader. Depends on is_blend */
+        unsigned blend_rt;
+
         /* Tracking for blend constant patching */
         int blend_constant_offset;
 
index 6575771edf713ef9bb34468b7222297bb3c01e23..5b018d86e50328c6953b0fc80e9e50b4dfd32974 100644 (file)
@@ -1607,9 +1607,9 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
                                 splatter.swizzle[1][c] = 0;
 
                         emit_mir_instruction(ctx, splatter);
-                        emit_fragment_store(ctx, expanded, 0);
+                        emit_fragment_store(ctx, expanded, ctx->blend_rt);
                 } else
-                        emit_fragment_store(ctx, reg, 0);
+                        emit_fragment_store(ctx, reg, ctx->blend_rt);
 
                 break;
 
@@ -2433,7 +2433,7 @@ midgard_get_first_tag_from_block(compiler_context *ctx, unsigned block_idx)
 }
 
 int
-midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_blend, unsigned gpu_id)
+midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_blend, unsigned blend_rt, unsigned gpu_id)
 {
         struct util_dynarray *compiled = &program->compiled;
 
@@ -2446,6 +2446,7 @@ midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_bl
         ctx->stage = nir->info.stage;
         ctx->is_blend = is_blend;
         ctx->alpha_ref = program->alpha_ref;
+        ctx->blend_rt = blend_rt;
         ctx->quirks = midgard_get_quirks(gpu_id);
 
         /* Start off with a safe cutoff, allowing usage of all 16 work
index ffdaa89d12992d1e3f5d8db8468aad871081ee3f..9d27c338f4bba73b50e1ec7789c630386e08b7dc 100644 (file)
@@ -91,7 +91,7 @@ typedef struct {
 } midgard_program;
 
 int
-midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_blend, unsigned gpu_id);
+midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_blend, unsigned blend_rt, unsigned gpu_id);
 
 /* NIR options are shared between the standalone compiler and the online
  * compiler. Defining it here is the simplest, though maybe not the Right