panfrost/midgard: Move scale from MIR to NIR
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 1 Jul 2019 21:46:43 +0000 (14:46 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jul 2019 13:12:03 +0000 (06:12 -0700)
This begins the process of removing blend shader specific MIR into a
more general NIR lowering pass for formats.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/midgard/midgard_compile.c
src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c

index 5559aa4445491129a5ab6fbdfa9182dca06a7def..2c304d9066e1eff212b5f20f5db03aca38ad5ce5 100644 (file)
@@ -2324,20 +2324,18 @@ emit_fragment_epilogue(compiler_context *ctx)
 static void
 emit_blend_epilogue(compiler_context *ctx)
 {
-        /* vmul.fmul.none.fulllow hr48, r0, #255 */
+        /* fmov hr48, [...], r0*/
 
         midgard_instruction scale = {
                 .type = TAG_ALU_4,
                 .unit = UNIT_VMUL,
-                .inline_constant = _mesa_float_to_half(255.0),
                 .ssa_args = {
-                        .src0 = SSA_FIXED_REGISTER(0),
-                        .src1 = SSA_UNUSED_0,
+                        .src0 = SSA_FIXED_REGISTER(24),
+                        .src1 = SSA_FIXED_REGISTER(0),
                         .dest = SSA_FIXED_REGISTER(24),
-                        .inline_constant = true
                 },
                 .alu = {
-                        .op = midgard_alu_op_fmul,
+                        .op = midgard_alu_op_fmov,
                         .reg_mode = midgard_reg_mode_32,
                         .dest_override = midgard_dest_override_lower,
                         .mask = 0xFF,
@@ -2348,7 +2346,7 @@ emit_blend_epilogue(compiler_context *ctx)
 
         emit_mir_instruction(ctx, scale);
 
-        /* vadd.f2u_rte.pos.low hr0, hr48, #0 */
+        /* vadd.f2u_rte qr0, hr48, #0 */
 
         midgard_vector_alu_src alu_src = blank_alu_src;
         alu_src.half = true;
@@ -2365,7 +2363,6 @@ emit_blend_epilogue(compiler_context *ctx)
                         .op = midgard_alu_op_f2u_rte,
                         .reg_mode = midgard_reg_mode_16,
                         .dest_override = midgard_dest_override_lower,
-                        .outmod = midgard_outmod_pos,
                         .mask = 0xF,
                         .src1 = vector_alu_srco_unsigned(alu_src),
                         .src2 = vector_alu_srco_unsigned(blank_alu_src),
index 67fdf012c0450d2b460ca167b93c7149b3686ad5..115fe5f09ddc622efcd3ab55a754791de2fa41e5 100644 (file)
@@ -44,8 +44,8 @@
 static nir_ssa_def *
 nir_float_to_native(nir_builder *b, nir_ssa_def *c_float)
 {
-   /* TODO */
-   return c_float;
+   nir_ssa_def *scaled = nir_fmul_imm(b, nir_fsat(b, c_float), 255.0);
+   return scaled;
 }
 
 void