Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SpvReflectVariableFlags to YAML #298

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading