diff options
author | Jason Ekstrand <[email protected]> | 2014-12-04 10:41:17 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-01-15 07:19:03 -0800 |
commit | e3fa49c9e6a38510fea4b65328d58e8a53859440 (patch) | |
tree | 337fdf1f113e3aef37c7889062c3dcfc504d1035 /src/glsl/nir/nir_validate.c | |
parent | 27663dbe8edfb7583d9d8fc3704a04a5c837fe05 (diff) |
nir/validate: Validate intrinsic source/destination sizes
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_validate.c')
-rw-r--r-- | src/glsl/nir/nir_validate.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c index bd7f5d71c94..e10f38bc6eb 100644 --- a/src/glsl/nir/nir_validate.c +++ b/src/glsl/nir/nir_validate.c @@ -318,10 +318,36 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) { unsigned num_srcs = nir_intrinsic_infos[instr->intrinsic].num_srcs; for (unsigned i = 0; i < num_srcs; i++) { + unsigned components_read = + nir_intrinsic_infos[instr->intrinsic].src_components[i]; + if (components_read == 0) + components_read = instr->num_components; + + assert(components_read > 0); + + if (instr->src[i].is_ssa) { + assert(components_read <= instr->src[i].ssa->num_components); + } else if (!instr->src[i].reg.reg->is_packed) { + assert(components_read <= instr->src[i].reg.reg->num_components); + } + validate_src(&instr->src[i], state); } if (nir_intrinsic_infos[instr->intrinsic].has_dest) { + unsigned components_written = + nir_intrinsic_infos[instr->intrinsic].dest_components; + if (components_written == 0) + components_written = instr->num_components; + + 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); } |