Fixed all warnings in the Vulkan build on Windows There were a bunch of warnings on Windows: - Precision loss through type conversion - Switch statement containing only default case - Zero sized array Bug b/130335507 Change-Id: I809db29db16f5dfd62d03d40353f4f2e0f6c3c93 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28768 Tested-by: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp index 57cbf4e..2857fb3 100644 --- a/src/Pipeline/PixelRoutine.cpp +++ b/src/Pipeline/PixelRoutine.cpp
@@ -509,8 +509,8 @@ Int4 zTest; // Bias values to make unsigned compares out of Reactor's (due SSE's) signed compares only - zValue = zValue - Short4(0x8000); - Z = Z - Short4(0x8000); + zValue = zValue - Short4(0x8000u); + Z = Z - Short4(0x8000u); switch(state.depthCompareMode) {
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp index e0bcdff..2b6cbd8 100644 --- a/src/Pipeline/SpirvShader.cpp +++ b/src/Pipeline/SpirvShader.cpp
@@ -942,7 +942,7 @@ auto set = routine->getPointer(id); auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet); - size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex); + int bindingOffset = static_cast<int>(setLayout->getBindingOffset(d.Binding, arrayIndex)); Pointer<Byte> bufferInfo = Pointer<Byte>(set + bindingOffset); // VkDescriptorBufferInfo* Pointer<Byte> buffer = *Pointer<Pointer<Byte>>(bufferInfo + OFFSET(VkDescriptorBufferInfo, buffer)); // vk::Buffer* @@ -974,7 +974,7 @@ Decorations d = {}; ApplyDecorationsForId(&d, baseObject.type); - size_t arrayIndex = 0; + uint32_t arrayIndex = 0; if (baseObject.kind == Object::Kind::DescriptorSet) { auto type = getType(typeId).definition.opcode();
diff --git a/src/Pipeline/SpirvShader_dbg.cpp b/src/Pipeline/SpirvShader_dbg.cpp index feacb87..3dd4e43 100644 --- a/src/Pipeline/SpirvShader_dbg.cpp +++ b/src/Pipeline/SpirvShader_dbg.cpp
@@ -21,8 +21,8 @@ { std::string SpirvShader::OpcodeName(spv::Op op) { - switch(op){ #ifndef NDEBUG + switch(op){ case spv::OpNop: return "Nop"; case spv::OpUndef: return "Undef"; case spv::OpSourceContinued: return "SourceContinued"; @@ -399,10 +399,12 @@ case spv::OpDecorateStringGOOGLE: return "DecorateStringGOOGLE"; case spv::OpMemberDecorateStringGOOGLE: return "MemberDecorateStringGOOGLE"; case spv::OpMax: return "Max"; -#endif // NDEBUG default: - return "Opcode<" + std::to_string(static_cast<int>(op)) + ">"; + break; } +#endif // NDEBUG + + return "Opcode<" + std::to_string(static_cast<int>(op)) + ">"; } } // namespace sw