Commit 5078d48f by Alexis Hetu Committed by Alexis Hétu

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/+/28768Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 00835736
...@@ -509,8 +509,8 @@ namespace sw ...@@ -509,8 +509,8 @@ namespace sw
Int4 zTest; Int4 zTest;
// Bias values to make unsigned compares out of Reactor's (due SSE's) signed compares only // Bias values to make unsigned compares out of Reactor's (due SSE's) signed compares only
zValue = zValue - Short4(0x8000); zValue = zValue - Short4(0x8000u);
Z = Z - Short4(0x8000); Z = Z - Short4(0x8000u);
switch(state.depthCompareMode) switch(state.depthCompareMode)
{ {
......
...@@ -942,7 +942,7 @@ namespace sw ...@@ -942,7 +942,7 @@ namespace sw
auto set = routine->getPointer(id); auto set = routine->getPointer(id);
auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet); 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> bufferInfo = Pointer<Byte>(set + bindingOffset); // VkDescriptorBufferInfo*
Pointer<Byte> buffer = *Pointer<Pointer<Byte>>(bufferInfo + OFFSET(VkDescriptorBufferInfo, buffer)); // vk::Buffer* Pointer<Byte> buffer = *Pointer<Pointer<Byte>>(bufferInfo + OFFSET(VkDescriptorBufferInfo, buffer)); // vk::Buffer*
...@@ -974,7 +974,7 @@ namespace sw ...@@ -974,7 +974,7 @@ namespace sw
Decorations d = {}; Decorations d = {};
ApplyDecorationsForId(&d, baseObject.type); ApplyDecorationsForId(&d, baseObject.type);
size_t arrayIndex = 0; uint32_t arrayIndex = 0;
if (baseObject.kind == Object::Kind::DescriptorSet) if (baseObject.kind == Object::Kind::DescriptorSet)
{ {
auto type = getType(typeId).definition.opcode(); auto type = getType(typeId).definition.opcode();
......
...@@ -21,8 +21,8 @@ namespace sw ...@@ -21,8 +21,8 @@ namespace sw
{ {
std::string SpirvShader::OpcodeName(spv::Op op) std::string SpirvShader::OpcodeName(spv::Op op)
{ {
switch(op){
#ifndef NDEBUG #ifndef NDEBUG
switch(op){
case spv::OpNop: return "Nop"; case spv::OpNop: return "Nop";
case spv::OpUndef: return "Undef"; case spv::OpUndef: return "Undef";
case spv::OpSourceContinued: return "SourceContinued"; case spv::OpSourceContinued: return "SourceContinued";
...@@ -399,10 +399,12 @@ namespace sw ...@@ -399,10 +399,12 @@ namespace sw
case spv::OpDecorateStringGOOGLE: return "DecorateStringGOOGLE"; case spv::OpDecorateStringGOOGLE: return "DecorateStringGOOGLE";
case spv::OpMemberDecorateStringGOOGLE: return "MemberDecorateStringGOOGLE"; case spv::OpMemberDecorateStringGOOGLE: return "MemberDecorateStringGOOGLE";
case spv::OpMax: return "Max"; case spv::OpMax: return "Max";
#endif // NDEBUG
default: default:
return "Opcode<" + std::to_string(static_cast<int>(op)) + ">"; break;
} }
#endif // NDEBUG
return "Opcode<" + std::to_string(static_cast<int>(op)) + ">";
} }
} // namespace sw } // namespace sw
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace vk namespace vk
{ {
const size_t Buffer::DataOffset = offsetof(Buffer, memory); const int Buffer::DataOffset = static_cast<int>(offsetof(Buffer, memory));
Buffer::Buffer(const VkBufferCreateInfo* pCreateInfo, void* mem) : Buffer::Buffer(const VkBufferCreateInfo* pCreateInfo, void* mem) :
flags(pCreateInfo->flags), size(pCreateInfo->size), usage(pCreateInfo->usage), flags(pCreateInfo->flags), size(pCreateInfo->size), usage(pCreateInfo->usage),
......
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
// DataOffset is the offset in bytes from the Buffer to the pointer to the // DataOffset is the offset in bytes from the Buffer to the pointer to the
// buffer's data memory. // buffer's data memory.
static const size_t DataOffset; static const int DataOffset;
private: private:
void* memory = nullptr; void* memory = nullptr;
......
...@@ -31,7 +31,7 @@ namespace vk ...@@ -31,7 +31,7 @@ namespace vk
using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>; using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>;
DescriptorSetLayout* layout; DescriptorSetLayout* layout;
uint8_t data[]; uint8_t data[1];
}; };
inline DescriptorSet* Cast(VkDescriptorSet object) inline DescriptorSet* Cast(VkDescriptorSet object)
......
...@@ -170,7 +170,7 @@ size_t DescriptorSetLayout::getBindingCount() const ...@@ -170,7 +170,7 @@ size_t DescriptorSetLayout::getBindingCount() const
return bindingCount; return bindingCount;
} }
size_t DescriptorSetLayout::getBindingOffset(uint32_t binding, uint32_t arrayElement) const size_t DescriptorSetLayout::getBindingOffset(uint32_t binding, size_t arrayElement) const
{ {
uint32_t index = getBindingIndex(binding); uint32_t index = getBindingIndex(binding);
auto typeSize = GetDescriptorSize(bindings[index].descriptorType); auto typeSize = GetDescriptorSize(bindings[index].descriptorType);
...@@ -189,9 +189,9 @@ bool DescriptorSetLayout::isBindingDynamic(uint32_t binding) const ...@@ -189,9 +189,9 @@ bool DescriptorSetLayout::isBindingDynamic(uint32_t binding) const
return isDynamic(bindings[index].descriptorType); return isDynamic(bindings[index].descriptorType);
} }
size_t DescriptorSetLayout::getDynamicDescriptorCount() const uint32_t DescriptorSetLayout::getDynamicDescriptorCount() const
{ {
size_t count = 0; uint32_t count = 0;
for (size_t i = 0; i < bindingCount; i++) for (size_t i = 0; i < bindingCount; i++)
{ {
if (isDynamic(bindings[i].descriptorType)) if (isDynamic(bindings[i].descriptorType))
...@@ -202,12 +202,12 @@ size_t DescriptorSetLayout::getDynamicDescriptorCount() const ...@@ -202,12 +202,12 @@ size_t DescriptorSetLayout::getDynamicDescriptorCount() const
return count; return count;
} }
size_t DescriptorSetLayout::getDynamicDescriptorOffset(uint32_t binding) const uint32_t DescriptorSetLayout::getDynamicDescriptorOffset(uint32_t binding) const
{ {
uint32_t n = getBindingIndex(binding); uint32_t n = getBindingIndex(binding);
ASSERT(isDynamic(bindings[n].descriptorType)); ASSERT(isDynamic(bindings[n].descriptorType));
size_t index = 0; uint32_t index = 0;
for (uint32_t i = 0; i < n; i++) for (uint32_t i = 0; i < n; i++)
{ {
if (isDynamic(bindings[i].descriptorType)) if (isDynamic(bindings[i].descriptorType))
......
...@@ -45,17 +45,17 @@ public: ...@@ -45,17 +45,17 @@ public:
// Returns the byte offset from the base address of the descriptor set for // Returns the byte offset from the base address of the descriptor set for
// the given binding and array element within that binding. // the given binding and array element within that binding.
size_t getBindingOffset(uint32_t binding, uint32_t arrayElement) const; size_t getBindingOffset(uint32_t binding, size_t arrayElement) const;
// Returns the number of descriptors across all bindings that are dynamic // Returns the number of descriptors across all bindings that are dynamic
// (see isBindingDynamic). // (see isBindingDynamic).
size_t getDynamicDescriptorCount() const; uint32_t getDynamicDescriptorCount() const;
// Returns the relative offset into the pipeline's dynamic offsets array for // Returns the relative offset into the pipeline's dynamic offsets array for
// the given binding. This offset should be added to the base offset // the given binding. This offset should be added to the base offset
// returned by PipelineLayout::getDynamicOffsetBase() to produce the // returned by PipelineLayout::getDynamicOffsetBase() to produce the
// starting index for dynamic descriptors. // starting index for dynamic descriptors.
size_t getDynamicDescriptorOffset(uint32_t binding) const; uint32_t getDynamicDescriptorOffset(uint32_t binding) const;
// Returns true if the given binding is of type: // Returns true if the given binding is of type:
// VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or
......
...@@ -34,7 +34,7 @@ void SurfaceKHR::getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabi ...@@ -34,7 +34,7 @@ void SurfaceKHR::getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabi
uint32_t SurfaceKHR::getSurfaceFormatsCount() const uint32_t SurfaceKHR::getSurfaceFormatsCount() const
{ {
return surfaceFormats.size(); return static_cast<uint32_t>(surfaceFormats.size());
} }
VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) const VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment