diff options
author | Jason Ekstrand <[email protected]> | 2019-01-12 10:32:13 -0600 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2019-03-07 09:09:15 -0800 |
commit | 0bc03198239699095ddd809d87ae37b536d3b892 (patch) | |
tree | 9db1cae833edcad0e129306aa9d529cc27ddf087 /src | |
parent | f852e93815a5132dd12b099f430c4c43aa708810 (diff) |
spirv: Pull offset/stride from the pointer for OpArrayLength
We can't pull it from the variable type because it might be an array of
blocks and not just the one block. While we're here, throw in some
error checking.
Reviewed-by: Lionel Landwerlin <[email protected]>
Cc: [email protected]
(cherry picked from commit f1dbc7e97d3dcb2104b9438d32cace9529575208)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/spirv/vtn_variables.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index f6b458b7e78..fe5340ab8cf 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -2444,9 +2444,17 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, case SpvOpArrayLength: { struct vtn_pointer *ptr = vtn_value(b, w[3], vtn_value_type_pointer)->pointer; + const uint32_t field = w[4]; - const uint32_t offset = ptr->var->type->offsets[w[4]]; - const uint32_t stride = ptr->var->type->members[w[4]]->stride; + vtn_fail_if(ptr->type->base_type != vtn_base_type_struct, + "OpArrayLength must take a pointer to a structure type"); + vtn_fail_if(field != ptr->type->length - 1 || + ptr->type->members[field]->base_type != vtn_base_type_array, + "OpArrayLength must reference the last memeber of the " + "structure and that must be an array"); + + const uint32_t offset = ptr->type->offsets[field]; + const uint32_t stride = ptr->type->members[field]->stride; if (!ptr->block_index) { struct vtn_access_chain chain = { |