Skip to content

Commit

Permalink
Added helper on RayTracing to query physical device ray tracing prope…
Browse files Browse the repository at this point in the history
…rties info (such as shader group handle size)
  • Loading branch information
gwihlidal committed Feb 10, 2019
1 parent 011e9e6 commit 0ed0a06
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions ash/src/extensions/nv/ray_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use prelude::*;
use std::ffi::CStr;
use std::mem;
use version::{DeviceV1_0, InstanceV1_0};
use version::{DeviceV1_1, InstanceV1_1};
use vk;
use RawPtr;

Expand All @@ -13,7 +13,7 @@ pub struct RayTracing {
}

impl RayTracing {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> RayTracing {
pub fn new<I: InstanceV1_1, D: DeviceV1_1>(instance: &I, device: &D) -> RayTracing {
let ray_tracing_fn = vk::NvRayTracingFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
Expand All @@ -23,6 +23,19 @@ impl RayTracing {
}
}

pub unsafe fn get_properties<I: InstanceV1_1>(
instance: &I,
pdevice: vk::PhysicalDevice,
) -> vk::PhysicalDeviceRayTracingPropertiesNV {
let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesNV::default();
let mut props = vk::PhysicalDeviceProperties2::builder()
.next(&mut props_rt)
.build();

instance.get_physical_device_properties2(pdevice, &mut props);
props_rt
}

pub unsafe fn create_acceleration_structure(
&self,
create_info: &vk::AccelerationStructureCreateInfoNV,
Expand Down Expand Up @@ -59,7 +72,11 @@ impl RayTracing {
) -> vk::MemoryRequirements2KHR {
let mut requirements = mem::uninitialized();
self.ray_tracing_fn
.get_acceleration_structure_memory_requirements_nv(self.handle, info, &mut requirements);
.get_acceleration_structure_memory_requirements_nv(
self.handle,
info,
&mut requirements,
);
requirements
}

Expand Down Expand Up @@ -230,11 +247,7 @@ impl RayTracing {
);
}

pub unsafe fn compile_deferred(
&self,
pipeline: vk::Pipeline,
shader: u32,
) -> VkResult<()> {
pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
let err_code = self
.ray_tracing_fn
.compile_deferred_nv(self.handle, pipeline, shader);
Expand Down

0 comments on commit 0ed0a06

Please sign in to comment.