Implemented NV RayTracing wrapper, and wrapped create_acceleration_structure_nv
This commit is contained in:
parent
7ffb94004d
commit
0a962b42cc
2 changed files with 46 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
pub use self::mesh_shader::MeshShader;
|
||||
pub use self::ray_tracing::RayTracing;
|
||||
|
||||
mod mesh_shader;
|
||||
mod ray_tracing;
|
||||
|
|
44
ash/src/extensions/nv/ray_tracing.rs
Normal file
44
ash/src/extensions/nv/ray_tracing.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
#![allow(dead_code)]
|
||||
use prelude::*;
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use version::{DeviceV1_0, InstanceV1_0};
|
||||
use vk;
|
||||
use RawPtr;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RayTracing {
|
||||
ray_tracing_fn: vk::NvRayTracingFn,
|
||||
}
|
||||
|
||||
impl RayTracing {
|
||||
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(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()))
|
||||
});
|
||||
RayTracing { ray_tracing_fn }
|
||||
}
|
||||
|
||||
pub unsafe fn create_acceleration_structure(
|
||||
&self,
|
||||
device: vk::Device,
|
||||
create_info: &vk::AccelerationStructureCreateInfoNV,
|
||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||
) -> VkResult<vk::AccelerationStructureNV> {
|
||||
let mut accel_struct = mem::uninitialized();
|
||||
let err_code = self.ray_tracing_fn.create_acceleration_structure_nv(
|
||||
device,
|
||||
create_info,
|
||||
allocation_callbacks.as_raw_ptr(),
|
||||
&mut accel_struct,
|
||||
);
|
||||
match err_code {
|
||||
vk::Result::SUCCESS => Ok(accel_struct),
|
||||
_ => Err(err_code),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr {
|
||||
CStr::from_bytes_with_nul(b"VK_NV_ray_tracing\0").expect("Wrong extension string")
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue