Added helper on RayTracing to query physical device ray tracing properties info (such as shader group handle size)

This commit is contained in:
Graham Wihlidal 2019-02-10 23:55:31 +01:00
parent 011e9e611f
commit 0ed0a06634

View file

@ -2,7 +2,7 @@
use prelude::*; use prelude::*;
use std::ffi::CStr; use std::ffi::CStr;
use std::mem; use std::mem;
use version::{DeviceV1_0, InstanceV1_0}; use version::{DeviceV1_1, InstanceV1_1};
use vk; use vk;
use RawPtr; use RawPtr;
@ -13,7 +13,7 @@ pub struct RayTracing {
} }
impl 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 { let ray_tracing_fn = vk::NvRayTracingFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
}); });
@ -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( pub unsafe fn create_acceleration_structure(
&self, &self,
create_info: &vk::AccelerationStructureCreateInfoNV, create_info: &vk::AccelerationStructureCreateInfoNV,
@ -59,7 +72,11 @@ impl RayTracing {
) -> vk::MemoryRequirements2KHR { ) -> vk::MemoryRequirements2KHR {
let mut requirements = mem::uninitialized(); let mut requirements = mem::uninitialized();
self.ray_tracing_fn 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 requirements
} }
@ -230,11 +247,7 @@ impl RayTracing {
); );
} }
pub unsafe fn compile_deferred( pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
&self,
pipeline: vk::Pipeline,
shader: u32,
) -> VkResult<()> {
let err_code = self let err_code = self
.ray_tracing_fn .ray_tracing_fn
.compile_deferred_nv(self.handle, pipeline, shader); .compile_deferred_nv(self.handle, pipeline, shader);