[Mesa-dev] [PATCH 085/133] nir: Validate that the sources of a phi have the same size as the destination

Jason Ekstrand jason at jlekstrand.net
Mon Dec 15 22:11:30 PST 2014


---
 src/glsl/nir/nir_validate.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
index 8354aa3..80faa15 100644
--- a/src/glsl/nir/nir_validate.c
+++ b/src/glsl/nir/nir_validate.c
@@ -466,9 +466,22 @@ validate_phi_src(nir_phi_instr *instr, nir_block *pred, validate_state *state)
 {
    state->instr = &instr->instr;
 
+   assert(instr->dest.is_ssa);
+
    exec_list_validate(&instr->srcs);
    foreach_list_typed(nir_phi_src, src, node, &instr->srcs) {
       if (src->pred == pred) {
+         unsigned num_components;
+         if (src->src.is_ssa)
+            num_components = src->src.ssa->num_components;
+         else {
+            if (src->src.reg.reg->is_packed)
+               num_components = 4; /* can't check anything */
+            else
+               num_components = src->src.reg.reg->num_components;
+         }
+         assert(num_components == instr->dest.ssa.num_components);
+
          validate_src(&src->src, state);
          return;
       }
-- 
2.2.0



More information about the mesa-dev mailing list