summaryrefslogtreecommitdiffstats
path: root/src/panfrost
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-12-16 17:02:36 -0500
committerMarge Bot <[email protected]>2019-12-17 17:42:57 +0000
commitd183f84585acc4f969ee3e713187b25ee88da1e9 (patch)
treebbbae007263869a0b810e9395bb8bdc6d77d075d /src/panfrost
parent96df5f1fbf3511be88adb1f9efa5eddd40fa9868 (diff)
pan/midgard: Hoist temporary coordinate for cubemaps
We'll reuse some of this code for shadow samplers, which are represented by a distinct source in NIR. Signed-off-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Tomeu Vizoso <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3125>
Diffstat (limited to 'src/panfrost')
-rw-r--r--src/panfrost/midgard/midgard_compile.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 01729304d42..504513340d6 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -1728,6 +1728,11 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
}
};
+ /* We may need a temporary for the coordinate */
+
+ bool needs_temp_coord = (midgard_texop == TEXTURE_OP_TEXEL_FETCH);
+ unsigned coords = needs_temp_coord ? make_compiler_temp_reg(ctx) : 0;
+
for (unsigned i = 0; i < instr->num_srcs; ++i) {
int index = nir_src_index(ctx, &instr->src[i].src);
unsigned nr_components = nir_src_num_components(instr->src[i].src);
@@ -1736,23 +1741,24 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
case nir_tex_src_coord: {
emit_explicit_constant(ctx, index, index);
+ if (needs_temp_coord) {
+ /* mov coord_temp, coords */
+ midgard_instruction mov = v_mov(index, coords);
+ mov.mask = 0x3;
+ emit_mir_instruction(ctx, mov);
+ } else {
+ coords = index;
+ }
+
/* Texelfetch coordinates uses all four elements
* (xyz/index) regardless of texture dimensionality,
* which means it's necessary to zero the unused
* components to keep everything happy */
if (midgard_texop == TEXTURE_OP_TEXEL_FETCH) {
- unsigned old_index = index;
-
- index = make_compiler_temp_reg(ctx);
-
- /* mov index, old_index */
- midgard_instruction mov = v_mov(old_index, index);
- mov.mask = 0x3;
- emit_mir_instruction(ctx, mov);
-
/* mov index.zw, #0 */
- mov = v_mov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), index);
+ midgard_instruction mov =
+ v_mov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), coords);
mov.has_constants = true;
mov.mask = (1 << COMPONENT_Z) | (1 << COMPONENT_W);
emit_mir_instruction(ctx, mov);
@@ -1768,7 +1774,7 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
unsigned temp = make_compiler_temp(ctx);
midgard_instruction ld = m_ld_cubemap_coords(temp, 0);
- ld.src[1] = index;
+ ld.src[1] = coords;
ld.mask = 0x3; /* xy */
ld.load_store.arg_1 = 0x20;
ld.swizzle[1][3] = COMPONENT_X;
@@ -1779,7 +1785,7 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
ins.swizzle[1][2] = COMPONENT_X;
ins.swizzle[1][3] = COMPONENT_X;
} else {
- ins.src[1] = index;
+ ins.src[1] = coords;
}
if (instr->sampler_dim == GLSL_SAMPLER_DIM_2D) {