Skip to content

Commit

Permalink
Add SpvReflectVariableFlags to YAML (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg authored Jan 15, 2025
1 parent 8d8bde2 commit e8f0079
Show file tree
Hide file tree
Showing 90 changed files with 1,100 additions and 0 deletions.
24 changes: 24 additions & 0 deletions common/output_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,27 @@ std::string ToStringTypeFlags(SpvReflectTypeFlags type_flags) {
return sstream.str();
}

std::string ToStringVariableFlags(SpvReflectVariableFlags var_flags) {
if (var_flags == SPV_REFLECT_VARIABLE_FLAGS_NONE) {
return "NONE";
}

#define PRINT_AND_CLEAR_TYPE_FLAG(stream, flags, bit) \
if (((flags) & (SPV_REFLECT_VARIABLE_FLAGS_##bit)) == (SPV_REFLECT_VARIABLE_FLAGS_##bit)) { \
stream << #bit << " "; \
flags ^= SPV_REFLECT_VARIABLE_FLAGS_##bit; \
}
std::stringstream sstream;
PRINT_AND_CLEAR_TYPE_FLAG(sstream, var_flags, UNUSED);
PRINT_AND_CLEAR_TYPE_FLAG(sstream, var_flags, PHYSICAL_POINTER_COPY);
#undef PRINT_AND_CLEAR_TYPE_FLAG
if (var_flags != 0) {
// Unhandled SpvReflectVariableFlags bit
sstream << "???";
}
return sstream.str();
}

std::string ToStringDecorationFlags(SpvReflectDecorationFlags decoration_flags) {
if (decoration_flags == SPV_REFLECT_DECORATION_NONE) {
return "NONE";
Expand Down Expand Up @@ -1832,6 +1853,9 @@ void SpvReflectToYaml::WriteBlockVariable(std::ostream& os, const SpvReflectBloc
// } SpvReflectArrayTraits;
os << " }" << std::endl;

// SpvReflectVariableFlags flags;
os << t1 << "flags: " << AsHexString(bv.flags) << " # " << ToStringVariableFlags(bv.flags) << std::endl;

// uint32_t member_count;
os << t1 << "member_count: " << bv.member_count << std::endl;
// struct SpvReflectBlockVariable* members;
Expand Down
1 change: 1 addition & 0 deletions common/output_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ std::string ToStringShaderStage(SpvReflectShaderStageFlagBits stage);
std::string ToStringResourceType(SpvReflectResourceType type);
std::string ToStringDescriptorType(SpvReflectDescriptorType value);
std::string ToStringTypeFlags(SpvReflectTypeFlags type_flags);
std::string ToStringVariableFlags(SpvReflectVariableFlags flags);
std::string ToStringDecorationFlags(SpvReflectDecorationFlags decoration_flags);
std::string ToStringDescriptorType(SpvReflectDescriptorType value);
std::string ToStringFormat(SpvReflectFormat fmt);
Expand Down
3 changes: 3 additions & 0 deletions tests/access_chains/array_length_from_access_chain.spv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ all_block_variables:
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000001 # UNUSED
member_count: 0
members:
type_description: *td0
Expand All @@ -82,6 +83,7 @@ all_block_variables:
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000001 # UNUSED
member_count: 0
members:
type_description: *td1
Expand All @@ -97,6 +99,7 @@ all_block_variables:
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 2
members:
- *bv0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ all_block_variables:
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000001 # UNUSED
member_count: 0
members:
type_description: *td0
Expand All @@ -117,6 +118,7 @@ all_block_variables:
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000001 # UNUSED
member_count: 0
members:
type_description: *td4
Expand All @@ -132,6 +134,7 @@ all_block_variables:
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000001 # UNUSED
member_count: 1
members:
- *bv1
Expand All @@ -148,6 +151,7 @@ all_block_variables:
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 2
members:
- *bv0
Expand Down
Loading

0 comments on commit e8f0079

Please # to comment.