Skip to content

Commit 5ba3026

Browse files
committed
Don't include alignment padding in returned alloc size. Closes baldurk#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.
1 parent cfe6011 commit 5ba3026

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

renderdoc/driver/vulkan/vk_memory.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(bool buffer, VkMemoryR
189189
// invalidate/flush safely. This is at most 256 bytes which is likely already satisfied.
190190
ret.size = AlignUp(ret.size, nonCoherentAtomSize);
191191

192-
RDCDEBUG("Allocating 0x%llx with alignment 0x%llx in 0x%x for a %s (%s in %s)", ret.size,
193-
mrq.alignment, mrq.memoryTypeBits, buffer ? "buffer" : "image", ToStr(type).c_str(),
194-
ToStr(scope).c_str());
192+
RDCDEBUG("Allocating 0x%llx (0x%llx requested) with alignment 0x%llx in 0x%x for a %s (%s in %s)",
193+
ret.size, mrq.size, mrq.alignment, mrq.memoryTypeBits, buffer ? "buffer" : "image",
194+
ToStr(type).c_str(), ToStr(scope).c_str());
195195

196196
std::vector<MemoryAllocation> &blockList = m_MemoryBlocks[(size_t)scope];
197197

@@ -333,6 +333,9 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(bool buffer, VkMemoryR
333333
ret.mem = chunk.mem;
334334
}
335335

336+
// ensure the returned size is accurate to what was requested, not what we padded
337+
ret.size = mrq.size;
338+
336339
return ret;
337340
}
338341

0 commit comments

Comments
 (0)