Commit fb6639fb by Alexis Hetu Committed by Alexis Hétu

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/+/27872Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent c0cf68ba
...@@ -93,9 +93,18 @@ void Buffer::copyTo(Buffer* dstBuffer, const VkBufferCopy& pRegion) const ...@@ -93,9 +93,18 @@ void Buffer::copyTo(Buffer* dstBuffer, const VkBufferCopy& pRegion) const
void Buffer::fill(VkDeviceSize dstOffset, VkDeviceSize fillSize, uint32_t data) 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) void Buffer::update(VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData)
......
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