Don't include alignment padding in returned alloc size. Closes #1625

* If we include the padding we might try to over-allocate the initial contents
  and copy/fill beyond the valid size for the actual memory allocation.
This commit is contained in:
baldurk committed 2019-12-02 20:41:28 +00:00
1 parent cfe601123c
commit 5ba3026f68
1 file changed
+6 -3
+6 -3
View File
@@ -189,9 +189,9 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(bool buffer, VkMemoryR
// invalidate/flush safely. This is at most 256 bytes which is likely already satisfied.
ret.size = AlignUp(ret.size, nonCoherentAtomSize);
RDCDEBUG("Allocating 0x%llx with alignment 0x%llx in 0x%x for a %s (%s in %s)", ret.size,
mrq.alignment, mrq.memoryTypeBits, buffer ? "buffer" : "image", ToStr(type).c_str(),
ToStr(scope).c_str());
RDCDEBUG("Allocating 0x%llx (0x%llx requested) with alignment 0x%llx in 0x%x for a %s (%s in %s)",
ret.size, mrq.size, mrq.alignment, mrq.memoryTypeBits, buffer ? "buffer" : "image",
ToStr(type).c_str(), ToStr(scope).c_str());
std::vector<MemoryAllocation> &blockList = m_MemoryBlocks[(size_t)scope];
@@ -333,6 +333,9 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(bool buffer, VkMemoryR
ret.mem = chunk.mem;
}
// ensure the returned size is accurate to what was requested, not what we padded
ret.size = mrq.size;
return ret;
}