Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add acceleration structure overrides #1759

Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
438a11f
Add code-overrides around acceleration-structures
fabian-lunarg Sep 11, 2024
9c62a26
Add struct-definition for AccelerationStructureInfoKHR
fabian-lunarg Sep 16, 2024
f629228
Add acceleration-structure support to BufferTracker
fabian-lunarg Sep 16, 2024
7eddd19
Rename buffer_tracker -> device_address_tracker
fabian-lunarg Sep 16, 2024
e1be39e
Implement address-remap in OverrideCmdBuildAccelerationStructuresKHR
fabian-lunarg Sep 16, 2024
d3122f4
in-place sbt-address remap
fabian-lunarg Sep 18, 2024
9d85b56
Add device-address tracking in vulkan_state_writer
fabian-lunarg Sep 18, 2024
97001ea
differentiate device-address/opaque-capture-address in capture
fabian-lunarg Sep 19, 2024
193681e
Support VkBufferUsageFlags2CreateInfoKHR in OverrideCreateBuffer
fabian-lunarg Sep 19, 2024
c13f927
cleanup, fuse two buffer-methods in state-writer
fabian-lunarg Sep 24, 2024
5ea9c0e
Add code-overrides around acceleration-structures
fabian-lunarg Sep 11, 2024
f262f40
Add struct-definition for AccelerationStructureInfoKHR
fabian-lunarg Sep 16, 2024
b334358
Add acceleration-structure support to BufferTracker
fabian-lunarg Sep 16, 2024
7ae8c0f
Rename buffer_tracker -> device_address_tracker
fabian-lunarg Sep 16, 2024
e4cce18
Implement address-remap in OverrideCmdBuildAccelerationStructuresKHR
fabian-lunarg Sep 16, 2024
73c6ff1
in-place sbt-address remap
fabian-lunarg Sep 18, 2024
4ed4a92
Merge branch 'state_writer_tmp' into fabian_add_acceleration_structur…
fabian-lunarg Sep 24, 2024
aeeb5da
Merge remote-tracking branch 'upstream/dev' into fabian_add_accelerat…
fabian-lunarg Sep 24, 2024
37655f6
refactor/clean comments
fabian-lunarg Sep 25, 2024
0182254
formatting
fabian-lunarg Sep 25, 2024
6de3c32
work on device-address tracking / trimming
fabian-lunarg Sep 26, 2024
179922d
Track RayTracingPipelineProperties
fabian-lunarg Sep 26, 2024
59a144a
Write raytracing-pipeline properties
fabian-lunarg Sep 26, 2024
82e7b14
Check instance-version, use proper vkGetBufferDeviceAddress/KHR
fabian-lunarg Sep 27, 2024
335ebc8
remove a too optimistic assert, formatting
fabian-lunarg Sep 30, 2024
d1477c9
missing clang-format
fabian-lunarg Sep 30, 2024
66c06c2
Merge remote-tracking branch 'upstream/dev' into fabian_add_accelerat…
fabian-lunarg Oct 1, 2024
df82f37
Add error for an unhandled switch-case
fabian-lunarg Oct 1, 2024
638d3d1
Clarify a workaround, leave related issue-#
fabian-lunarg Oct 1, 2024
0daf9ee
correct trimming for vkGetBufferDeviceAddress(KHR)
fabian-lunarg Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 62 additions & 21 deletions framework/decode/vulkan_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ static uint32_t GetHardwareBufferFormatBpp(uint32_t format)

VulkanReplayConsumerBase::VulkanReplayConsumerBase(std::shared_ptr<application::Application> application,
const VulkanReplayOptions& options) :
resource_dumper(options, object_info_table_), loader_handle_(nullptr), get_instance_proc_addr_(nullptr),
create_instance_proc_(nullptr), application_(application), options_(options), loading_trim_state_(false),
replaying_trimmed_capture_(false), have_imported_semaphores_(false), fps_info_(nullptr),
omitted_pipeline_cache_data_(false)
resource_dumper(options, object_info_table_),
loader_handle_(nullptr), get_instance_proc_addr_(nullptr), create_instance_proc_(nullptr),
application_(application), options_(options), loading_trim_state_(false), replaying_trimmed_capture_(false),
have_imported_semaphores_(false), fps_info_(nullptr), omitted_pipeline_cache_data_(false)
{
assert(application_ != nullptr);
assert(options.create_resource_allocator != nullptr);
Expand Down Expand Up @@ -4230,9 +4230,9 @@ VkResult VulkanReplayConsumerBase::OverrideAllocateMemory(

VkMemoryAllocateInfo modified_allocate_info = (*replay_allocate_info);
VkMemoryOpaqueCaptureAddressAllocateInfo address_info = {
VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO,
modified_allocate_info.pNext,
opaque_address
VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO,
modified_allocate_info.pNext,
opaque_address
};
modified_allocate_info.pNext = &address_info;

Expand Down Expand Up @@ -7556,22 +7556,63 @@ void VulkanReplayConsumerBase::OverrideCmdBuildAccelerationStructuresKHR(
StructPointerDecoder<Decoded_VkAccelerationStructureBuildGeometryInfoKHR>* pInfos,
StructPointerDecoder<Decoded_VkAccelerationStructureBuildRangeInfoKHR*>* ppBuildRangeInfos)
{
DeviceInfo* device_info = object_info_table_.GetDeviceInfo(command_buffer_info->parent_id);
if (device_info->allocator->SupportsOpaqueDeviceAddresses())
{
VkCommandBuffer command_buffer = command_buffer_info->handle;
VkAccelerationStructureBuildGeometryInfoKHR* infos = pInfos->GetPointer();
VkAccelerationStructureBuildRangeInfoKHR** build_range_infos = ppBuildRangeInfos->GetPointer();
func(command_buffer, infoCount, infos, build_range_infos);
return;
}
// Use the builder when the rebind allocator is selected and the trimming is done / not used
else if (!loading_trim_state_)
DeviceInfo* device_info = object_info_table_.GetDeviceInfo(command_buffer_info->parent_id);
VkCommandBuffer command_buffer = command_buffer_info->handle;
VkAccelerationStructureBuildGeometryInfoKHR* build_geometry_infos = pInfos->GetPointer();
VkAccelerationStructureBuildRangeInfoKHR** build_range_infos = ppBuildRangeInfos->GetPointer();

auto& address_tracker = GetDeviceAddressTracker(device_info->handle);

auto address_remap = [&address_tracker](const VkDeviceAddress& capture_address) {
auto buffer_info = address_tracker.GetBufferByCaptureDeviceAddress(capture_address);
GFXRECON_ASSERT(buffer_info != nullptr);

uint64_t offset = capture_address - buffer_info->capture_address;

// in-place address-remap via const-cast
auto& dst = *const_cast<VkDeviceAddress*>(&capture_address);
dst = buffer_info->replay_address + offset;
};

for (uint32_t i = 0; i < infoCount; ++i)
{
GFXRECON_ASSERT(false);
// acceleration_structure_builders_[command_buffer_info->parent_id]->CmdBuildAccelerationStructures(
// command_buffer_info->handle, infoCount, pInfos->GetPointer(), ppBuildRangeInfos->GetPointer());
const auto& build_geometry_info = build_geometry_infos[i];

for (uint32_t j = 0; j < build_geometry_info.geometryCount; ++j)
{
const VkAccelerationStructureGeometryKHR* geometry = build_geometry_info.pGeometries != nullptr
? build_geometry_info.pGeometries + j
: build_geometry_info.ppGeometries[j];

switch (geometry->geometryType)
{
case VK_GEOMETRY_TYPE_TRIANGLES_KHR:
{
const auto& triangles = geometry->geometry.triangles;
address_remap(triangles.vertexData.deviceAddress);
address_remap(triangles.indexData.deviceAddress);
break;
}
case VK_GEOMETRY_TYPE_AABBS_KHR:
{
const auto& aabbs = geometry->geometry.aabbs;
address_remap(aabbs.data.deviceAddress);
break;
}
case VK_GEOMETRY_TYPE_INSTANCES_KHR:
{
const auto& instances = geometry->geometry.instances;
// TODO: inside buffer:
// replace all VkAccelerationStructureInstanceKHR::accelerationStructureReference
address_remap(instances.data.deviceAddress);
break;
}
default:
break;
MarkY-LunarG marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
func(command_buffer, infoCount, build_geometry_infos, build_range_infos);
}

void VulkanReplayConsumerBase::OverrideCmdCopyAccelerationStructureKHR(
Expand Down