pan/midgard: Implement nir_intrinsic_load_output_u8_as_fp16_pan
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 7 Nov 2019 02:50:32 +0000 (21:50 -0500)
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Mon, 11 Nov 2019 15:23:44 +0000 (15:23 +0000)
We can use the native Midgard ops for this, depending what chip we're
on.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
src/panfrost/midgard/midgard_compile.c

index 1183d11f34926321a69166b08d4f78ef2075593f..5704f8475763119408b1849e28ee16abf9a51428 100644 (file)
@@ -1477,10 +1477,30 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
         /* Reads 128-bit value raw off the tilebuffer during blending, tasty */
 
         case nir_intrinsic_load_raw_output_pan:
+        case nir_intrinsic_load_output_u8_as_fp16_pan:
                 reg = nir_dest_index(ctx, &instr->dest);
                 assert(ctx->is_blend);
 
+                /* T720 and below use different blend opcodes with slightly
+                 * different semantics than T760 and up */
+
                 midgard_instruction ld = m_ld_color_buffer_8(reg, 0);
+                bool old_blend = ctx->gpu_id < 0x750;
+
+                if (instr->intrinsic == nir_intrinsic_load_output_u8_as_fp16_pan) {
+                        ld.load_store.op = old_blend ?
+                                midgard_op_ld_color_buffer_u8_as_fp16_old :
+                                midgard_op_ld_color_buffer_u8_as_fp16;
+
+                        if (old_blend) {
+                                ld.load_store.address = 1;
+                                ld.load_store.arg_2 = 0x1E;
+                        }
+
+                        for (unsigned c = 2; c < 16; ++c)
+                                ld.swizzle[0][c] = 0;
+                }
+
                 emit_mir_instruction(ctx, ld);
                 break;