mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-08 16:50:44 +00:00
Improved handling for sparse buffers
Change-Id: I12d74140f8b3df862a15d6966431862c145612d8
This commit is contained in:
committed by
Baldur Karlsson
parent
38a61a2ec6
commit
1ce89dfc62
@@ -42,10 +42,19 @@ GPUAddressRange WrappedVulkan::CreateAddressRange(VkDevice device, VkBuffer buff
|
||||
VkResourceRecord *record = GetRecord(buffer);
|
||||
VkResourceRecord *memrecord = GetResourceManager()->GetResourceRecord(record->baseResourceMem);
|
||||
|
||||
// Just in case this is called when a buffer is being destroyed without being bound
|
||||
if(!memrecord)
|
||||
const bool isSparse = record->resInfo && record->resInfo->IsSparse();
|
||||
|
||||
// If the buffer is not sparse and there's no baseResourceMem, then the buffer is being destroyed
|
||||
// without being bound so exit early as there's nothing to do
|
||||
if(!isSparse && !memrecord)
|
||||
return {};
|
||||
|
||||
// Sparse buffers may not have a single device allocation so set the OOB size to the same as the
|
||||
// buffer
|
||||
VkDeviceSize oobSize = record->memSize;
|
||||
if(!isSparse && memrecord)
|
||||
oobSize = memrecord->memSize - record->memOffset;
|
||||
|
||||
const VkBufferDeviceAddressInfo addrInfo = {
|
||||
VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
|
||||
NULL,
|
||||
@@ -58,7 +67,7 @@ GPUAddressRange WrappedVulkan::CreateAddressRange(VkDevice device, VkBuffer buff
|
||||
return {
|
||||
address,
|
||||
address + record->memSize,
|
||||
address + (memrecord->memSize - record->memOffset),
|
||||
address + oobSize,
|
||||
record->GetResourceID(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1912,11 +1912,17 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo
|
||||
ObjDisp(device)->GetBufferMemoryRequirements(Unwrap(device), Unwrap(*pBuffer),
|
||||
&record->resInfo->memreqs);
|
||||
|
||||
// initialise the sparse page table
|
||||
if(isSparse)
|
||||
{
|
||||
// initialise the sparse page table
|
||||
record->resInfo->sparseTable.Initialise(pCreateInfo->size,
|
||||
record->resInfo->memreqs.alignment & 0xFFFFFFFFU);
|
||||
|
||||
// Track the buffer address. We only do this here for sparse buffers as they aren't
|
||||
// bound against a single allocation
|
||||
TrackBufferAddress(device, *pBuffer);
|
||||
}
|
||||
|
||||
// for external buffers, try creating a non-external version and take the worst case of
|
||||
// memory requirements, in case the non-external one (as we will replay it) needs more
|
||||
// memory or a stricter alignment
|
||||
|
||||
Reference in New Issue
Block a user