Descriptor buffers must force on BDA for all memory

* This is required for any images that will be bound to the memory
This commit is contained in:
baldurk
2025-07-30 22:10:23 +01:00
parent efd60e5751
commit 2eb028f31a
3 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -395,7 +395,7 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(bool buffer, VkMemoryR
};
VkMemoryAllocateInfo info = {
VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
AccelerationStructures() ? &flagsInfo : NULL,
(DescriptorBuffers() || AccelerationStructures()) ? &flagsInfo : NULL,
allocSize * 1024 * 1024,
memoryTypeIndex,
};
@@ -4716,6 +4716,9 @@ VkResult WrappedVulkan::vkCreateDevice(VkPhysicalDevice physicalDevice,
if(descBufFeatures && descBufFeatures->descriptorBuffer)
{
descBufFeatures->descriptorBufferCaptureReplay = VK_TRUE;
m_DescriptorBuffers = true;
RDCLOG("descriptor buffers enabled, ALL MEMORY WILL BE MARKED AS BDA");
}
VkResult ret;
@@ -4923,8 +4926,6 @@ VkResult WrappedVulkan::vkCreateDevice(VkPhysicalDevice physicalDevice,
if(m_EnabledExtensions.ext_EXT_descriptor_buffer && descBufFeatures &&
descBufFeatures->descriptorBuffer)
{
m_DescriptorBuffers = true;
// if any update after bind feature is enabled, check robustBufferAccessUpdateAfterBind
m_DescriptorBufferProperties = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_PROPERTIES_EXT,
@@ -320,14 +320,15 @@ bool WrappedVulkan::Serialise_vkAllocateMemory(SerialiserType &ser, VkDevice dev
{
RDCDEBUG("Patching dedicated allocation for incompatible size");
// if acceleration structures are used, we promote all non-dedicated memory to be BDA as
// we can't know if it will be used for an AS or not during capture. That means that
// during self-capture if we just remove the dedicated allocation structure here without
// any other changes the self-capture layer will promote it to BDA and potentially cause
// clashes with reserved addresses elsewhere.
// if acceleration structures or descriptor buffers are used, we promote all non-dedicated
// memory to be BDA as we can't know if it will be used for an AS or not during capture.
// That means that during self-capture if we just remove the dedicated allocation
// structure here without any other changes the self-capture layer will promote it to BDA
// and potentially cause clashes with reserved addresses elsewhere.
//
// instead we do the more dangerous thing of adjusting the allocation size to match the
// image's memory requirements and keep the dedicated allocation.
if(AccelerationStructures())
if(AccelerationStructures() || DescriptorBuffers())
patched.allocationSize = mrq.size;
else
RemoveNextStruct(&patched, VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO);
@@ -562,7 +563,7 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate
// means that when RT is enabled ALL MEMORY IN THE ENTIRE PROGRAM must be marked as BDA just in
// case.
bool forceBDA = false;
if(IsCaptureMode(m_State) && AccelerationStructures())
if(IsCaptureMode(m_State) && (AccelerationStructures() || DescriptorBuffers()))
{
// force BDA flag when creating, by adding the struct if needed
forceBDA = true;