From aca43c1f23272453c3d7b3b7e9fccac70fc2eb01 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Thu, 6 Jan 2022 17:02:21 -0500 Subject: Added array information to spirv-reflect output --- common/output_stream.cpp | 30 ++++++++++++++++++++++++------ 1 file 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 array_dims; // Text Data uint32_t text_line_flags; std::vector 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; -- cgit v1.2.3