summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHai Nguyen <codingforlove@gmail.com>2022-01-06 17:02:21 -0500
committerHai Nguyen <codingforlove@gmail.com>2022-01-06 17:02:21 -0500
commitaca43c1f23272453c3d7b3b7e9fccac70fc2eb01 (patch)
treebf4cd1537cddb5b0a23eef4d3c722a8eb89bc416
parent2420f1c8f3d3ff915eddc6385b062220fe913ce2 (diff)
downloadSPIRV-Reflect-aca43c1f23272453c3d7b3b7e9fccac70fc2eb01.tar.gz
Added array information to spirv-reflect output
-rw-r--r--common/output_stream.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/common/output_stream.cpp b/common/output_stream.cpp
index e9628e4..6670cc4 100644
--- a/common/output_stream.cpp
+++ b/common/output_stream.cpp
@@ -26,6 +26,7 @@ struct TextLine {
uint32_t padded_size;
uint32_t array_stride;
uint32_t block_variable_flags;
+ std::vector<uint32_t> array_dims;
// Text Data
uint32_t text_line_flags;
std::vector<TextLine> lines;
@@ -641,13 +642,30 @@ void ParseBlockMembersToTextLines(const char* indent, int indent_depth, bool fla
tl = {};
tl.indent = expanded_indent;
tl.name = name;
- if (member.array.dims_count > 0) {
- std::stringstream ss_array;
- for (uint32_t array_dim_index = 0; array_dim_index < member.array.dims_count; ++array_dim_index) {
- uint32_t dim = member.array.dims[array_dim_index];
- ss_array << "[" << dim << "]";
+ if ((member.array.dims_count > 0) || (member.type_description->traits.array.dims > 0)) {
+ const SpvReflectArrayTraits* p_array_info = (member.array.dims_count > 0) ? &member.array : nullptr;
+ if (p_array_info == nullptr) {
+ //
+ // glslang based compilers stores array information in the type and not the variable
+ //
+ p_array_info = (member.type_description->traits.array.dims > 0) ? &member.type_description->traits.array : nullptr;
+ }
+ if (p_array_info != nullptr) {
+ std::stringstream ss_array;
+ for (uint32_t array_dim_index = 0; array_dim_index < p_array_info->dims_count; ++array_dim_index) {
+ uint32_t dim = p_array_info->dims[array_dim_index];
+ //
+ // dim = 0 means it's an unbounded array
+ //
+ if (dim > 0) {
+ ss_array << "[" << dim << "]";
+ }
+ else {
+ ss_array << "[]";
+ }
+ }
+ tl.name += ss_array.str();
}
- tl.name += ss_array.str();
}
tl.absolute_offset = member.absolute_offset;
tl.relative_offset = member.offset;