Skip to content

Commit

Permalink
Features required to support raytracing pipeline (#1068)
Browse files Browse the repository at this point in the history
* Code required for raytracing

* Minor init fix

---------

Co-authored-by: Peter McNeeley <[email protected]>
  • Loading branch information
petermcneeleychromium and Peter McNeeley authored Dec 23, 2024
1 parent 4d35f88 commit 8f241fa
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
39 changes: 38 additions & 1 deletion samples/config_helper_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,9 @@ ConfigHelperVulkan::ConfigHelperVulkan()
buffer_device_address_feature_(
VkPhysicalDeviceBufferDeviceAddressFeatures()),
ray_tracing_pipeline_feature_(
VkPhysicalDeviceRayTracingPipelineFeaturesKHR()) {}
VkPhysicalDeviceRayTracingPipelineFeaturesKHR()),
descriptor_indexing_feature_(
VkPhysicalDeviceDescriptorIndexingFeatures()) {}

ConfigHelperVulkan::~ConfigHelperVulkan() {
if (vulkan_device_)
Expand Down Expand Up @@ -814,6 +816,14 @@ amber::Result ConfigHelperVulkan::CheckVulkanPhysicalDeviceRequirements(
supports_buffer_device_address_ = true;
else if (ext == "VK_KHR_ray_tracing_pipeline")
supports_ray_tracing_pipeline_ = true;
else if (ext == VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME)
supports_descriptor_indexing_ = true;
else if (ext == VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME)
supports_deferred_host_operations_ = true;
else if (ext == VK_KHR_SPIRV_1_4_EXTENSION_NAME)
supports_spirv_1_4_ = true;
else if (ext == VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME)
supports_shader_float_controls_ = true;
}

VkPhysicalDeviceFeatures required_vulkan_features =
Expand All @@ -834,6 +844,8 @@ amber::Result ConfigHelperVulkan::CheckVulkanPhysicalDeviceRequirements(
{};
VkPhysicalDeviceRayTracingPipelineFeaturesKHR
ray_tracing_pipeline_features = {};
VkPhysicalDeviceDescriptorIndexingFeatures descriptor_indexing_features =
{};
void* next_ptr = nullptr;

if (supports_subgroup_size_control_) {
Expand Down Expand Up @@ -890,6 +902,13 @@ amber::Result ConfigHelperVulkan::CheckVulkanPhysicalDeviceRequirements(
next_ptr = &ray_tracing_pipeline_features;
}

if (supports_descriptor_indexing_) {
descriptor_indexing_features.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT;
descriptor_indexing_feature_.pNext = next_ptr;
next_ptr = &descriptor_indexing_features;
}

VkPhysicalDeviceFeatures2KHR features2 = VkPhysicalDeviceFeatures2KHR();
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
features2.pNext = next_ptr;
Expand Down Expand Up @@ -1146,6 +1165,24 @@ amber::Result ConfigHelperVulkan::CreateDeviceWithFeatures2(
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR,
VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);

init_feature(
supports_descriptor_indexing_, descriptor_indexing_feature_,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT,
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);

// These extensions are required to support the raytracing pipeline.
if (supports_deferred_host_operations_) {
exts.push_back(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
}

if (supports_spirv_1_4_) {
exts.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
}

if (supports_shader_float_controls_) {
exts.push_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
}

available_features2_.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
available_features2_.pNext = pnext;

Expand Down
5 changes: 5 additions & 0 deletions samples/config_helper_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ class ConfigHelperVulkan : public ConfigHelperImpl {
bool supports_acceleration_structure_ = false;
bool supports_buffer_device_address_ = false;
bool supports_ray_tracing_pipeline_ = false;
bool supports_descriptor_indexing_ = false;
bool supports_deferred_host_operations_ = false;
bool supports_spirv_1_4_ = false;
bool supports_shader_float_controls_ = false;
VkPhysicalDeviceFeatures available_features_;
VkPhysicalDeviceFeatures2KHR available_features2_;
VkPhysicalDeviceVariablePointerFeaturesKHR variable_pointers_feature_;
Expand All @@ -135,6 +139,7 @@ class ConfigHelperVulkan : public ConfigHelperImpl {
acceleration_structure_feature_;
VkPhysicalDeviceBufferDeviceAddressFeatures buffer_device_address_feature_;
VkPhysicalDeviceRayTracingPipelineFeaturesKHR ray_tracing_pipeline_feature_;
VkPhysicalDeviceDescriptorIndexingFeatures descriptor_indexing_feature_;
};

} // namespace sample
Expand Down

0 comments on commit 8f241fa

Please sign in to comment.