Skip to content

Commit

Permalink
Fix undefined enums
Browse files Browse the repository at this point in the history
There are a few places where an enum value is purpoposly getting a value
that is not one of the enum values. This is causing a problem when
testing. I have a quick fix to make those values `int` instead of the
enum type.

The variables could contain `-1` as a special value to indicate that no
storage class or builtin is used. We cannot change the enum class to add
`-1` because it is defined in spirv headers.
  • Loading branch information
s-perron committed Nov 11, 2024
1 parent d341b0e commit 5e35c99
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions common/output_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ std::string ToStringShaderStage(SpvReflectShaderStageFlagBits stage) {
return "???";
}

std::string ToStringSpvStorageClass(SpvStorageClass storage_class) {
std::string ToStringSpvStorageClass(int storage_class) {
switch (storage_class) {
case SpvStorageClassUniformConstant:
return "UniformConstant";
Expand Down Expand Up @@ -343,7 +343,7 @@ std::string ToStringDescriptorType(SpvReflectDescriptorType value) {
return "VK_DESCRIPTOR_TYPE_???";
}

static std::string ToStringSpvBuiltIn(SpvBuiltIn built_in) {
static std::string ToStringSpvBuiltIn(int built_in) {
switch (built_in) {
case SpvBuiltInPosition:
return "Position";
Expand Down
4 changes: 2 additions & 2 deletions common/output_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

std::string ToStringSpvSourceLanguage(SpvSourceLanguage lang);
std::string ToStringSpvExecutionModel(SpvExecutionModel model);
std::string ToStringSpvStorageClass(SpvStorageClass storage_class);
std::string ToStringSpvStorageClass(int storage_class);
std::string ToStringSpvDim(SpvDim dim);
std::string ToStringSpvBuiltIn(const SpvReflectInterfaceVariable& variable, bool preface);
std::string ToStringSpvImageFormat(SpvImageFormat fmt);
Expand Down Expand Up @@ -66,4 +66,4 @@ class SpvReflectToYaml {
std::map<const SpvReflectInterfaceVariable*, uint32_t> interface_variable_to_index_;
};

#endif
#endif
4 changes: 2 additions & 2 deletions spirv_reflect.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ typedef struct SpvReflectTypeDescription {
const char* type_name;
// Non-NULL if type is member of a struct
const char* struct_member_name;
SpvStorageClass storage_class;
int storage_class;
SpvReflectTypeFlags type_flags;
SpvReflectDecorationFlags decoration_flags;

Expand Down Expand Up @@ -429,7 +429,7 @@ typedef struct SpvReflectInterfaceVariable {
SpvStorageClass storage_class;
const char* semantic;
SpvReflectDecorationFlags decoration_flags;
SpvBuiltIn built_in;
int built_in;
SpvReflectNumericTraits numeric;
SpvReflectArrayTraits array;

Expand Down

0 comments on commit 5e35c99

Please sign in to comment.