-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Vulkan-Headers to 1.2.162 with stable ray-tracing spec #341
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
44b0960
Update Vulkan-Headers subproject to 1.2.162 (ray tracing)
MarijnS95 9075304
Generate against vk.xml 1.2.162
MarijnS95 0cc6ace
generator: Shim IDirectFB and IDirectFBSurface to c_void
MarijnS95 ef9f8ef
generator: Edgecase for name-clash in p_geometries and pp_geometries
MarijnS95 da5d025
extensions: Migrate acceleration structure to separate extension
MarijnS95 a56ddaf
extensions: Migrate RT safe wrapper functions to ray_tracing_pipeline
MarijnS95 1ab5d21
Add high level wrapper for currently-empty RayQuery extension
MarijnS95 745594d
vk: definition: Turn host/device AS handle into type safe union
DBouma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,321 @@ | ||
#![allow(dead_code)] | ||
use crate::prelude::*; | ||
use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; | ||
use crate::vk; | ||
use crate::RawPtr; | ||
use std::ffi::CStr; | ||
use std::mem; | ||
|
||
#[derive(Clone)] | ||
pub struct AccelerationStructure { | ||
handle: vk::Device, | ||
acceleration_structure_fn: vk::KhrAccelerationStructureFn, | ||
} | ||
|
||
impl AccelerationStructure { | ||
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Self { | ||
let acceleration_structure_fn = vk::KhrAccelerationStructureFn::load(|name| unsafe { | ||
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) | ||
}); | ||
Self { | ||
handle: device.handle(), | ||
acceleration_structure_fn, | ||
} | ||
} | ||
|
||
pub unsafe fn get_properties<I: InstanceV1_1>( | ||
instance: &I, | ||
pdevice: vk::PhysicalDevice, | ||
) -> vk::PhysicalDeviceAccelerationStructurePropertiesKHR { | ||
let mut props_rt = vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default(); | ||
{ | ||
let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); | ||
instance.get_physical_device_properties2(pdevice, &mut props); | ||
} | ||
props_rt | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAccelerationStructureKHR.html>"] | ||
pub unsafe fn create_acceleration_structure( | ||
&self, | ||
create_info: &vk::AccelerationStructureCreateInfoKHR, | ||
allocation_callbacks: Option<&vk::AllocationCallbacks>, | ||
) -> VkResult<vk::AccelerationStructureKHR> { | ||
let mut accel_struct = mem::zeroed(); | ||
let err_code = self | ||
.acceleration_structure_fn | ||
.create_acceleration_structure_khr( | ||
self.handle, | ||
create_info, | ||
allocation_callbacks.as_raw_ptr(), | ||
&mut accel_struct, | ||
); | ||
match err_code { | ||
vk::Result::SUCCESS => Ok(accel_struct), | ||
_ => Err(err_code), | ||
} | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureKHR.html>"] | ||
pub unsafe fn destroy_acceleration_structure( | ||
&self, | ||
accel_struct: vk::AccelerationStructureKHR, | ||
allocation_callbacks: Option<&vk::AllocationCallbacks>, | ||
) { | ||
self.acceleration_structure_fn | ||
.destroy_acceleration_structure_khr( | ||
self.handle, | ||
accel_struct, | ||
allocation_callbacks.as_raw_ptr(), | ||
); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructuresKHR.html>"] | ||
pub unsafe fn cmd_build_acceleration_structures( | ||
&self, | ||
command_buffer: vk::CommandBuffer, | ||
infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], | ||
build_range_infos: &[&[vk::AccelerationStructureBuildRangeInfoKHR]], | ||
) { | ||
assert_eq!(infos.len(), build_range_infos.len()); | ||
|
||
let build_range_infos = build_range_infos | ||
.iter() | ||
.map(|slice| slice.as_ptr()) | ||
.collect::<Vec<*const _>>(); | ||
|
||
self.acceleration_structure_fn | ||
.cmd_build_acceleration_structures_khr( | ||
command_buffer, | ||
infos.len() as _, | ||
infos.as_ptr(), | ||
build_range_infos.as_ptr(), | ||
); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructuresIndirectKHR.html>"] | ||
pub unsafe fn cmd_build_acceleration_structures_indirect( | ||
&self, | ||
command_buffer: vk::CommandBuffer, | ||
infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], | ||
indirect_device_addresses: &[vk::DeviceAddress], | ||
indirect_strides: &[u32], | ||
max_primitive_counts: &[&u32], | ||
) { | ||
assert_eq!(infos.len(), indirect_device_addresses.len()); | ||
assert_eq!(infos.len(), indirect_strides.len()); | ||
assert_eq!(infos.len(), max_primitive_counts.len()); | ||
|
||
let max_primitive_counts = max_primitive_counts | ||
.iter() | ||
.map(|cnt| *cnt as *const _) | ||
.collect::<Vec<_>>(); | ||
|
||
self.acceleration_structure_fn | ||
.cmd_build_acceleration_structures_indirect_khr( | ||
command_buffer, | ||
infos.len() as _, | ||
infos.as_ptr(), | ||
indirect_device_addresses.as_ptr(), | ||
indirect_strides.as_ptr(), | ||
max_primitive_counts.as_ptr(), | ||
); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBuildAccelerationStructuresKHR.html>"] | ||
pub unsafe fn build_acceleration_structures( | ||
&self, | ||
device: vk::Device, | ||
deferred_operation: vk::DeferredOperationKHR, | ||
infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], | ||
build_range_infos: &[&[vk::AccelerationStructureBuildRangeInfoKHR]], | ||
) -> VkResult<()> { | ||
assert_eq!(infos.len(), build_range_infos.len()); | ||
|
||
let build_range_infos = build_range_infos | ||
.iter() | ||
.map(|slice| slice.as_ptr()) | ||
.collect::<Vec<*const _>>(); | ||
|
||
self.acceleration_structure_fn | ||
.build_acceleration_structures_khr( | ||
device, | ||
deferred_operation, | ||
infos.len() as _, | ||
infos.as_ptr(), | ||
build_range_infos.as_ptr(), | ||
) | ||
.into() | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyAccelerationStructureKHR.html>"] | ||
pub unsafe fn copy_acceleration_structure( | ||
&self, | ||
device: vk::Device, | ||
deferred_operation: vk::DeferredOperationKHR, | ||
info: &vk::CopyAccelerationStructureInfoKHR, | ||
) -> VkResult<()> { | ||
self.acceleration_structure_fn | ||
.copy_acceleration_structure_khr(device, deferred_operation, info as *const _) | ||
.into() | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyAccelerationStructureToMemoryKHR.html>"] | ||
pub unsafe fn copy_acceleration_structure_to_memory( | ||
&self, | ||
device: vk::Device, | ||
deferred_operation: vk::DeferredOperationKHR, | ||
info: &vk::CopyAccelerationStructureToMemoryInfoKHR, | ||
) -> VkResult<()> { | ||
self.acceleration_structure_fn | ||
.copy_acceleration_structure_to_memory_khr(device, deferred_operation, info as *const _) | ||
.into() | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyMemoryToAccelerationStructureKHR.html>"] | ||
pub unsafe fn copy_memory_to_acceleration_structure( | ||
&self, | ||
device: vk::Device, | ||
deferred_operation: vk::DeferredOperationKHR, | ||
info: &vk::CopyMemoryToAccelerationStructureInfoKHR, | ||
) -> VkResult<()> { | ||
self.acceleration_structure_fn | ||
.copy_memory_to_acceleration_structure_khr(device, deferred_operation, info as *const _) | ||
.into() | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWriteAccelerationStructuresPropertiesKHR.html>"] | ||
pub unsafe fn write_acceleration_structures_properties( | ||
&self, | ||
device: vk::Device, | ||
acceleration_structures: &[vk::AccelerationStructureKHR], | ||
query_type: vk::QueryType, | ||
data: &mut [u8], | ||
stride: usize, | ||
) -> VkResult<()> { | ||
self.acceleration_structure_fn | ||
.write_acceleration_structures_properties_khr( | ||
device, | ||
acceleration_structures.len() as _, | ||
acceleration_structures.as_ptr(), | ||
query_type, | ||
data.len(), | ||
data.as_mut_ptr() as *mut std::ffi::c_void, | ||
stride, | ||
) | ||
.into() | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html>"] | ||
pub unsafe fn cmd_copy_acceleration_structure( | ||
&self, | ||
command_buffer: vk::CommandBuffer, | ||
info: &vk::CopyAccelerationStructureInfoKHR, | ||
) { | ||
self.acceleration_structure_fn | ||
.cmd_copy_acceleration_structure_khr(command_buffer, info); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureToMemoryKHR.html>"] | ||
pub unsafe fn cmd_copy_acceleration_structure_to_memory( | ||
&self, | ||
command_buffer: vk::CommandBuffer, | ||
info: &vk::CopyAccelerationStructureToMemoryInfoKHR, | ||
) { | ||
self.acceleration_structure_fn | ||
.cmd_copy_acceleration_structure_to_memory_khr(command_buffer, info as *const _); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyMemoryToAccelerationStructureKHR.html>"] | ||
pub unsafe fn cmd_copy_memory_to_acceleration_structure( | ||
&self, | ||
command_buffer: vk::CommandBuffer, | ||
info: &vk::CopyMemoryToAccelerationStructureInfoKHR, | ||
) { | ||
self.acceleration_structure_fn | ||
.cmd_copy_memory_to_acceleration_structure_khr(command_buffer, info as *const _); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleKHR.html>"] | ||
pub unsafe fn get_acceleration_structure_device_address( | ||
&self, | ||
device: vk::Device, | ||
info: &vk::AccelerationStructureDeviceAddressInfoKHR, | ||
) -> vk::DeviceAddress { | ||
self.acceleration_structure_fn | ||
.get_acceleration_structure_device_address_khr(device, info as *const _) | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesKHR.html>"] | ||
pub unsafe fn cmd_write_acceleration_structures_properties( | ||
&self, | ||
command_buffer: vk::CommandBuffer, | ||
structures: &[vk::AccelerationStructureKHR], | ||
query_type: vk::QueryType, | ||
query_pool: vk::QueryPool, | ||
first_query: u32, | ||
) { | ||
self.acceleration_structure_fn | ||
.cmd_write_acceleration_structures_properties_khr( | ||
command_buffer, | ||
structures.len() as _, | ||
structures.as_ptr(), | ||
query_type, | ||
query_pool, | ||
first_query, | ||
); | ||
} | ||
|
||
pub unsafe fn get_device_acceleration_structure_compatibility( | ||
&self, | ||
device: vk::Device, | ||
version: &vk::AccelerationStructureVersionInfoKHR, | ||
) -> vk::AccelerationStructureCompatibilityKHR { | ||
let mut compatibility = vk::AccelerationStructureCompatibilityKHR::default(); | ||
|
||
self.acceleration_structure_fn | ||
.get_device_acceleration_structure_compatibility_khr( | ||
device, | ||
version, | ||
&mut compatibility as *mut _, | ||
); | ||
|
||
compatibility | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureBuildSizesKHR.html>"] | ||
pub unsafe fn get_acceleration_structure_build_sizes( | ||
&self, | ||
device: vk::Device, | ||
build_type: vk::AccelerationStructureBuildTypeKHR, | ||
build_info: &vk::AccelerationStructureBuildGeometryInfoKHR, | ||
max_primitive_counts: &[u32], | ||
) -> vk::AccelerationStructureBuildSizesInfoKHR { | ||
assert_eq!(max_primitive_counts.len(), build_info.geometry_count as _); | ||
|
||
let mut size_info = vk::AccelerationStructureBuildSizesInfoKHR::default(); | ||
|
||
self.acceleration_structure_fn | ||
.get_acceleration_structure_build_sizes_khr( | ||
device, | ||
build_type, | ||
build_info as *const _, | ||
max_primitive_counts.as_ptr(), | ||
&mut size_info as *mut _, | ||
); | ||
|
||
size_info | ||
} | ||
|
||
pub fn name() -> &'static CStr { | ||
vk::KhrAccelerationStructureFn::name() | ||
} | ||
|
||
pub fn fp(&self) -> &vk::KhrAccelerationStructureFn { | ||
&self.acceleration_structure_fn | ||
} | ||
|
||
pub fn device(&self) -> vk::Device { | ||
self.handle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#![allow(dead_code)] | ||
use crate::version::{DeviceV1_0, InstanceV1_0}; | ||
use crate::vk; | ||
use std::ffi::CStr; | ||
use std::mem; | ||
|
||
#[derive(Clone)] | ||
pub struct RayQuery { | ||
handle: vk::Device, | ||
ray_query_fn: vk::KhrRayQueryFn, | ||
} | ||
|
||
impl RayQuery { | ||
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Self { | ||
let ray_query_fn = vk::KhrRayQueryFn::load(|name| unsafe { | ||
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) | ||
}); | ||
Self { | ||
handle: device.handle(), | ||
ray_query_fn, | ||
} | ||
} | ||
|
||
pub fn name() -> &'static CStr { | ||
vk::KhrRayQueryFn::name() | ||
} | ||
|
||
pub fn fp(&self) -> &vk::KhrRayQueryFn { | ||
&self.ray_query_fn | ||
} | ||
|
||
pub fn device(&self) -> vk::Device { | ||
self.handle | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is slightly unfortunate. I think this could actually be safe to transmute, but safe code for now is totally fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that'd be better, one now has to be aware that
cnt
is&&u32
to make the pointer cast work.