summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-11-12 10:38:12 -0800
committerJason Ekstrand <[email protected]>2015-11-23 11:04:49 -0800
commit03c9ad900e4f1feb2a4df8dd0c563937d999ae5d (patch)
tree2ece03fdd023f0961835602f5094c60b38aecde2 /src/glsl/nir
parent6c8ba59cff14a1a86273f4008ff2a8e68335ab25 (diff)
nir/validate: Validated dests after sources
Previously, if someone accidentally made an instruction that refers to its own SSA destination, the validator wouldn't catch it. The reason for this is that it validated the destination too early and, by the time it got to the source, the destination SSA value was already added to the set of seen SSA values so it would assume that it came from some previous instruction. By moving destination validation to be after source validation, the SSA value is not in the list of seen values and the validator will catch self-referential instructions. Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir')
-rw-r--r--src/glsl/nir/nir_validate.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
index ed374b921fa..06879d64ee2 100644
--- a/src/glsl/nir/nir_validate.c
+++ b/src/glsl/nir/nir_validate.c
@@ -290,11 +290,11 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state)
{
assert(instr->op < nir_num_opcodes);
- validate_alu_dest(&instr->dest, state);
-
for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
validate_alu_src(instr, i, state);
}
+
+ validate_alu_dest(&instr->dest, state);
}
static void
@@ -375,6 +375,11 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
validate_src(&instr->src[i], state);
}
+ unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
+ for (unsigned i = 0; i < num_vars; i++) {
+ validate_deref_var(instr, instr->variables[i], state);
+ }
+
if (nir_intrinsic_infos[instr->intrinsic].has_dest) {
unsigned components_written =
nir_intrinsic_infos[instr->intrinsic].dest_components;
@@ -392,11 +397,6 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
validate_dest(&instr->dest, state);
}
- unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
- for (unsigned i = 0; i < num_vars; i++) {
- validate_deref_var(instr, instr->variables[i], state);
- }
-
switch (instr->intrinsic) {
case nir_intrinsic_load_var: {
const struct glsl_type *type =
@@ -434,8 +434,6 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
static void
validate_tex_instr(nir_tex_instr *instr, validate_state *state)
{
- validate_dest(&instr->dest, state);
-
bool src_type_seen[nir_num_tex_src_types];
for (unsigned i = 0; i < nir_num_tex_src_types; i++)
src_type_seen[i] = false;
@@ -448,6 +446,8 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)
if (instr->sampler != NULL)
validate_deref_var(instr, instr->sampler, state);
+
+ validate_dest(&instr->dest, state);
}
static void