nir/validate: Ensure that outputs are write-only and inputs are read-only
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 3 Dec 2014 22:47:17 +0000 (14:47 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Jan 2015 15:19:02 +0000 (07:19 -0800)
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/glsl/nir/nir_validate.c

index 0a015e43bba7270df73831f352f9c3ae66a544df..73ca1b0e7869e7acf7e2d179d9f3029c2d1a5b69 100644 (file)
@@ -330,6 +330,29 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
       validate_deref_var(instr->variables[i], state);
    }
 
+   switch (instr->intrinsic) {
+   case nir_intrinsic_load_var_vec1:
+   case nir_intrinsic_load_var_vec2:
+   case nir_intrinsic_load_var_vec3:
+   case nir_intrinsic_load_var_vec4:
+      assert(instr->variables[0]->var->data.mode != nir_var_shader_out);
+      break;
+   case nir_intrinsic_store_var_vec1:
+   case nir_intrinsic_store_var_vec2:
+   case nir_intrinsic_store_var_vec3:
+   case nir_intrinsic_store_var_vec4:
+      assert(instr->variables[0]->var->data.mode != nir_var_shader_in &&
+             instr->variables[0]->var->data.mode != nir_var_uniform);
+      break;
+   case nir_intrinsic_copy_var:
+      assert(instr->variables[0]->var->data.mode != nir_var_shader_in &&
+             instr->variables[0]->var->data.mode != nir_var_uniform);
+      assert(instr->variables[1]->var->data.mode != nir_var_shader_out);
+      break;
+   default:
+      break;
+   }
+
    if (instr->has_predicate)
       validate_src(&instr->predicate, state);
 }