[06/42] panfrost/midgard: Rewrite to use new blend intrinsic

Submitted by Alyssa Rosenzweig on July 8, 2019, 2:08 p.m.

Details

Message ID 20190708140855.4126-7-alyssa.rosenzweig@collabora.com
State New
Headers show
Series "panfrost: Render target stuff" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Alyssa Rosenzweig July 8, 2019, 2:08 p.m.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
---
 .../drivers/panfrost/midgard/midgard_compile.c    | 11 +++++++++++
 .../panfrost/midgard/nir_lower_framebuffer.c      | 15 ++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index 2c304d9066e..39b8d9c1005 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -1416,6 +1416,17 @@  emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
 
                 break;
 
+        /* Special case of store_output for lowered blend shaders */
+        case nir_intrinsic_store_blended_output:
+                assert (ctx->stage == MESA_SHADER_FRAGMENT);
+                reg = nir_src_index(ctx, &instr->src[0]);
+
+                midgard_instruction move = v_mov(reg, blank_alu_src, SSA_FIXED_REGISTER(0));
+                emit_mir_instruction(ctx, move);
+                ctx->fragment_output = reg;
+
+                break;
+
         case nir_intrinsic_load_alpha_ref_float:
                 assert(instr->dest.is_ssa);
 
diff --git a/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c b/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c
index 115fe5f09dd..202b3658a28 100644
--- a/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c
+++ b/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c
@@ -87,9 +87,18 @@  nir_lower_framebuffer(nir_shader *shader)
                /* Format convert */
                nir_ssa_def *converted = nir_float_to_native(&b, c_nir);
 
-               /* Write out the converted color instead of the input */
-               nir_instr_rewrite_src(instr, &intr->src[1],
-               nir_src_for_ssa(converted));
+               /* Rewrite to use a native store by creating a new intrinsic */
+               nir_intrinsic_instr *new =
+                  nir_intrinsic_instr_create(shader, nir_intrinsic_store_blended_output);
+               new->src[0] = nir_src_for_ssa(converted);
+
+               /* TODO: What about non-RGBA? Is that different? */
+               new->num_components = 4;
+
+               nir_builder_instr_insert(&b, &new->instr);
+
+               /* (And finally removing the old) */
+               nir_instr_remove(instr);
             } else {
                /* TODO loads */
             }