diff options
author | Jason Ekstrand <[email protected]> | 2018-12-15 08:31:51 -0600 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-01-08 00:38:30 +0000 |
commit | 5c3cb9c3ce3f9fb05c22536c30a68a7b09300642 (patch) | |
tree | bde031799ff13eeeb7020c0eea6f5f13db1b55cb /src/compiler/spirv/vtn_variables.c | |
parent | e90b738f201e7281e2a4cf43eddd2d15eb942cce (diff) |
spirv: Add error checking for Block and BufferBlock decorations
Variable pointers being well-defined across the block boundary requires
a couple of very specific SPIR-V validation rules. Normally, we'd trust
the validator to catch these but since CTS tests have been found in the
wild which violate them, we'll carry our own checks.
Reviewed-by: Alejandro PiƱeiro <[email protected]>
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_variables.c')
-rw-r--r-- | src/compiler/spirv/vtn_variables.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index c177952d7e1..7e80263abf3 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1686,9 +1686,26 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, switch (mode) { case vtn_variable_mode_ubo: + /* There's no other way to get vtn_variable_mode_ubo */ + vtn_assert(without_array->block); b->shader->info.num_ubos++; break; case vtn_variable_mode_ssbo: + if (storage_class == SpvStorageClassStorageBuffer && + !without_array->block) { + if (b->variable_pointers) { + vtn_fail("Variables in the StorageBuffer storage class must " + "have a struct type with the Block decoration"); + } else { + /* If variable pointers are not present, it's still malformed + * SPIR-V but we can parse it and do the right thing anyway. + * Since some of the 8-bit storage tests have bugs in this are, + * just make it a warning for now. + */ + vtn_warn("Variables in the StorageBuffer storage class must " + "have a struct type with the Block decoration"); + } + } b->shader->info.num_ssbos++; break; case vtn_variable_mode_uniform: |