radv: Support accelerationStructureCaptureReplay.

The address itself was already stable assuming that the memory itself was
allocated with capture/replay. Enable the feature flag and add an equality
check to return VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR on mismatch.

Tested with:
- dEQP-VK.ray_tracing_pipeline.capture_replay.*
- q2rtx gfxrecon replays correctly without major errors.
  * There are debug logs about VkBuffers missing opaque address
  for unknown reason, however the AS part is confirmed to be correctly
  captured.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19841>
This commit is contained in:
Tatsuyuki Ishi 2022-11-18 15:59:50 +09:00 committed by Marge Bot
parent 165ef452fd
commit 390c4b337a
2 changed files with 9 additions and 3 deletions

View File

@ -233,6 +233,12 @@ radv_CreateAccelerationStructureKHR(VkDevice _device,
RADV_FROM_HANDLE(radv_device, device, _device);
RADV_FROM_HANDLE(radv_buffer, buffer, pCreateInfo->buffer);
struct radv_acceleration_structure *accel;
uint64_t mem_offset, va;
mem_offset = buffer->offset + pCreateInfo->offset;
va = radv_buffer_get_va(buffer->bo) + mem_offset;
if (pCreateInfo->deviceAddress && va != pCreateInfo->deviceAddress)
return vk_error(device, VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR);
accel = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*accel), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@ -241,10 +247,10 @@ radv_CreateAccelerationStructureKHR(VkDevice _device,
vk_object_base_init(&device->vk, &accel->base, VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR);
accel->mem_offset = buffer->offset + pCreateInfo->offset;
accel->mem_offset = mem_offset;
accel->size = pCreateInfo->size;
accel->bo = buffer->bo;
accel->va = radv_buffer_get_va(accel->bo) + accel->mem_offset;
accel->va = va;
accel->type = pCreateInfo->type;
*pAccelerationStructure = radv_acceleration_structure_to_handle(accel);

View File

@ -1699,7 +1699,7 @@ radv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceAccelerationStructureFeaturesKHR *features =
(VkPhysicalDeviceAccelerationStructureFeaturesKHR *)ext;
features->accelerationStructure = true;
features->accelerationStructureCaptureReplay = false;
features->accelerationStructureCaptureReplay = true;
features->accelerationStructureIndirectBuild = false;
features->accelerationStructureHostCommands = false;
features->descriptorBindingAccelerationStructureUpdateAfterBind = true;