diff options
author | Hai Nguyen <379079+chaoticbob@users.noreply.github.com> | 2022-01-06 14:21:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 14:21:29 -0500 |
commit | f9c51151eafc9c5a405c359676557ccd9ad44760 (patch) | |
tree | 8d1cbb9378080dc6920c2b55359f9243f586c3db | |
parent | d920b79aadafe3ffd52764ac80370b15a611c83a (diff) | |
parent | 65efb7d9d3fca388b2f1657536f18e7e58e7ea3d (diff) | |
download | SPIRV-Reflect-f9c51151eafc9c5a405c359676557ccd9ad44760.tar.gz |
Merge pull request #114 from mgsegal/runtime_array
Runtime array
-rw-r--r-- | spirv_reflect.c | 12 | ||||
-rw-r--r-- | spirv_reflect.h | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/spirv_reflect.c b/spirv_reflect.c index 284774d..9548f8d 100644 --- a/spirv_reflect.c +++ b/spirv_reflect.c @@ -1671,16 +1671,19 @@ static SpvReflectResult ParseType( // Get length for current dimension SpvReflectPrvNode* p_length_node = FindNode(p_parser, length_id); if (IsNotNull(p_length_node)) { + uint32_t dim_index = p_type->traits.array.dims_count; if (p_length_node->op == SpvOpSpecConstant || p_length_node->op == SpvOpSpecConstantOp) { - p_type->traits.array.dims[p_type->traits.array.dims_count] = 0xFFFFFFFF; + p_type->traits.array.dims[dim_index] = 0xFFFFFFFF; + p_type->traits.array.spec_constant_op_ids[dim_index] = length_id; p_type->traits.array.dims_count += 1; } else { uint32_t length = 0; IF_READU32(result, p_parser, p_length_node->word_offset + 3, length); if (result == SPV_REFLECT_RESULT_SUCCESS) { // Write the array dim and increment the count and offset - p_type->traits.array.dims[p_type->traits.array.dims_count] = length; + p_type->traits.array.dims[dim_index] = length; + p_type->traits.array.spec_constant_op_ids[dim_index] = 0xFFFFFFFF; p_type->traits.array.dims_count += 1; } else { result = SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_ID_REFERENCE; @@ -1705,6 +1708,11 @@ static SpvReflectResult ParseType( p_type->type_flags |= SPV_REFLECT_TYPE_FLAG_ARRAY; uint32_t element_type_id = (uint32_t)INVALID_VALUE; IF_READU32(result, p_parser, p_node->word_offset + 2, element_type_id); + p_type->traits.array.stride = p_node->decorations.array_stride; + uint32_t dim_index = p_type->traits.array.dims_count; + p_type->traits.array.dims[dim_index] = 0; + p_type->traits.array.spec_constant_op_ids[dim_index] = 0; + p_type->traits.array.dims_count += 1; // Parse next dimension or element type SpvReflectPrvNode* p_next_node = FindNode(p_parser, element_type_id); if (IsNotNull(p_next_node)) { diff --git a/spirv_reflect.h b/spirv_reflect.h index 9aac36d..8096923 100644 --- a/spirv_reflect.h +++ b/spirv_reflect.h @@ -262,7 +262,11 @@ typedef struct SpvReflectImageTraits { typedef struct SpvReflectArrayTraits { uint32_t dims_count; + // Each entry is: 0xFFFFFFFF for a specialization constant dimension, + // 0 for a runtime array dimension, and the array length otherwise. uint32_t dims[SPV_REFLECT_MAX_ARRAY_DIMS]; + // Stores Ids for dimensions that are specialization constants + uint32_t spec_constant_op_ids[SPV_REFLECT_MAX_ARRAY_DIMS]; uint32_t stride; // Measured in bytes } SpvReflectArrayTraits; |