Fill buffer fix

memset was erroneously being used to copy 4 bytes at a time,
but the integer input value in memset is used as an 8 bit value,
so the fill was failing if the 4 bytes were not identical.

Tests: dEQP-VK.api.fill_and_update_buffer.*
Tests: dEQP-VK.memory.pipeline_barrier.host_read_transfer_dst.*

Bug b/118383648

Change-Id: I29cb5915ebd3773b4afbd89850c47a042fff6952
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27872
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/VkBuffer.cpp b/src/Vulkan/VkBuffer.cpp
index 7f21ce4..7679553 100644
--- a/src/Vulkan/VkBuffer.cpp
+++ b/src/Vulkan/VkBuffer.cpp
@@ -93,9 +93,18 @@
 
 void Buffer::fill(VkDeviceSize dstOffset, VkDeviceSize fillSize, uint32_t data)
 {
-	ASSERT((fillSize + dstOffset) <= size);
+	size_t bytes = (fillSize == VK_WHOLE_SIZE) ? (size - dstOffset) : fillSize;
 
-	memset(getOffsetPointer(dstOffset), data, fillSize);
+	ASSERT((bytes + dstOffset) <= size);
+
+	uint32_t* memToWrite = static_cast<uint32_t*>(getOffsetPointer(dstOffset));
+
+	// Vulkan 1.1 spec: "If VK_WHOLE_SIZE is used and the remaining size of the buffer is
+	//                   not a multiple of 4, then the nearest smaller multiple is used."
+	for(; bytes >= 4; bytes -= 4, memToWrite++)
+	{
+		*memToWrite = data;
+	}
 }
 
 void Buffer::update(VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData)