mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-10 09:37:08 +00:00
Don't allocate wholeMemBuf buffer for memory that doesn't allow buffers
* Some memory types may not be compatible with buffers, so allocations in those memory type indices we just don't create a spanning buffer, as it won't be needed anyway to restore memory contents.
This commit is contained in:
@@ -1491,7 +1491,10 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, VkInitialContents ini
|
||||
|
||||
VkBufferCopy region = {0, dstMemOffs, datasize};
|
||||
|
||||
ObjDisp(cmd)->CmdCopyBuffer(Unwrap(cmd), Unwrap(srcBuf), Unwrap(dstBuf), 1, ®ion);
|
||||
if(dstBuf != VK_NULL_HANDLE)
|
||||
ObjDisp(cmd)->CmdCopyBuffer(Unwrap(cmd), Unwrap(srcBuf), Unwrap(dstBuf), 1, ®ion);
|
||||
else
|
||||
RDCERR("Whole memory buffer not present for %llu", id);
|
||||
|
||||
vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd));
|
||||
RDCASSERTEQUAL(vkr, VK_SUCCESS);
|
||||
|
||||
@@ -712,14 +712,19 @@ bool WrappedVulkan::Apply_SparseInitialState(WrappedVkBuffer *buf, VkInitialCont
|
||||
VkDeviceMemory dstMem =
|
||||
GetResourceManager()->GetLiveHandle<VkDeviceMemory>(info.memDataOffs[i].memory);
|
||||
|
||||
VkBuffer dstBuf = m_CreationInfo.m_Memory[GetResID(dstMem)].wholeMemBuf;
|
||||
ResourceId id = GetResID(dstMem);
|
||||
|
||||
VkDeviceSize size = m_CreationInfo.m_Memory[GetResID(dstMem)].size;
|
||||
VkBuffer dstBuf = m_CreationInfo.m_Memory[id].wholeMemBuf;
|
||||
|
||||
VkDeviceSize size = m_CreationInfo.m_Memory[id].size;
|
||||
|
||||
// fill the whole memory from the given offset
|
||||
VkBufferCopy region = {info.memDataOffs[i].memOffs, 0, size};
|
||||
|
||||
ObjDisp(cmd)->CmdCopyBuffer(Unwrap(cmd), Unwrap(srcBuf), Unwrap(dstBuf), 1, ®ion);
|
||||
if(dstBuf != VK_NULL_HANDLE)
|
||||
ObjDisp(cmd)->CmdCopyBuffer(Unwrap(cmd), Unwrap(srcBuf), Unwrap(dstBuf), 1, ®ion);
|
||||
else
|
||||
RDCERR("Whole memory buffer not present for %llu", id);
|
||||
}
|
||||
|
||||
vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd));
|
||||
@@ -843,15 +848,20 @@ bool WrappedVulkan::Apply_SparseInitialState(WrappedVkImage *im, VkInitialConten
|
||||
VkDeviceMemory dstMem =
|
||||
GetResourceManager()->GetLiveHandle<VkDeviceMemory>(info.memDataOffs[i].memory);
|
||||
|
||||
ResourceId id = GetResID(dstMem);
|
||||
|
||||
// since this is short lived it isn't wrapped. Note that we want
|
||||
// to cache this up front, so it will then be wrapped
|
||||
VkBuffer dstBuf = m_CreationInfo.m_Memory[GetResID(dstMem)].wholeMemBuf;
|
||||
VkDeviceSize size = m_CreationInfo.m_Memory[GetResID(dstMem)].size;
|
||||
VkBuffer dstBuf = m_CreationInfo.m_Memory[id].wholeMemBuf;
|
||||
VkDeviceSize size = m_CreationInfo.m_Memory[id].size;
|
||||
|
||||
// fill the whole memory from the given offset
|
||||
VkBufferCopy region = {info.memDataOffs[i].memOffs, 0, size};
|
||||
|
||||
ObjDisp(cmd)->CmdCopyBuffer(Unwrap(cmd), Unwrap(srcBuf), Unwrap(dstBuf), 1, ®ion);
|
||||
if(dstBuf != VK_NULL_HANDLE)
|
||||
ObjDisp(cmd)->CmdCopyBuffer(Unwrap(cmd), Unwrap(srcBuf), Unwrap(dstBuf), 1, ®ion);
|
||||
else
|
||||
RDCERR("Whole memory buffer not present for %llu", id);
|
||||
}
|
||||
|
||||
vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd));
|
||||
|
||||
@@ -197,16 +197,28 @@ bool WrappedVulkan::Serialise_vkAllocateMemory(SerialiserType &ser, VkDevice dev
|
||||
VkMemoryRequirements mrq = {};
|
||||
ObjDisp(device)->GetBufferMemoryRequirements(Unwrap(device), buf, &mrq);
|
||||
|
||||
RDCASSERT(mrq.size <= AllocateInfo.allocationSize, mrq.size, AllocateInfo.allocationSize);
|
||||
// check that this allocation type can actually be bound to a buffer. Allocations that can't
|
||||
// be used with buffers we can just skip and leave wholeMemBuf as NULL.
|
||||
if((1 << AllocateInfo.memoryTypeIndex) & mrq.memoryTypeBits)
|
||||
{
|
||||
RDCASSERT(mrq.size <= AllocateInfo.allocationSize, mrq.size, AllocateInfo.allocationSize);
|
||||
|
||||
ResourceId bufid = GetResourceManager()->WrapResource(Unwrap(device), buf);
|
||||
ResourceId bufid = GetResourceManager()->WrapResource(Unwrap(device), buf);
|
||||
|
||||
ObjDisp(device)->BindBufferMemory(Unwrap(device), Unwrap(buf), Unwrap(mem), 0);
|
||||
ObjDisp(device)->BindBufferMemory(Unwrap(device), Unwrap(buf), Unwrap(mem), 0);
|
||||
|
||||
// register as a live-only resource, so it is cleaned up properly
|
||||
GetResourceManager()->AddLiveResource(bufid, buf);
|
||||
// register as a live-only resource, so it is cleaned up properly
|
||||
GetResourceManager()->AddLiveResource(bufid, buf);
|
||||
|
||||
m_CreationInfo.m_Memory[live].wholeMemBuf = buf;
|
||||
m_CreationInfo.m_Memory[live].wholeMemBuf = buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCWARN("Can't create buffer covering memory allocation %llu", Memory);
|
||||
ObjDisp(device)->DestroyBuffer(Unwrap(device), buf, NULL);
|
||||
|
||||
m_CreationInfo.m_Memory[live].wholeMemBuf = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
AddResource(Memory, ResourceType::Memory, "Memory");
|
||||
|
||||
Reference in New Issue
Block a user