nir/lower_clip: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:

committed by
Jason Ekstrand

parent
e36fbcfc3f
commit
686f247b21
@@ -97,40 +97,23 @@ load_clipdist_input(nir_builder *b, nir_variable *in, nir_ssa_def **val)
|
|||||||
val[3] = nir_channel(b, &load->dest.ssa, 3);
|
val[3] = nir_channel(b, &load->dest.ssa, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct find_output_state
|
static nir_ssa_def *
|
||||||
|
find_output_in_block(nir_block *block, unsigned drvloc)
|
||||||
{
|
{
|
||||||
unsigned drvloc;
|
|
||||||
nir_ssa_def *def;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool
|
|
||||||
find_output_in_block(nir_block *block, void *void_state)
|
|
||||||
{
|
|
||||||
struct find_output_state *state = void_state;
|
|
||||||
nir_foreach_instr(block, instr) {
|
nir_foreach_instr(block, instr) {
|
||||||
|
|
||||||
if (instr->type == nir_instr_type_intrinsic) {
|
if (instr->type == nir_instr_type_intrinsic) {
|
||||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||||
if ((intr->intrinsic == nir_intrinsic_store_output) &&
|
if ((intr->intrinsic == nir_intrinsic_store_output) &&
|
||||||
nir_intrinsic_base(intr) == state->drvloc) {
|
nir_intrinsic_base(intr) == drvloc) {
|
||||||
assert(state->def == NULL);
|
|
||||||
assert(intr->src[0].is_ssa);
|
assert(intr->src[0].is_ssa);
|
||||||
assert(nir_src_as_const_value(intr->src[1]));
|
assert(nir_src_as_const_value(intr->src[1]));
|
||||||
state->def = intr->src[0].ssa;
|
return intr->src[0].ssa;
|
||||||
|
|
||||||
#if !defined(DEBUG)
|
|
||||||
/* for debug builds, scan entire shader to assert
|
|
||||||
* if output is written multiple times. For release
|
|
||||||
* builds just assume all is well and bail when we
|
|
||||||
* find first:
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: maybe this would be a useful helper?
|
/* TODO: maybe this would be a useful helper?
|
||||||
@@ -140,18 +123,27 @@ find_output_in_block(nir_block *block, void *void_state)
|
|||||||
static nir_ssa_def *
|
static nir_ssa_def *
|
||||||
find_output(nir_shader *shader, unsigned drvloc)
|
find_output(nir_shader *shader, unsigned drvloc)
|
||||||
{
|
{
|
||||||
struct find_output_state state = {
|
nir_ssa_def *def = NULL;
|
||||||
.drvloc = drvloc,
|
|
||||||
};
|
|
||||||
|
|
||||||
nir_foreach_function(shader, function) {
|
nir_foreach_function(shader, function) {
|
||||||
if (function->impl) {
|
if (function->impl) {
|
||||||
nir_foreach_block_reverse_call(function->impl,
|
nir_foreach_block_reverse(block, function->impl) {
|
||||||
find_output_in_block, &state);
|
nir_ssa_def *new_def = find_output_in_block(block, drvloc);
|
||||||
|
assert(!(new_def && def));
|
||||||
|
def = new_def;
|
||||||
|
#if !defined(DEBUG)
|
||||||
|
/* for debug builds, scan entire shader to assert
|
||||||
|
* if output is written multiple times. For release
|
||||||
|
* builds just assume all is well and bail when we
|
||||||
|
* find first:
|
||||||
|
*/
|
||||||
|
if (def)
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user