Fix alignment for mapped memory when loading initial contents

Change-Id: If40878b6b7a190237c3686463c7358bb033c8b06
This commit is contained in:
Benson Joeris
2020-01-16 23:05:31 +00:00
committed by Baldur Karlsson
parent 84fd1858ca
commit f12ae2d9fa
+5 -3
View File
@@ -904,6 +904,8 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id,
// Serialise this separately so that it can be used on reading to prepare the upload memory
SERIALISE_ELEMENT(ContentsSize);
const VkDeviceSize nonCoherentAtomSize = GetDeviceProps().limits.nonCoherentAtomSize;
// the memory/buffer that we allocated on read, to upload the initial contents.
MemoryAllocation uploadMemory;
VkBuffer uploadBuf = VK_NULL_HANDLE;
@@ -953,8 +955,8 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id,
mappedMem = uploadMemory;
ObjDisp(d)->MapMemory(Unwrap(d), Unwrap(mappedMem.mem), mappedMem.offs, mappedMem.size, 0,
(void **)&Contents);
ObjDisp(d)->MapMemory(Unwrap(d), Unwrap(mappedMem.mem), mappedMem.offs,
AlignUp(mappedMem.size, nonCoherentAtomSize), 0, (void **)&Contents);
}
// not using SERIALISE_ELEMENT_ARRAY so we can deliberately avoid allocation - we serialise
@@ -972,7 +974,7 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id,
NULL,
Unwrap(mappedMem.mem),
mappedMem.offs,
mappedMem.size,
AlignUp(mappedMem.size, nonCoherentAtomSize),
};
vkr = ObjDisp(d)->FlushMappedMemoryRanges(Unwrap(d), 1, &range);