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
diff --git a/src/Vulkan/VkBuffer.cpp b/src/Vulkan/VkBuffer.cpp
index 9691fd3..8331b3f 100644
--- a/src/Vulkan/VkBuffer.cpp
+++ b/src/Vulkan/VkBuffer.cpp
@@ -21,7 +21,7 @@
 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) :
 	flags(pCreateInfo->flags), size(pCreateInfo->size), usage(pCreateInfo->usage),
diff --git a/src/Vulkan/VkBuffer.hpp b/src/Vulkan/VkBuffer.hpp
index bbd0fdc..fe29f8c 100644
--- a/src/Vulkan/VkBuffer.hpp
+++ b/src/Vulkan/VkBuffer.hpp
@@ -42,7 +42,7 @@
 
 	// DataOffset is the offset in bytes from the Buffer to the pointer to the
 	// buffer's data memory.
-	static const size_t DataOffset;
+	static const int DataOffset;
 
 private:
 	void*                 memory = nullptr;
diff --git a/src/Vulkan/VkDescriptorSet.hpp b/src/Vulkan/VkDescriptorSet.hpp
index ca0626b..dee38b5 100644
--- a/src/Vulkan/VkDescriptorSet.hpp
+++ b/src/Vulkan/VkDescriptorSet.hpp
@@ -31,7 +31,7 @@
 		using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>;
 
 		DescriptorSetLayout* layout;
-		uint8_t data[];
+		uint8_t data[1];
 	};
 
 	inline DescriptorSet* Cast(VkDescriptorSet object)
diff --git a/src/Vulkan/VkDescriptorSetLayout.cpp b/src/Vulkan/VkDescriptorSetLayout.cpp
index 80a0bec..1d57347 100644
--- a/src/Vulkan/VkDescriptorSetLayout.cpp
+++ b/src/Vulkan/VkDescriptorSetLayout.cpp
@@ -170,7 +170,7 @@
 	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);
 	auto typeSize = GetDescriptorSize(bindings[index].descriptorType);
@@ -189,9 +189,9 @@
 	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++)
 	{
 		if (isDynamic(bindings[i].descriptorType))
@@ -202,12 +202,12 @@
 	return count;
 }
 
-size_t DescriptorSetLayout::getDynamicDescriptorOffset(uint32_t binding) const
+uint32_t DescriptorSetLayout::getDynamicDescriptorOffset(uint32_t binding) const
 {
 	uint32_t n = getBindingIndex(binding);
 	ASSERT(isDynamic(bindings[n].descriptorType));
 
-	size_t index = 0;
+	uint32_t index = 0;
 	for (uint32_t i = 0; i < n; i++)
 	{
 		if (isDynamic(bindings[i].descriptorType))
diff --git a/src/Vulkan/VkDescriptorSetLayout.hpp b/src/Vulkan/VkDescriptorSetLayout.hpp
index 70ff227..d5aa560 100644
--- a/src/Vulkan/VkDescriptorSetLayout.hpp
+++ b/src/Vulkan/VkDescriptorSetLayout.hpp
@@ -45,17 +45,17 @@
 
 	// Returns the byte offset from the base address of the descriptor set for
 	// 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
 	// (see isBindingDynamic).
-	size_t getDynamicDescriptorCount() const;
+	uint32_t getDynamicDescriptorCount() const;
 
 	// Returns the relative offset into the pipeline's dynamic offsets array for
 	// the given binding. This offset should be added to the base offset
 	// returned by PipelineLayout::getDynamicOffsetBase() to produce the
 	// 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:
 	//  VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or
diff --git a/src/WSI/VkSurfaceKHR.cpp b/src/WSI/VkSurfaceKHR.cpp
index ce282f3..ba121b7 100644
--- a/src/WSI/VkSurfaceKHR.cpp
+++ b/src/WSI/VkSurfaceKHR.cpp
@@ -34,7 +34,7 @@
 
 uint32_t SurfaceKHR::getSurfaceFormatsCount() const
 {
-	return surfaceFormats.size();
+	return static_cast<uint32_t>(surfaceFormats.size());
 }
 
 VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) const