Skip to content

Commit

Permalink
Merge pull request #1461 from Kangz/fix-warnings
Browse files Browse the repository at this point in the history
Fix -Wduplicate-enum and -Wrange-for-analysis.
  • Loading branch information
HansKristian-Work authored Sep 4, 2020
2 parents ba2d0e1 + bcd7153 commit bdbef7b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spirv_msl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3990,7 +3990,7 @@ void CompilerMSL::emit_custom_templates()
// otherwise they will cause problems when linked together in a single Metallib.
void CompilerMSL::emit_custom_functions()
{
for (uint32_t i = SPVFuncImplArrayCopyMultidimMax; i >= 2; i--)
for (uint32_t i = kArrayCopyMultidimMax; i >= 2; i--)
if (spv_function_implementations.count(static_cast<SPVFuncImpl>(SPVFuncImplArrayCopyMultidimBase + i)))
spv_function_implementations.insert(static_cast<SPVFuncImpl>(SPVFuncImplArrayCopyMultidimBase + i - 1));

Expand Down Expand Up @@ -7288,7 +7288,7 @@ void CompilerMSL::emit_array_copy(const string &lhs, uint32_t rhs_id, StorageCla
// if this is the only use of array copies in our shader.
if (type.array.size() > 1)
{
if (type.array.size() > SPVFuncImplArrayCopyMultidimMax)
if (type.array.size() > kArrayCopyMultidimMax)
SPIRV_CROSS_THROW("Cannot support this many dimensions for arrays of arrays.");
auto func = static_cast<SPVFuncImpl>(SPVFuncImplArrayCopyMultidimBase + type.array.size());
add_spv_func_and_recompile(func);
Expand Down
5 changes: 3 additions & 2 deletions spirv_msl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ static const uint32_t kArgumentBufferBinding = ~(3u);

static const uint32_t kMaxArgumentBuffers = 8;

// The arbitrary maximum for the nesting of array of array copies.
static const uint32_t kArrayCopyMultidimMax = 6;

// Decompiles SPIR-V to Metal Shading Language
class CompilerMSL : public CompilerGLSL
{
Expand Down Expand Up @@ -621,8 +624,6 @@ class CompilerMSL : public CompilerGLSL
SPVFuncImplConvertYCbCrBT601,
SPVFuncImplConvertYCbCrBT2020,
SPVFuncImplDynamicImageSampler,

SPVFuncImplArrayCopyMultidimMax = 6
};

// If the underlying resource has been used for comparison then duplicate loads of that resource must be too
Expand Down
2 changes: 1 addition & 1 deletion spirv_reflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ void CompilerReflection::emit_specialization_constants()
return;

json_stream->emit_json_key_array("specialization_constants");
for (const auto spec_const : specialization_constants)
for (const auto &spec_const : specialization_constants)
{
auto &c = get<SPIRConstant>(spec_const.id);
auto type = get<SPIRType>(c.constant_type);
Expand Down

0 comments on commit bdbef7b

Please sign in to comment.