pan/midgard: Update RA for cubemap coords
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 25 Jul 2019 14:09:40 +0000 (07:09 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 26 Jul 2019 15:37:08 +0000 (08:37 -0700)
Following the RA work, we apply the same technique to eliminate the move
to r27 when loading cubemaps.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/helpers.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_ra.c

index 76bda286f7e3eff1b43d41dbba1d3a51f23058c6..92545cfc7870e03ebadc7e2cc1d9ec477640d91e 100644 (file)
@@ -57,7 +57,8 @@
         )
 
 #define OP_IS_R27_ONLY(op) ( \
-                OP_IS_PROJECTION(op) \
+                OP_IS_PROJECTION(op) || \
+                op == midgard_op_st_cubemap_coords \
         )
 
 #define OP_IS_MOVE(op) ( \
index 6f50e345baae313b0ad4ba47a51669cd56e4f55f..71625e8fd55b33a6098ff4d0ca0b7b47c74bea5a 100644 (file)
@@ -173,7 +173,7 @@ M_LOAD(ld_uniform_32);
 M_LOAD(ld_color_buffer_8);
 //M_STORE(st_vary_16);
 M_STORE(st_vary_32);
-M_STORE(st_cubemap_coords);
+M_LOAD(st_cubemap_coords);
 
 static midgard_instruction
 v_alu_br_compact_cond(midgard_jmp_writeout_op op, unsigned tag, signed offset, unsigned cond)
@@ -1578,17 +1578,12 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
                                 /* texelFetch is undefined on samplerCube */
                                 assert(midgard_texop != TEXTURE_OP_TEXEL_FETCH);
 
-                                /* For cubemaps, we need to load coords into
-                                 * special r27, and then use a special ld/st op
-                                 * to select the face and copy the xy into the
+                                /* For cubemaps, we use a special ld/st op to
+                                 * select the face and copy the xy into the
                                  * texture register */
 
-                                alu_src.swizzle = SWIZZLE(COMPONENT_X, COMPONENT_Y, COMPONENT_Z, COMPONENT_X);
-
-                                midgard_instruction move = v_mov(index, alu_src, SSA_FIXED_REGISTER(27));
-                                emit_mir_instruction(ctx, move);
-
                                 midgard_instruction st = m_st_cubemap_coords(reg, 0);
+                                st.ssa_args.src0 = index;
                                 st.load_store.unknown = 0x24; /* XXX: What is this? */
                                 st.mask = 0x3; /* xy */
                                 st.load_store.swizzle = alu_src.swizzle;
index 485ab789cd4a997c11ef8c31844b1cc2c3cb7e43..cca167c0ba7fbae248c241e8eaf1f8cedff56f71 100644 (file)
@@ -704,6 +704,8 @@ install_registers_instr(
 
                 if (OP_IS_STORE_R26(ins->load_store.op) && fixed) {
                         ins->load_store.reg = SSA_REG_FROM_FIXED(args.src0);
+                } else if (ins->load_store.op == midgard_op_st_cubemap_coords) {
+                        ins->load_store.reg = SSA_REG_FROM_FIXED(args.dest);
                 } else if (OP_IS_STORE_VARY(ins->load_store.op)) {
                         struct phys_reg src = index_to_reg(ctx, g, args.src0);
                         assert(src.reg == 26 || src.reg == 27);