Warnings fix

Fixes most warnings using the Visual Studio C++ 64 bit compiler.
Should be noop

Bug b/132445520

Change-Id: I7844062244478b39299729cf4e4c0b647e2f5b14
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31150
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Device/Blitter.cpp b/src/Device/Blitter.cpp
index 63c6040..edf7cad 100644
--- a/src/Device/Blitter.cpp
+++ b/src/Device/Blitter.cpp
@@ -231,7 +231,7 @@
 							for(uint32_t i = 0; i < area.extent.height; i++)
 							{
 								ASSERT(d < dest->end());
-								sw::clear((uint16_t*)d, packed, area.extent.width);
+								sw::clear((uint16_t*)d, static_cast<uint16_t>(packed), area.extent.width);
 								d += rowPitchBytes;
 							}
 							break;
@@ -1447,7 +1447,7 @@
 									preScaled = true;
 								}
 								Float4 accum = color;
-								for(int i = 1; i < state.srcSamples; i++)
+								for(int sample = 1; sample < state.srcSamples; sample++)
 								{
 									s += *Pointer<Int>(blit + OFFSET(BlitData, sSliceB));
 									if(!read(color, s, state))
diff --git a/src/Device/Color.hpp b/src/Device/Color.hpp
index a87f5db..0e6fc27 100644
--- a/src/Device/Color.hpp
+++ b/src/Device/Color.hpp
@@ -92,19 +92,19 @@
 	template<>
 	inline Color<byte>::Color(const Color<short> &c)
 	{
-		r = clamp(c.r >> 4, 0, 255);
-		g = clamp(c.g >> 4, 0, 255);
-		b = clamp(c.b >> 4, 0, 255);
-		a = clamp(c.a >> 4, 0, 255);
+		r = static_cast<byte>(clamp(c.r >> 4, 0, 255));
+		g = static_cast<byte>(clamp(c.g >> 4, 0, 255));
+		b = static_cast<byte>(clamp(c.b >> 4, 0, 255));
+		a = static_cast<byte>(clamp(c.a >> 4, 0, 255));
 	}
 
 	template<>
 	inline Color<byte>::Color(const Color<float> &c)
 	{
-		r = ifloor(clamp(c.r * 256.0f, 0.0f, 255.0f));
-		g = ifloor(clamp(c.g * 256.0f, 0.0f, 255.0f));
-		b = ifloor(clamp(c.b * 256.0f, 0.0f, 255.0f));
-		a = ifloor(clamp(c.a * 256.0f, 0.0f, 255.0f));
+		r = static_cast<byte>(ifloor(clamp(c.r * 256.0f, 0.0f, 255.0f)));
+		g = static_cast<byte>(ifloor(clamp(c.g * 256.0f, 0.0f, 255.0f)));
+		b = static_cast<byte>(ifloor(clamp(c.b * 256.0f, 0.0f, 255.0f)));
+		a = static_cast<byte>(ifloor(clamp(c.a * 256.0f, 0.0f, 255.0f)));
 	}
 
 	template<>
@@ -137,10 +137,10 @@
 	template<>
 	inline Color<short>::Color(const Color<float> &c)
 	{
-		r = iround(clamp(c.r * 4095.0f, -4096.0f, 4095.0f));
-		g = iround(clamp(c.g * 4095.0f, -4096.0f, 4095.0f));
-		b = iround(clamp(c.b * 4095.0f, -4096.0f, 4095.0f));
-		a = iround(clamp(c.a * 4095.0f, -4096.0f, 4095.0f));
+		r = static_cast<short>(iround(clamp(c.r * 4095.0f, -4096.0f, 4095.0f)));
+		g = static_cast<short>(iround(clamp(c.g * 4095.0f, -4096.0f, 4095.0f)));
+		b = static_cast<short>(iround(clamp(c.b * 4095.0f, -4096.0f, 4095.0f)));
+		a = static_cast<short>(iround(clamp(c.a * 4095.0f, -4096.0f, 4095.0f)));
 	}
 
 	template<>
diff --git a/src/Device/ETC_Decoder.cpp b/src/Device/ETC_Decoder.cpp
index c40f7da..aba807f 100644
--- a/src/Device/ETC_Decoder.cpp
+++ b/src/Device/ETC_Decoder.cpp
@@ -16,21 +16,21 @@
 
 namespace
 {
-	inline int clampByte(int value)
+	inline unsigned char clampByte(int value)
 	{
-		return (value < 0) ? 0 : ((value > 255) ? 255 : value);
+		return static_cast<unsigned char>((value < 0) ? 0 : ((value > 255) ? 255 : value));
 	}
 
-	inline int clampSByte(int value)
+	inline signed char clampSByte(int value)
 	{
-		return (value < -128) ? -128 : ((value > 127) ? 127 : value);
+		return static_cast<signed char>((value < -128) ? -128 : ((value > 127) ? 127 : value));
 	}
 
-	inline short clampEAC(short value, bool isSigned)
+	inline short clampEAC(int value, bool isSigned)
 	{
 		short min = isSigned ? -1023 : 0;
 		short max = isSigned ? 1023 : 2047;
-		return ((value < min) ? min : ((value > max) ? max : value)) << 5;
+		return static_cast<short>(((value < min) ? min : ((value > max) ? max : value)) << 5);
 	}
 
 	struct bgra8
@@ -46,20 +46,20 @@
 
 		inline void set(int red, int green, int blue)
 		{
-			r = static_cast<unsigned char>(clampByte(red));
-			g = static_cast<unsigned char>(clampByte(green));
-			b = static_cast<unsigned char>(clampByte(blue));
+			r = clampByte(red);
+			g = clampByte(green);
+			b = clampByte(blue);
 		}
 
 		inline void set(int red, int green, int blue, int alpha)
 		{
-			r = static_cast<unsigned char>(clampByte(red));
-			g = static_cast<unsigned char>(clampByte(green));
-			b = static_cast<unsigned char>(clampByte(blue));
-			a = static_cast<unsigned char>(clampByte(alpha));
+			r = clampByte(red);
+			g = clampByte(green);
+			b = clampByte(blue);
+			a = clampByte(alpha);
 		}
 
-		const bgra8& addA(int alpha)
+		const bgra8& addA(unsigned char alpha)
 		{
 			a = alpha;
 			return *this;
diff --git a/src/Device/PixelProcessor.cpp b/src/Device/PixelProcessor.cpp
index 797e3da..e9e708c 100644
--- a/src/Device/PixelProcessor.cpp
+++ b/src/Device/PixelProcessor.cpp
@@ -67,10 +67,10 @@
 	void PixelProcessor::setBlendConstant(const Color<float> &blendConstant)
 	{
 		// FIXME: Compact into generic function   // FIXME: Clamp
-		short blendConstantR = iround(65535 * blendConstant.r);
-		short blendConstantG = iround(65535 * blendConstant.g);
-		short blendConstantB = iround(65535 * blendConstant.b);
-		short blendConstantA = iround(65535 * blendConstant.a);
+		short blendConstantR = static_cast<short>(iround(65535 * blendConstant.r));
+		short blendConstantG = static_cast<short>(iround(65535 * blendConstant.g));
+		short blendConstantB = static_cast<short>(iround(65535 * blendConstant.b));
+		short blendConstantA = static_cast<short>(iround(65535 * blendConstant.a));
 
 		factor.blendConstant4W[0][0] = blendConstantR;
 		factor.blendConstant4W[0][1] = blendConstantR;
@@ -93,10 +93,10 @@
 		factor.blendConstant4W[3][3] = blendConstantA;
 
 		// FIXME: Compact into generic function   // FIXME: Clamp
-		short invBlendConstantR = iround(65535 * (1 - blendConstant.r));
-		short invBlendConstantG = iround(65535 * (1 - blendConstant.g));
-		short invBlendConstantB = iround(65535 * (1 - blendConstant.b));
-		short invBlendConstantA = iround(65535 * (1 - blendConstant.a));
+		short invBlendConstantR = static_cast<short>(iround(65535 * (1 - blendConstant.r)));
+		short invBlendConstantG = static_cast<short>(iround(65535 * (1 - blendConstant.g)));
+		short invBlendConstantB = static_cast<short>(iround(65535 * (1 - blendConstant.b)));
+		short invBlendConstantA = static_cast<short>(iround(65535 * (1 - blendConstant.a)));
 
 		factor.invBlendConstant4W[0][0] = invBlendConstantR;
 		factor.invBlendConstant4W[0][1] = invBlendConstantR;
diff --git a/src/Device/Stream.hpp b/src/Device/Stream.hpp
index b9ff604..654a9f8 100644
--- a/src/Device/Stream.hpp
+++ b/src/Device/Stream.hpp
@@ -52,7 +52,7 @@
 			this->instanceStride = 0;
 		}
 
-		Stream &define(StreamType type, unsigned int count, bool normalized = false)
+		Stream &define(StreamType type, unsigned char count, bool normalized = false)
 		{
 			this->type = type;
 			this->count = count;
@@ -61,7 +61,7 @@
 			return *this;
 		}
 
-		Stream &define(const void *buffer, StreamType type, unsigned int count, bool normalized = false)
+		Stream &define(const void *buffer, StreamType type, unsigned char count, bool normalized = false)
 		{
 			this->buffer = buffer;
 			this->type = type;
diff --git a/src/Pipeline/SamplerCore.cpp b/src/Pipeline/SamplerCore.cpp
index 302c73e..0dd30b9 100644
--- a/src/Pipeline/SamplerCore.cpp
+++ b/src/Pipeline/SamplerCore.cpp
@@ -1343,16 +1343,16 @@
 				c.x = (c.x & Short4(0xF800u));
 				break;
 			case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
-				c.w = (c.x << 12) & Short4(0xF000);
-				c.z = (c.x) & Short4(0xF000);
-				c.y = (c.x << 4) & Short4(0xF000);
-				c.x = (c.x << 8) & Short4(0xF000);
+				c.w = (c.x << 12) & Short4(0xF000u);
+				c.z = (c.x) & Short4(0xF000u);
+				c.y = (c.x << 4) & Short4(0xF000u);
+				c.x = (c.x << 8) & Short4(0xF000u);
 				break;
 			case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
-				c.w = (c.x) & Short4(0x8000);
-				c.z = (c.x << 11) & Short4(0xF800);
-				c.y = (c.x << 6) & Short4(0xF800);
-				c.x = (c.x << 1) & Short4(0xF800);
+				c.w = (c.x) & Short4(0x8000u);
+				c.z = (c.x << 11) & Short4(0xF800u);
+				c.y = (c.x << 6) & Short4(0xF800u);
+				c.x = (c.x << 1) & Short4(0xF800u);
 				break;
 			default:
 				ASSERT(false);
@@ -1408,10 +1408,10 @@
 						if (state.textureFormat == VK_FORMAT_R8G8B8A8_SNORM)
 						{
 							// TODO: avoid populating the low bits at all.
-							c.x &= Short4(0xFF00);
-							c.y &= Short4(0xFF00);
-							c.z &= Short4(0xFF00);
-							c.w &= Short4(0xFF00);
+							c.x &= Short4(0xFF00u);
+							c.y &= Short4(0xFF00u);
+							c.z &= Short4(0xFF00u);
+							c.w &= Short4(0xFF00u);
 						}
 
 						break;
@@ -1483,7 +1483,7 @@
 					case VK_FORMAT_R8_SNORM:
 						// TODO: avoid populating the low bits at all.
 						c.x = Unpack(As<Byte4>(c0));
-						c.x &= Short4(0xff00);
+						c.x &= Short4(0xFF00u);
 						break;
 					default:
 						c.x = Unpack(As<Byte4>(c0));
@@ -1660,9 +1660,14 @@
 			{
 				// Scaling and bias for studio-swing range: Y = [16 .. 235], U/V = [16 .. 240]
 				// Scale down by 0x0101 to normalize the 8.8 samples, and up by 0x7FFF for signed 15-bit output.
-				Float4 y = (Float4(Y)  - Float4(state.studioSwing ? 16 * 0x0101 : 0)) * Float4(float(0x7FFF) / (state.studioSwing ? 219 * 0x0101 : 255 * 0x0101));
-				Float4 u = (Float4(Cb) - Float4(128 * 0x0101))                        * Float4(float(0x7FFF) / (state.studioSwing ? 224 * 0x0101 : 255 * 0x0101));
-				Float4 v = (Float4(Cr) - Float4(128 * 0x0101))                        * Float4(float(0x7FFF) / (state.studioSwing ? 224 * 0x0101 : 255 * 0x0101));
+				float yOffset  = static_cast<float>(state.studioSwing ? 16 * 0x0101 : 0);
+				float uvOffset = static_cast<float>(128 * 0x0101);
+				float yFactor  = static_cast<float>(0x7FFF) / static_cast<float>(state.studioSwing ? 219 * 0x0101 : 255 * 0x0101);
+				float uvFactor = static_cast<float>(0x7FFF) / static_cast<float>(state.studioSwing ? 224 * 0x0101 : 255 * 0x0101);
+
+				Float4 y = (Float4(Y)  - Float4(yOffset))  * Float4(yFactor);
+				Float4 u = (Float4(Cb) - Float4(uvOffset)) * Float4(uvFactor);
+				Float4 v = (Float4(Cr) - Float4(uvOffset)) * Float4(uvFactor);
 
 				if(state.ycbcrModel == VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY)
 				{
@@ -1936,7 +1941,7 @@
 
 		bool scaled = !hasFloatTexture() && !hasUnnormalizedIntegerTexture() && !state.compareEnable;
 		bool sign = !hasUnsignedTextureComponent(0);
-		Int4 float_one = scaled ? As<Int4>(Float4(sign ? 0x7FFF : 0xFFFF)) : As<Int4>(Float4(1.0f));
+		Int4 float_one = scaled ? As<Int4>(Float4(static_cast<float>(sign ? 0x7FFF : 0xFFFF))) : As<Int4>(Float4(1.0f));
 
 		switch(state.border)
 		{
diff --git a/src/Pipeline/ShaderCore.cpp b/src/Pipeline/ShaderCore.cpp
index 6a9fc08..b28e8f4 100644
--- a/src/Pipeline/ShaderCore.cpp
+++ b/src/Pipeline/ShaderCore.cpp
@@ -135,7 +135,7 @@
 		return ii * ff;
 	}
 
-	Float4 logarithm2(RValue<Float4> x, bool absolute, bool pp)
+	Float4 logarithm2(RValue<Float4> x, bool pp)
 	{
 		Float4 x0;
 		Float4 x1;
@@ -166,15 +166,15 @@
 		return exponential2(Float4(1.44269504f) * x, pp);   // 1/ln(2)
 	}
 
-	Float4 logarithm(RValue<Float4> x, bool absolute, bool pp)
+	Float4 logarithm(RValue<Float4> x, bool pp)
 	{
 		// FIXME: Propagate the constant
-		return Float4(6.93147181e-1f) * logarithm2(x, absolute, pp);   // ln(2)
+		return Float4(6.93147181e-1f) * logarithm2(x, pp);   // ln(2)
 	}
 
 	Float4 power(RValue<Float4> x, RValue<Float4> y, bool pp)
 	{
-		Float4 log = logarithm2(x, true, pp);
+		Float4 log = logarithm2(x, pp);
 		log *= y;
 		return exponential2(log, pp);
 	}
diff --git a/src/Pipeline/ShaderCore.hpp b/src/Pipeline/ShaderCore.hpp
index e1da028..fb59e93 100644
--- a/src/Pipeline/ShaderCore.hpp
+++ b/src/Pipeline/ShaderCore.hpp
@@ -55,9 +55,9 @@
 	};
 
 	Float4 exponential2(RValue<Float4> x, bool pp = false);
-	Float4 logarithm2(RValue<Float4> x, bool abs, bool pp = false);
+	Float4 logarithm2(RValue<Float4> x, bool pp = false);
 	Float4 exponential(RValue<Float4> x, bool pp = false);
-	Float4 logarithm(RValue<Float4> x, bool abs, bool pp = false);
+	Float4 logarithm(RValue<Float4> x, bool pp = false);
 	Float4 power(RValue<Float4> x, RValue<Float4> y, bool pp = false);
 	Float4 reciprocal(RValue<Float4> x, bool pp = false, bool finite = false, bool exactAtPow2 = false);
 	Float4 reciprocalSquareRoot(RValue<Float4> x, bool abs, bool pp = false);
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 7294102..5d2b2da 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -592,7 +592,7 @@
 				case spv::StorageClassWorkgroup:
 				{
 					auto &elTy = getType(getType(typeId).element);
-					auto sizeInBytes = elTy.sizeInComponents * sizeof(float);
+					auto sizeInBytes = elTy.sizeInComponents * static_cast<uint32_t>(sizeof(float));
 					workgroupMemory.allocate(resultId, sizeInBytes);
 					object.kind = Object::Kind::Pointer;
 					break;
@@ -1379,7 +1379,7 @@
 			break;
 		case spv::OpTypeVector:
 		{
-			auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : sizeof(float);
+			auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : static_cast<int32_t>(sizeof(float));
 			for (auto i = 0u; i < type.definition.word(3); i++)
 			{
 				VisitMemoryObjectInner(type.definition.word(2), d, index, offset + elemStride * i, f);
@@ -1388,7 +1388,7 @@
 		}
 		case spv::OpTypeMatrix:
 		{
-			auto columnStride = (d.HasRowMajor && d.RowMajor) ? sizeof(float) : d.MatrixStride;
+			auto columnStride = (d.HasRowMajor && d.RowMajor) ? static_cast<int32_t>(sizeof(float)) : d.MatrixStride;
 			d.InsideMatrix = true;
 			for (auto i = 0u; i < type.definition.word(3); i++)
 			{
@@ -1594,7 +1594,7 @@
 				// TODO: b/127950082: Check bounds.
 				ASSERT(d.HasMatrixStride);
 				d.InsideMatrix = true;
-				auto columnStride = (d.HasRowMajor && d.RowMajor) ? sizeof(float) : d.MatrixStride;
+				auto columnStride = (d.HasRowMajor && d.RowMajor) ? static_cast<int32_t>(sizeof(float)) : d.MatrixStride;
 				auto & obj = getObject(indexIds[i]);
 				if (obj.kind == Object::Kind::Constant)
 				{
@@ -1609,7 +1609,7 @@
 			}
 			case spv::OpTypeVector:
 			{
-				auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : sizeof(float);
+				auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : static_cast<int32_t>(sizeof(float));
 				auto & obj = getObject(indexIds[i]);
 				if (obj.kind == Object::Kind::Constant)
 				{
@@ -1679,12 +1679,12 @@
 					ASSERT(d.DescriptorSet >= 0);
 					ASSERT(d.Binding >= 0);
 					auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
-					auto stride = setLayout->getBindingStride(d.Binding);
+					auto stride = static_cast<uint32_t>(setLayout->getBindingStride(d.Binding));
 					ptr.base += stride * GetConstScalarInt(indexIds[i]);
 				}
 				else
 				{
-					auto stride = getType(type.element).sizeInComponents * sizeof(float);
+					auto stride = getType(type.element).sizeInComponents * static_cast<uint32_t>(sizeof(float));
 					auto & obj = getObject(indexIds[i]);
 					if (obj.kind == Object::Kind::Constant)
 					{
@@ -2619,7 +2619,7 @@
 			ASSERT(objectTy.opcode() == spv::OpTypePointer);
 			auto base = &routine->getVariable(resultId)[0];
 			auto elementTy = getType(objectTy.element);
-			auto size = elementTy.sizeInComponents * sizeof(float) * SIMD::Width;
+			auto size = elementTy.sizeInComponents * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
 			routine->createPointer(resultId, SIMD::Pointer(base, size));
 			break;
 		}
@@ -2646,7 +2646,7 @@
 			ASSERT(objectTy.opcode() == spv::OpTypePointer);
 			auto base = &routine->getVariable(resultId)[0];
 			auto elementTy = getType(objectTy.element);
-			auto size = elementTy.sizeInComponents * sizeof(float) * SIMD::Width;
+			auto size = elementTy.sizeInComponents * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
 			routine->createPointer(resultId, SIMD::Pointer(base, size));
 			break;
 		}
@@ -2660,7 +2660,7 @@
 			auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
 			if (setLayout->hasBinding(d.Binding))
 			{
-				size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex);
+				uint32_t bindingOffset = static_cast<uint32_t>(setLayout->getBindingOffset(d.Binding, arrayIndex));
 				Pointer<Byte> set = routine->descriptorSets[d.DescriptorSet];  // DescriptorSet*
 				Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset);    // vk::SampledImageDescriptor*
 				auto size = 0; // Not required as this pointer is not directly used by SIMD::Read or SIMD::Write.
diff --git a/src/Vulkan/VkBufferView.hpp b/src/Vulkan/VkBufferView.hpp
index 732f600..4d67ab2 100644
--- a/src/Vulkan/VkBufferView.hpp
+++ b/src/Vulkan/VkBufferView.hpp
@@ -35,8 +35,8 @@
 	}
 
 	void *getPointer() const;
-	uint32_t getElementCount() const { return range / Format(format).bytes(); }
-	uint32_t getRangeInBytes() const { return range; }
+	uint32_t getElementCount() const { return static_cast<uint32_t>(range / Format(format).bytes()); }
+	uint32_t getRangeInBytes() const { return static_cast<uint32_t>(range); }
 	VkFormat getFormat() const { return format; }
 
 	const uint32_t id = ImageView::nextID++;	// ID space for sampling function cache, shared with imageviews
diff --git a/src/Vulkan/VkDescriptorPool.hpp b/src/Vulkan/VkDescriptorPool.hpp
index 8926467..731dd01 100644
--- a/src/Vulkan/VkDescriptorPool.hpp
+++ b/src/Vulkan/VkDescriptorPool.hpp
@@ -41,8 +41,8 @@
 		struct Node
 		{
 			Node(VkDescriptorSet set, size_t size) : set(set), size(size) {}
-			bool operator<(const Node& node) const { return this->set < node.set; }
-			bool operator==(VkDescriptorSet set) const { return this->set == set; }
+			bool operator<(const Node& node) const { return set < node.set; }
+			bool operator==(VkDescriptorSet other) const { return set == other; }
 
 			VkDescriptorSet set = VK_NULL_HANDLE;
 			size_t size = 0;
diff --git a/src/Vulkan/VkDescriptorSetLayout.cpp b/src/Vulkan/VkDescriptorSetLayout.cpp
index d6668cd..16fb5b9 100644
--- a/src/Vulkan/VkDescriptorSetLayout.cpp
+++ b/src/Vulkan/VkDescriptorSetLayout.cpp
@@ -255,17 +255,17 @@
 	return &descriptorSet->data[byteOffset];
 }
 
-void SampledImageDescriptor::updateSampler(const vk::Sampler *sampler)
+void SampledImageDescriptor::updateSampler(const vk::Sampler *newSampler)
 {
-	if(sampler)
+	if(newSampler)
 	{
-		memcpy(&this->sampler, sampler, sizeof(this->sampler));
+		memcpy(&sampler, newSampler, sizeof(sampler));
 	}
 	else
 	{
 		// Descriptor ID's start at 1, allowing to detect descriptor update
 		// bugs by checking for 0. Also avoid reading random values.
-		memset(&this->sampler, 0, sizeof(this->sampler));
+		memset(&sampler, 0, sizeof(sampler));
 	}
 }
 
@@ -315,8 +315,8 @@
 			imageSampler[i].arrayLayers = 1;
 			imageSampler[i].mipLevels = 1;
 			imageSampler[i].sampleCount = 1;
-			imageSampler[i].texture.widthWidthHeightHeight = sw::vector(numElements, numElements, 1, 1);
-			imageSampler[i].texture.width = sw::replicate(numElements);
+			imageSampler[i].texture.widthWidthHeightHeight = sw::vector(static_cast<float>(numElements), static_cast<float>(numElements), 1, 1);
+			imageSampler[i].texture.width = sw::replicate(static_cast<float>(numElements));
 			imageSampler[i].texture.height = sw::replicate(1);
 			imageSampler[i].texture.depth = sw::replicate(1);
 
@@ -448,7 +448,7 @@
 			descriptor[i].slicePitchBytes = descriptor[i].samplePitchBytes * imageView->getSampleCount();
 			descriptor[i].arrayLayers = imageView->getSubresourceRange().layerCount;
 			descriptor[i].sampleCount = imageView->getSampleCount();
-			descriptor[i].sizeInBytes = imageView->getImageSizeInBytes();
+			descriptor[i].sizeInBytes = static_cast<int>(imageView->getImageSizeInBytes());
 
 			if (imageView->getFormat().isStencil())
 			{
@@ -489,8 +489,8 @@
 			auto update = reinterpret_cast<VkDescriptorBufferInfo const *>(src + entry.offset + entry.stride * i);
 			auto buffer = Cast(update->buffer);
 			descriptor[i].ptr = buffer->getOffsetPointer(update->offset);
-			descriptor[i].sizeInBytes = (update->range == VK_WHOLE_SIZE) ? buffer->getSize() - update->offset : update->range;
-			descriptor[i].robustnessSize = buffer->getSize() - update->offset;
+			descriptor[i].sizeInBytes = static_cast<int>((update->range == VK_WHOLE_SIZE) ? buffer->getSize() - update->offset : update->range);
+			descriptor[i].robustnessSize = static_cast<int>(buffer->getSize() - update->offset);
 		}
 	}
 }
@@ -499,25 +499,25 @@
 {
 	if(level == 0)
 	{
-		texture->widthWidthHeightHeight[0] = width;
-		texture->widthWidthHeightHeight[1] = width;
-		texture->widthWidthHeightHeight[2] = height;
-		texture->widthWidthHeightHeight[3] = height;
+		texture->widthWidthHeightHeight[0] =
+		texture->widthWidthHeightHeight[1] = static_cast<float>(width);
+		texture->widthWidthHeightHeight[2] =
+		texture->widthWidthHeightHeight[3] = static_cast<float>(height);
 
-		texture->width[0] = width;
-		texture->width[1] = width;
-		texture->width[2] = width;
-		texture->width[3] = width;
+		texture->width[0] =
+		texture->width[1] =
+		texture->width[2] =
+		texture->width[3] = static_cast<float>(width);
 
-		texture->height[0] = height;
-		texture->height[1] = height;
-		texture->height[2] = height;
-		texture->height[3] = height;
+		texture->height[0] =
+		texture->height[1] =
+		texture->height[2] =
+		texture->height[3] = static_cast<float>(height);
 
-		texture->depth[0] = depth;
-		texture->depth[1] = depth;
-		texture->depth[2] = depth;
-		texture->depth[3] = depth;
+		texture->depth[0] =
+		texture->depth[1] =
+		texture->depth[2] =
+		texture->depth[3] = static_cast<float>(depth);
 	}
 
 	sw::Mipmap &mipmap = texture->mipmap[level];
@@ -526,40 +526,40 @@
 	short halfTexelV = 0x8000 / height;
 	short halfTexelW = 0x8000 / depth;
 
-	mipmap.uHalf[0] = halfTexelU;
-	mipmap.uHalf[1] = halfTexelU;
-	mipmap.uHalf[2] = halfTexelU;
+	mipmap.uHalf[0] =
+	mipmap.uHalf[1] =
+	mipmap.uHalf[2] =
 	mipmap.uHalf[3] = halfTexelU;
 
-	mipmap.vHalf[0] = halfTexelV;
-	mipmap.vHalf[1] = halfTexelV;
-	mipmap.vHalf[2] = halfTexelV;
+	mipmap.vHalf[0] =
+	mipmap.vHalf[1] =
+	mipmap.vHalf[2] =
 	mipmap.vHalf[3] = halfTexelV;
 
-	mipmap.wHalf[0] = halfTexelW;
-	mipmap.wHalf[1] = halfTexelW;
-	mipmap.wHalf[2] = halfTexelW;
+	mipmap.wHalf[0] =
+	mipmap.wHalf[1] =
+	mipmap.wHalf[2] =
 	mipmap.wHalf[3] = halfTexelW;
 
-	mipmap.width[0] = width;
-	mipmap.width[1] = width;
-	mipmap.width[2] = width;
+	mipmap.width[0] =
+	mipmap.width[1] =
+	mipmap.width[2] =
 	mipmap.width[3] = width;
 
-	mipmap.height[0] = height;
-	mipmap.height[1] = height;
-	mipmap.height[2] = height;
+	mipmap.height[0] =
+	mipmap.height[1] =
+	mipmap.height[2] =
 	mipmap.height[3] = height;
 
-	mipmap.depth[0] = depth;
-	mipmap.depth[1] = depth;
-	mipmap.depth[2] = depth;
+	mipmap.depth[0] =
+	mipmap.depth[1] =
+	mipmap.depth[2] =
 	mipmap.depth[3] = depth;
 
 	mipmap.onePitchP[0] = 1;
-	mipmap.onePitchP[1] = pitchP;
+	mipmap.onePitchP[1] = static_cast<short>(pitchP);
 	mipmap.onePitchP[2] = 1;
-	mipmap.onePitchP[3] = pitchP;
+	mipmap.onePitchP[3] = static_cast<short>(pitchP);
 
 	mipmap.pitchP[0] = pitchP;
 	mipmap.pitchP[1] = pitchP;
diff --git a/src/Vulkan/VkDescriptorSetLayout.hpp b/src/Vulkan/VkDescriptorSetLayout.hpp
index 8ebdfda..63f1211 100644
--- a/src/Vulkan/VkDescriptorSetLayout.hpp
+++ b/src/Vulkan/VkDescriptorSetLayout.hpp
@@ -29,6 +29,8 @@
 // TODO(b/129523279): Move to the Device or Pipeline layer.
 struct alignas(16) SampledImageDescriptor
 {
+	~SampledImageDescriptor() = delete;
+
 	void updateSampler(const vk::Sampler *sampler);
 
 	// TODO(b/129523279): Minimize to the data actually needed.
@@ -47,6 +49,8 @@
 
 struct alignas(16) StorageImageDescriptor
 {
+	~StorageImageDescriptor() = delete;
+
 	void *ptr;
 	VkExtent3D extent;
 	int rowPitchBytes;
@@ -64,6 +68,8 @@
 
 struct alignas(16) BufferDescriptor
 {
+	~BufferDescriptor() = delete;
+
 	void *ptr;
 	int sizeInBytes;		// intended size of the bound region -- slides along with dynamic offsets
 	int robustnessSize;		// total accessible size from static offset -- does not move with dynamic offset
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 9bdec50..bb963b3 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -289,7 +289,7 @@
 
 void PhysicalDevice::getProperties(VkPhysicalDeviceMaintenance3Properties* properties) const
 {
-	properties->maxMemoryAllocationSize = 1 << 31;
+	properties->maxMemoryAllocationSize = 1u << 31;
 	properties->maxPerSetDescriptors = 1024;
 }
 
@@ -718,7 +718,7 @@
 		break;
 	}
 
-	pImageFormatProperties->maxResourceSize = 1 << 31; // Minimum value for maxResourceSize
+	pImageFormatProperties->maxResourceSize = 1u << 31; // Minimum value for maxResourceSize
 
 	// "Images created with tiling equal to VK_IMAGE_TILING_LINEAR have further restrictions on their limits and capabilities
 	//  compared to images created with tiling equal to VK_IMAGE_TILING_OPTIMAL."
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 4d16ccd..18f5324 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -92,7 +92,7 @@
 	return sw::STREAMTYPE_BYTE;
 }
 
-uint32_t getNumberOfChannels(VkFormat format)
+unsigned char getNumberOfChannels(VkFormat format)
 {
 	switch(format)
 	{