Skip to content

Commit

Permalink
Add buffer-tracking logic to OverrideBindBufferMemory
Browse files Browse the repository at this point in the history
- trimming: covers case when no vkGetBufferDeviceAddress was captured
  • Loading branch information
fabian-lunarg committed Sep 5, 2024
1 parent a5dabec commit c5b7479
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions framework/decode/vulkan_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4476,6 +4476,28 @@ VkResult VulkanReplayConsumerBase::OverrideBindBufferMemory(PFN_vkBindBufferMemo
buffer_info->handle, buffer_info->allocator_data, memory_info->allocator_data);
}

if (result == VK_SUCCESS && !allocator->SupportsOpaqueDeviceAddresses())
{
// On fast-forwarded traces buffer device addresses might be missing (no GetBufferDeviceAddress calls)
// Fill out this data based on original memory device address and binding offset
auto entry = device_info->opaque_addresses.find(memory_info->capture_id);
if (entry != device_info->opaque_addresses.end())
{
uint64_t memory_device_address = entry->second;
uint64_t original_buffer_address = memory_device_address + memoryOffset;
VkBufferDeviceAddressInfo info = {};
info.sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO;
info.pNext = nullptr;
info.buffer = buffer_info->handle;

buffer_info->capture_address = original_buffer_address;
buffer_info->replay_address =
GetDeviceTable(device_info->handle)->GetBufferDeviceAddress(device_info->handle, &info);

// track buffer-addresses
GetBufferTracker(device_info->handle).TrackBuffer(buffer_info);
}
}
return result;
}

Expand Down Expand Up @@ -7811,7 +7833,7 @@ VkDeviceAddress VulkanReplayConsumerBase::OverrideGetBufferDeviceAddress(
buffer_info->capture_address = original_result;
buffer_info->replay_address = replay_device_address;

// pass info to buffer-tracker
// track device-addresses
GetBufferTracker(device).TrackBuffer(buffer_info);

// Fabian tmp
Expand Down Expand Up @@ -8184,12 +8206,14 @@ void VulkanReplayConsumerBase::OverrideCmdTraceRaysKHR(
const VkStridedDeviceAddressRegionKHR* in_pCallableShaderBindingTable =
pCallableShaderBindingTable->GetPointer();

// Fabian tmp
// assert we can identify the buffer(s) by their device-address
const DeviceInfo* device_info = GetObjectInfoTable().GetDeviceInfo(command_buffer_info->parent_id);
const auto& buffer_tracker = GetBufferTracker(device_info->handle);
GFXRECON_ASSERT(buffer_tracker.GetBufferByCaptureDeviceAddress(in_pRaygenShaderBindingTable->deviceAddress));
GFXRECON_ASSERT(buffer_tracker.GetBufferByCaptureDeviceAddress(in_pMissShaderBindingTable->deviceAddress));
GFXRECON_ASSERT(buffer_tracker.GetBufferByCaptureDeviceAddress(in_pHitShaderBindingTable->deviceAddress));
GFXRECON_ASSERT(in_pMissShaderBindingTable->size == 0 ||
buffer_tracker.GetBufferByCaptureDeviceAddress(in_pMissShaderBindingTable->deviceAddress));
GFXRECON_ASSERT(in_pHitShaderBindingTable->size == 0 ||
buffer_tracker.GetBufferByCaptureDeviceAddress(in_pHitShaderBindingTable->deviceAddress));
GFXRECON_ASSERT(in_pCallableShaderBindingTable->size == 0 ||
buffer_tracker.GetBufferByCaptureDeviceAddress(in_pCallableShaderBindingTable->deviceAddress));

Expand All @@ -8203,6 +8227,7 @@ void VulkanReplayConsumerBase::OverrideCmdTraceRaysKHR(
physical_device_info->shaderGroupHandleAlignment != replay_props.shaderGroupHandleAlignment ||
physical_device_info->shaderGroupBaseAlignment != replay_props.shaderGroupBaseAlignment)
{
// TODO: move forward with address-remapping and re-assembly of a binding-table
GFXRECON_LOG_WARNING_ONCE("capture/replay have mismatching shader-binding-table size or alignments");
}
}
Expand Down

0 comments on commit c5b7479

Please sign in to comment.