Skip to content

Commit

Permalink
Portable Acceleration Structures (LunarG#1955)
Browse files Browse the repository at this point in the history
- worked mostly on decode::VulkanAddressReplacer
- enables portable replay of raytracing pipelines, when using RebindAllocator (-m rebind).
- work on Acceleration Structures (AS):
-> tracking, meta-commands, copies, query-pool handling and rebuild
-> rebuild AS from original input-buffers when trimming.
-> check AS- and scratch-buffer sizes, replace resources with shadow objects where required
  • Loading branch information
fabian-lunarg authored and bradgrantham-lunarg committed Jan 24, 2025
1 parent acc5f4d commit 58c9a6d
Show file tree
Hide file tree
Showing 31 changed files with 2,005 additions and 1,276 deletions.
1 change: 1 addition & 0 deletions android/framework/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ add_library(gfxrecon_util STATIC "")

target_sources(gfxrecon_util
PRIVATE
${GFXRECON_SOURCE_DIR}/framework/util/alignment_utils.h
${GFXRECON_SOURCE_DIR}/framework/util/argument_parser.h
${GFXRECON_SOURCE_DIR}/framework/util/argument_parser.cpp
${GFXRECON_SOURCE_DIR}/framework/util/buffer_writer.h
Expand Down
3 changes: 1 addition & 2 deletions framework/decode/metadata_consumer_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class MetadataConsumerBase
format::HandleId device_id,
uint32_t info_count,
StructPointerDecoder<Decoded_VkAccelerationStructureBuildGeometryInfoKHR>* geometry_infos,
StructPointerDecoder<Decoded_VkAccelerationStructureBuildRangeInfoKHR*>* range_infos,
std::vector<std::vector<VkAccelerationStructureInstanceKHR>>& instance_buffers_data)
StructPointerDecoder<Decoded_VkAccelerationStructureBuildRangeInfoKHR*>* range_infos)
{}

virtual void ProcessCopyVulkanAccelerationStructuresMetaCommand(
Expand Down
36 changes: 8 additions & 28 deletions framework/decode/screenshot_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,25 +539,6 @@ VkDeviceSize ScreenshotHandler::GetCopyBufferSize(VkDevice
return memory_requirements.size;
}

uint32_t ScreenshotHandler::GetMemoryTypeIndex(const VkPhysicalDeviceMemoryProperties& memory_properties,
uint32_t type_bits,
VkMemoryPropertyFlags property_flags) const
{
uint32_t memory_type_index = std::numeric_limits<uint32_t>::max();

for (uint32_t i = 0; i < memory_properties.memoryTypeCount; ++i)
{
if ((type_bits & (1 << i)) &&
((memory_properties.memoryTypes[i].propertyFlags & property_flags) == property_flags))
{
memory_type_index = i;
break;
}
}

return memory_type_index;
}

VkResult ScreenshotHandler::CreateCopyResource(VkDevice device,
const encode::VulkanDeviceTable* device_table,
const VkPhysicalDeviceMemoryProperties& memory_properties,
Expand Down Expand Up @@ -597,17 +578,17 @@ VkResult ScreenshotHandler::CreateCopyResource(VkDevice
device_table->GetBufferMemoryRequirements(device, copy_resource->buffer, &memory_requirements);

uint32_t memory_type_index =
GetMemoryTypeIndex(memory_properties,
memory_requirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT);
graphics::GetMemoryTypeIndex(memory_properties,
memory_requirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT);

if (memory_type_index == std::numeric_limits<uint32_t>::max())
{
/* fallback to coherent */
memory_type_index =
GetMemoryTypeIndex(memory_properties,
memory_requirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
memory_type_index = graphics::GetMemoryTypeIndex(memory_properties,
memory_requirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
}

assert(memory_type_index != std::numeric_limits<uint32_t>::max());
Expand Down Expand Up @@ -660,9 +641,8 @@ VkResult ScreenshotHandler::CreateCopyResource(VkDevice
VkMemoryRequirements memory_requirements;
device_table->GetImageMemoryRequirements(device, copy_resource->convert_image, &memory_requirements);

uint32_t memory_type_index = GetMemoryTypeIndex(
uint32_t memory_type_index = graphics::GetMemoryTypeIndex(
memory_properties, memory_requirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);

assert(memory_type_index != std::numeric_limits<uint32_t>::max());

VkMemoryAllocateInfo allocate_info = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };
Expand Down
4 changes: 0 additions & 4 deletions framework/decode/screenshot_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ class ScreenshotHandler : public ScreenshotHandlerBase
uint32_t width,
uint32_t height) const;

uint32_t GetMemoryTypeIndex(const VkPhysicalDeviceMemoryProperties& memory_properties,
uint32_t type_bits,
VkMemoryPropertyFlags property_flags) const;

VkResult CreateCopyResource(VkDevice device,
const encode::VulkanDeviceTable* device_table,
const VkPhysicalDeviceMemoryProperties& memory_properties,
Expand Down
Loading

0 comments on commit 58c9a6d

Please sign in to comment.