Add a safety barrier between buffer fills and copies

* It's unclear if this should be required as the fills and copies don't overlap,
  but this is not so perf sensitive that a barrier can't be added for safety.
This commit is contained in:
baldurk
2022-11-23 17:42:14 +00:00
parent c144757d11
commit 839e9f609f
+17
View File
@@ -2137,8 +2137,25 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten
RDCDEBUG("Apply_InitialState (Mem %s): %d fills, %d copies", ToStr(orig).c_str(), fillCount,
regions.size());
if(regions.size() > 0)
{
VkBufferMemoryBarrier bufBarrier = {
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
NULL,
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_ACCESS_TRANSFER_WRITE_BIT,
VK_QUEUE_FAMILY_IGNORED,
VK_QUEUE_FAMILY_IGNORED,
Unwrap(dstBuf),
0,
VK_WHOLE_SIZE,
};
// be conservative about whether or not the above fills overlap with the below copies
DoPipelineBarrier(cmd, 1, &bufBarrier);
ObjDisp(cmd)->CmdCopyBuffer(Unwrap(cmd), Unwrap(srcBuf), Unwrap(dstBuf),
(uint32_t)regions.size(), regions.data());
}
VkMarkerRegion::End(cmd);