[Mesa-dev] [PATCH 4/4] nir: Validate that the tex_instr dest is the right size.
Eric Anholt
eric at anholt.net
Mon Apr 13 13:36:49 PDT 2015
---
src/glsl/nir/nir_validate.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
index d7ba374..2c80e44 100644
--- a/src/glsl/nir/nir_validate.c
+++ b/src/glsl/nir/nir_validate.c
@@ -107,6 +107,16 @@ validate_src_components(nir_src *src, int num_components)
}
static void
+validate_dest_components(nir_dest *dest, int num_components)
+{
+ if (dest->is_ssa) {
+ assert(num_components <= dest->ssa.num_components);
+ } else if (!dest->reg.reg->is_packed) {
+ assert(num_components <= dest->reg.reg->num_components);
+ }
+}
+
+static void
validate_reg_src(nir_reg_src *src, validate_state *state)
{
assert(src->reg != NULL);
@@ -383,13 +393,8 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
assert(components_written > 0);
- if (instr->dest.is_ssa) {
- assert(components_written <= instr->dest.ssa.num_components);
- } else if (!instr->dest.reg.reg->is_packed) {
- assert(components_written <= instr->dest.reg.reg->num_components);
- }
-
validate_dest(&instr->dest, state);
+ validate_dest_components(&instr->dest, components_written);
}
unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
@@ -434,6 +439,8 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)
if (instr->sampler != NULL)
validate_deref_var(instr, instr->sampler, state);
+
+ validate_dest_components(&instr->dest, nir_tex_instr_dest_size(instr));
}
static void
--
2.1.4
More information about the mesa-dev
mailing list