aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2019-04-26 11:39:42 -0700
committerRob Clark <[email protected]>2019-05-02 11:19:22 -0700
commita2c89a85f4f69b5eacc8052d6cc4f4efd07a1294 (patch)
treeaba9d002484b8846cacd52d5fc0153096a8c4bd4
parent691d5a825a633fea81af9f83828d5d526ac6b22d (diff)
nir: fix lower_wpos_ytransform in load_frag_coord case
Apparently we never hit this path. Or at least haven't for a rather long time. But in either case (load_deref or load_frag_coord), we can just directly use the intrinsic's ssa dest. So stop passing the nir_variable (which would be NULL in the load_frag_coord case) around and instead just use &intr->dest.ssa. (This ofc means we need to setup the cursor to insert *after* the instruction, which seems to be another bug of the original implementation.) Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]>
-rw-r--r--src/compiler/nir/nir_lower_wpos_ytransform.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c b/src/compiler/nir/nir_lower_wpos_ytransform.c
index 34a4801d66b..d0a694f889b 100644
--- a/src/compiler/nir/nir_lower_wpos_ytransform.c
+++ b/src/compiler/nir/nir_lower_wpos_ytransform.c
@@ -77,18 +77,18 @@ nir_cmp(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1, nir_ssa_def *src2)
/* see emit_wpos_adjustment() in st_mesa_to_tgsi.c */
static void
emit_wpos_adjustment(lower_wpos_ytransform_state *state,
- nir_intrinsic_instr *intr, nir_variable *fragcoord,
- bool invert, float adjX, float adjY[2])
+ nir_intrinsic_instr *intr, bool invert,
+ float adjX, float adjY[2])
{
nir_builder *b = &state->b;
nir_ssa_def *wpostrans, *wpos_temp, *wpos_temp_y, *wpos_input;
assert(intr->dest.is_ssa);
+ wpos_input = &intr->dest.ssa;
- b->cursor = nir_before_instr(&intr->instr);
+ b->cursor = nir_after_instr(&intr->instr);
wpostrans = get_transform(state);
- wpos_input = nir_load_var(b, fragcoord);
/* First, apply the coordinate shift: */
if (adjX || adjY[0] || adjY[1]) {
@@ -139,12 +139,13 @@ emit_wpos_adjustment(lower_wpos_ytransform_state *state,
nir_channel(b, wpos_temp, 2),
nir_channel(b, wpos_temp, 3));
- nir_ssa_def_rewrite_uses(&intr->dest.ssa, nir_src_for_ssa(wpos_temp));
+ nir_ssa_def_rewrite_uses_after(&intr->dest.ssa,
+ nir_src_for_ssa(wpos_temp),
+ wpos_temp->parent_instr);
}
static void
-lower_fragcoord(lower_wpos_ytransform_state *state,
- nir_intrinsic_instr *intr, nir_variable *fragcoord)
+lower_fragcoord(lower_wpos_ytransform_state *state, nir_intrinsic_instr *intr)
{
const nir_lower_wpos_ytransform_options *options = state->options;
float adjX = 0.0f;
@@ -228,7 +229,7 @@ lower_fragcoord(lower_wpos_ytransform_state *state,
}
}
- emit_wpos_adjustment(state, intr, fragcoord, invert, adjX, adjY);
+ emit_wpos_adjustment(state, intr, invert, adjX, adjY);
}
static void
@@ -331,7 +332,7 @@ lower_wpos_ytransform_block(lower_wpos_ytransform_state *state, nir_block *block
(var->data.mode == nir_var_system_value &&
var->data.location == SYSTEM_VALUE_FRAG_COORD)) {
/* gl_FragCoord should not have array/struct derefs: */
- lower_fragcoord(state, intr, var);
+ lower_fragcoord(state, intr);
} else if (var->data.mode == nir_var_system_value &&
var->data.location == SYSTEM_VALUE_SAMPLE_POS) {
lower_load_sample_pos(state, intr);
@@ -341,7 +342,7 @@ lower_wpos_ytransform_block(lower_wpos_ytransform_state *state, nir_block *block
lower_load_pointcoord(state, intr);
}
} else if (intr->intrinsic == nir_intrinsic_load_frag_coord) {
- lower_fragcoord(state, intr, NULL);
+ lower_fragcoord(state, intr);
} else if (intr->intrinsic == nir_intrinsic_load_sample_pos) {
lower_load_sample_pos(state, intr);
} else if (intr->intrinsic == nir_intrinsic_interp_deref_at_offset) {