Skip to content

Commit 16c5212

Browse files
committed
Implement RAY_QUERY instead of RAY_TRACING_PIPELINE since there's no actual API surface for it
1 parent 399737f commit 16c5212

File tree

4 files changed

+14
-58
lines changed

4 files changed

+14
-58
lines changed

examples/ray-tracing/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ fn main() {
150150

151151
let adapter = adapters.remove(0);
152152

153-
let required_features =
154-
hal::Features::ACCELERATION_STRUCTURE | hal::Features::RAY_TRACING_PIPELINE;
153+
let required_features = hal::Features::ACCELERATION_STRUCTURE; // | hal::Features::RAY_QUERY;
155154

156155
assert!(adapter
157156
.physical_device

src/backend/vulkan/src/conv.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -592,19 +592,6 @@ pub(crate) fn map_device_features(
592592
} else {
593593
None
594594
},
595-
ray_tracing_pipeline: if features.contains(Features::RAY_TRACING_PIPELINE) {
596-
Some(
597-
vk::PhysicalDeviceRayTracingPipelineFeaturesKHR::builder()
598-
.ray_tracing_pipeline(features.contains(Features::RAY_TRACING_PIPELINE))
599-
// .ray_tracing_pipeline_shader_group_handle_capture_replay()
600-
// .ray_tracing_pipeline_shader_group_handle_capture_replay_mixed()
601-
// .ray_tracing_pipeline_trace_rays_indirect()
602-
// .ray_traversal_primitive_culling()
603-
.build(),
604-
)
605-
} else {
606-
None
607-
},
608595
}
609596
}
610597

src/backend/vulkan/src/lib.rs

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use ash::{
3232
extensions::{
3333
self,
3434
ext::{DebugReport, DebugUtils},
35-
khr::{AccelerationStructure, DrawIndirectCount, RayTracingPipeline, Swapchain},
35+
khr::{AccelerationStructure, DrawIndirectCount, RayQuery, Swapchain},
3636
nv::MeshShader,
3737
},
3838
version::{DeviceV1_0, EntryV1_0, InstanceV1_0},
@@ -684,7 +684,6 @@ pub struct DeviceCreationFeatures {
684684
imageless_framebuffers: Option<vk::PhysicalDeviceImagelessFramebufferFeaturesKHR>,
685685
buffer_device_address: Option<vk::PhysicalDeviceBufferDeviceAddressFeaturesKHR>,
686686
acceleration_structure: Option<vk::PhysicalDeviceAccelerationStructureFeaturesKHR>,
687-
ray_tracing_pipeline: Option<vk::PhysicalDeviceRayTracingPipelineFeaturesKHR>,
688687
}
689688

690689
impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
@@ -776,12 +775,11 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
776775
enabled_extensions.push(extensions::khr::DeferredHostOperations::name());
777776
}
778777

779-
if requested_features.contains(Features::RAY_TRACING_PIPELINE) {
780-
enabled_extensions.push(RayTracingPipeline::name());
778+
if requested_features.contains(Features::RAY_QUERY) {
779+
enabled_extensions.push(RayQuery::name());
781780

782-
// TODO better handling of extension dependencies? These are required by VK_KHR_ray_tracing_pipeline
781+
// TODO better handling of extension dependencies? These are required by VK_KHR_ray_query
783782
enabled_extensions.push(vk::KhrSpirv14Fn::name());
784-
enabled_extensions.push(vk::KhrShaderFloatControlsFn::name());
785783
}
786784

787785
enabled_extensions
@@ -844,13 +842,6 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
844842
info
845843
};
846844

847-
let info =
848-
if let Some(ref mut ray_tracing_pipeline) = enabled_features.ray_tracing_pipeline {
849-
info.push_next(ray_tracing_pipeline)
850-
} else {
851-
info
852-
};
853-
854845
match self.instance.inner.create_device(self.handle, &info, None) {
855846
Ok(device) => device,
856847
Err(e) => {
@@ -1069,7 +1060,7 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
10691060
let mut descriptor_indexing_features = None;
10701061
let mut buffer_device_address = None;
10711062
let mut acceleration_structure_features = None;
1072-
let mut ray_tracing_pipeline_features = None;
1063+
let mut ray_query_features = None;
10731064
let features = if let Some(ref get_device_properties) =
10741065
self.instance.get_physical_device_properties
10751066
{
@@ -1103,11 +1094,10 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
11031094
mut_ref.p_next = mem::replace(&mut features2.p_next, mut_ref as *mut _ as *mut _);
11041095
}
11051096

1106-
if self.supports_extension(RayTracingPipeline::name()) {
1107-
ray_tracing_pipeline_features =
1108-
Some(vk::PhysicalDeviceRayTracingPipelineFeaturesKHR::builder().build());
1097+
if self.supports_extension(RayQuery::name()) {
1098+
ray_query_features = Some(vk::PhysicalDeviceRayQueryFeaturesKHR::builder().build());
11091099

1110-
let mut_ref = ray_tracing_pipeline_features.as_mut().unwrap();
1100+
let mut_ref = ray_query_features.as_mut().unwrap();
11111101
mut_ref.p_next = mem::replace(&mut features2.p_next, mut_ref as *mut _ as *mut _);
11121102
}
11131103

@@ -1346,26 +1336,9 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
13461336
// TODO
13471337
}
13481338
}
1349-
if let Some(ray_tracing_pipeline_features) = ray_tracing_pipeline_features {
1350-
if ray_tracing_pipeline_features.ray_tracing_pipeline == vk::TRUE {
1351-
bits |= Features::RAY_TRACING_PIPELINE;
1352-
}
1353-
if ray_tracing_pipeline_features.ray_tracing_pipeline_shader_group_handle_capture_replay
1354-
== vk::TRUE
1355-
{
1356-
// bits |= Features::RAY_TRACING_PIPELINE_SHADER_GROUP_HANDLE_CAPTURE_REPLAY;
1357-
}
1358-
if ray_tracing_pipeline_features
1359-
.ray_tracing_pipeline_shader_group_handle_capture_replay_mixed
1360-
== vk::TRUE
1361-
{
1362-
// bits |= Features::RAY_TRACING_PIPELINE_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_MIXED;
1363-
}
1364-
if ray_tracing_pipeline_features.ray_tracing_pipeline_trace_rays_indirect == vk::TRUE {
1365-
// bits |= Features::RAY_TRACING_PIPELINE_TRACE_RAYS_INDIRECT;
1366-
}
1367-
if ray_tracing_pipeline_features.ray_traversal_primitive_culling == vk::TRUE {
1368-
// bits |= Features::RAY_TRAVERSAL_PRIMITIVE_CULLING;
1339+
if let Some(ray_query_features) = ray_query_features {
1340+
if ray_query_features.ray_query == vk::TRUE {
1341+
bits |= Features::RAY_QUERY;
13691342
}
13701343
}
13711344
if let Some(buffer_device_address) = buffer_device_address {

src/hal/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,8 @@ bitflags! {
286286
// TODO this is not supported for other resource types yet
287287
// const ACCELERATION_STRUCTURE_UPDATE_AFTER_BIND = 0x0010 << 112;
288288

289-
///
290-
const RAY_TRACING_PIPELINE = 0x0020 << 112;
291-
292-
// ///
293-
// const RAY_QUERY = 0x0040 << 112;
289+
/// Support ray query functionality in shaders.
290+
const RAY_QUERY = 0x0020 << 112;
294291
}
295292
}
296293

0 commit comments

Comments
 (0)