diff options
author | Jason Ekstrand <[email protected]> | 2017-09-01 16:40:28 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-11-07 10:41:24 -0800 |
commit | ad77775809555bc215f468424215e8dddc7083bf (patch) | |
tree | d99d4e6f962dee3e6534647bcf95e10b026af32d /src/compiler/nir/nir_validate.c | |
parent | ab9220edd69fcb7016e15d4d96186eac524b45a4 (diff) |
nir: Validate base types on array dereferences
We were already validating that the parent type goes along with the
child type but we weren't actually validating that the parent type is
reasonable. This fixes that.
Acked-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_validate.c')
-rw-r--r-- | src/compiler/nir/nir_validate.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 2322c8f786d..9bf8c702901 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -397,7 +397,8 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state) } static void -validate_deref_chain(nir_deref *deref, validate_state *state) +validate_deref_chain(nir_deref *deref, nir_variable_mode mode, + validate_state *state) { validate_assert(state, deref->child == NULL || ralloc_parent(deref->child) == deref); @@ -405,6 +406,19 @@ validate_deref_chain(nir_deref *deref, validate_state *state) while (deref != NULL) { switch (deref->deref_type) { case nir_deref_type_array: + if (mode == nir_var_shared) { + /* Shared variables have a bit more relaxed rules because we need + * to be able to handle array derefs on vectors. Fortunately, + * nir_lower_io handles these just fine. + */ + validate_assert(state, glsl_type_is_array(parent->type) || + glsl_type_is_matrix(parent->type) || + glsl_type_is_vector(parent->type)); + } else { + /* Most of NIR cannot handle array derefs on vectors */ + validate_assert(state, glsl_type_is_array(parent->type) || + glsl_type_is_matrix(parent->type)); + } validate_assert(state, deref->type == glsl_get_array_element(parent->type)); if (nir_deref_as_array(deref)->deref_array_type == nir_deref_array_type_indirect) @@ -451,7 +465,7 @@ validate_deref_var(void *parent_mem_ctx, nir_deref_var *deref, validate_state *s validate_var_use(deref->var, state); - validate_deref_chain(&deref->deref, state); + validate_deref_chain(&deref->deref, deref->var->data.mode, state); } static void |