diff --git a/Changelog.md b/Changelog.md index a3ffe4a..8749c4c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,7 +8,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add `VK_KHR_present_wait` extension (#493) +- Added `VK_KHR_present_wait` device extension (#493) + +### Changed + +- Device extension `khr::PipelineExecutableProperties` and `khr::TimelineSemaphore` now expose `fn device()` instead of `fn instance()` (#499) +- Changed `khr::PipelineExecutableProperties::new()` and `khr::TimelineSemaphore::new()` to take `instance` and `device` as arguments (#499) + +### Removed + +- Removed `device()` function from `khr::Synchronization2` device extension (#494) +- Removed `instance()` function from `ext::ExtendedDynamicState`, `khr::PushDescriptor`, `ext::ToolingInfo` and `khr::GetPhysicalDeviceProperties2` instance extensions (#494) +- Removed `device` argument from `ext::DebugMarkers::debug_marker_set_object_name` function (#494) +- Removed `From` trait for `VkResult` (#495) +- Removed `instance` argument from `ext::DebugUtils::submit_debug_utils_message` function (#499) ## [0.33.3] - 2021-09-08 diff --git a/ash/src/extensions/ext/buffer_device_address.rs b/ash/src/extensions/ext/buffer_device_address.rs index ecb03af..61578ee 100644 --- a/ash/src/extensions/ext/buffer_device_address.rs +++ b/ash/src/extensions/ext/buffer_device_address.rs @@ -6,18 +6,16 @@ use std::mem; #[derive(Clone)] pub struct BufferDeviceAddress { handle: vk::Device, - fns: vk::ExtBufferDeviceAddressFn, + fp: vk::ExtBufferDeviceAddressFn, } impl BufferDeviceAddress { pub fn new(instance: &Instance, device: &Device) -> Self { - let fns = vk::ExtBufferDeviceAddressFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::ExtBufferDeviceAddressFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - fns, - } + Self { handle, fp } } #[doc = ""] @@ -25,7 +23,7 @@ impl BufferDeviceAddress { &self, info: &vk::BufferDeviceAddressInfoEXT, ) -> vk::DeviceAddress { - self.fns.get_buffer_device_address_ext(self.handle, info) + self.fp.get_buffer_device_address_ext(self.handle, info) } pub fn name() -> &'static CStr { @@ -33,7 +31,7 @@ impl BufferDeviceAddress { } pub fn fp(&self) -> &vk::ExtBufferDeviceAddressFn { - &self.fns + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/ext/debug_marker.rs b/ash/src/extensions/ext/debug_marker.rs index 102ea46..1d2f76a 100755 --- a/ash/src/extensions/ext/debug_marker.rs +++ b/ash/src/extensions/ext/debug_marker.rs @@ -6,29 +6,26 @@ use std::mem; #[derive(Clone)] pub struct DebugMarker { - debug_marker_fn: vk::ExtDebugMarkerFn, + handle: vk::Device, + fp: vk::ExtDebugMarkerFn, } impl DebugMarker { pub fn new(instance: &Instance, device: &Device) -> Self { - let debug_marker_fn = vk::ExtDebugMarkerFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::ExtDebugMarkerFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { debug_marker_fn } - } - - pub fn name() -> &'static CStr { - vk::ExtDebugMarkerFn::name() + Self { handle, fp } } #[doc = ""] pub unsafe fn debug_marker_set_object_name( &self, - device: vk::Device, name_info: &vk::DebugMarkerObjectNameInfoEXT, ) -> VkResult<()> { - self.debug_marker_fn - .debug_marker_set_object_name_ext(device, name_info) + self.fp + .debug_marker_set_object_name_ext(self.handle, name_info) .result() } @@ -38,14 +35,13 @@ impl DebugMarker { command_buffer: vk::CommandBuffer, marker_info: &vk::DebugMarkerMarkerInfoEXT, ) { - self.debug_marker_fn + self.fp .cmd_debug_marker_begin_ext(command_buffer, marker_info); } #[doc = ""] pub unsafe fn cmd_debug_marker_end(&self, command_buffer: vk::CommandBuffer) { - self.debug_marker_fn - .cmd_debug_marker_end_ext(command_buffer); + self.fp.cmd_debug_marker_end_ext(command_buffer); } #[doc = ""] @@ -54,11 +50,19 @@ impl DebugMarker { command_buffer: vk::CommandBuffer, marker_info: &vk::DebugMarkerMarkerInfoEXT, ) { - self.debug_marker_fn + self.fp .cmd_debug_marker_insert_ext(command_buffer, marker_info); } + pub fn name() -> &'static CStr { + vk::ExtDebugMarkerFn::name() + } + pub fn fp(&self) -> &vk::ExtDebugMarkerFn { - &self.debug_marker_fn + &self.fp + } + + pub fn device(&self) -> vk::Device { + self.handle } } diff --git a/ash/src/extensions/ext/debug_report.rs b/ash/src/extensions/ext/debug_report.rs index 89abb9b..6382509 100755 --- a/ash/src/extensions/ext/debug_report.rs +++ b/ash/src/extensions/ext/debug_report.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct DebugReport { handle: vk::Instance, - debug_report_fn: vk::ExtDebugReportFn, + fp: vk::ExtDebugReportFn, } impl DebugReport { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let debug_report_fn = vk::ExtDebugReportFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::ExtDebugReportFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - debug_report_fn, - } - } - - pub fn name() -> &'static CStr { - vk::ExtDebugReportFn::name() + Self { handle, fp } } #[doc = ""] @@ -32,7 +26,7 @@ impl DebugReport { debug: vk::DebugReportCallbackEXT, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.debug_report_fn.destroy_debug_report_callback_ext( + self.fp.destroy_debug_report_callback_ext( self.handle, debug, allocation_callbacks.as_raw_ptr(), @@ -46,7 +40,7 @@ impl DebugReport { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut debug_cb = mem::zeroed(); - self.debug_report_fn + self.fp .create_debug_report_callback_ext( self.handle, create_info, @@ -56,8 +50,12 @@ impl DebugReport { .result_with_success(debug_cb) } + pub fn name() -> &'static CStr { + vk::ExtDebugReportFn::name() + } + pub fn fp(&self) -> &vk::ExtDebugReportFn { - &self.debug_report_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/ext/debug_utils.rs b/ash/src/extensions/ext/debug_utils.rs index 1bb87d8..0b38d5e 100755 --- a/ash/src/extensions/ext/debug_utils.rs +++ b/ash/src/extensions/ext/debug_utils.rs @@ -7,22 +7,16 @@ use std::mem; #[derive(Clone)] pub struct DebugUtils { handle: vk::Instance, - debug_utils_fn: vk::ExtDebugUtilsFn, + fp: vk::ExtDebugUtilsFn, } impl DebugUtils { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let debug_utils_fn = vk::ExtDebugUtilsFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::ExtDebugUtilsFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - debug_utils_fn, - } - } - - pub fn name() -> &'static CStr { - vk::ExtDebugUtilsFn::name() + Self { handle, fp } } #[doc = ""] @@ -31,7 +25,7 @@ impl DebugUtils { device: vk::Device, name_info: &vk::DebugUtilsObjectNameInfoEXT, ) -> VkResult<()> { - self.debug_utils_fn + self.fp .set_debug_utils_object_name_ext(device, name_info) .result() } @@ -42,7 +36,7 @@ impl DebugUtils { device: vk::Device, tag_info: &vk::DebugUtilsObjectTagInfoEXT, ) -> VkResult<()> { - self.debug_utils_fn + self.fp .set_debug_utils_object_tag_ext(device, tag_info) .result() } @@ -53,14 +47,13 @@ impl DebugUtils { command_buffer: vk::CommandBuffer, label: &vk::DebugUtilsLabelEXT, ) { - self.debug_utils_fn + self.fp .cmd_begin_debug_utils_label_ext(command_buffer, label); } #[doc = ""] pub unsafe fn cmd_end_debug_utils_label(&self, command_buffer: vk::CommandBuffer) { - self.debug_utils_fn - .cmd_end_debug_utils_label_ext(command_buffer); + self.fp.cmd_end_debug_utils_label_ext(command_buffer); } #[doc = ""] @@ -69,7 +62,7 @@ impl DebugUtils { command_buffer: vk::CommandBuffer, label: &vk::DebugUtilsLabelEXT, ) { - self.debug_utils_fn + self.fp .cmd_insert_debug_utils_label_ext(command_buffer, label); } @@ -79,13 +72,12 @@ impl DebugUtils { queue: vk::Queue, label: &vk::DebugUtilsLabelEXT, ) { - self.debug_utils_fn - .queue_begin_debug_utils_label_ext(queue, label); + self.fp.queue_begin_debug_utils_label_ext(queue, label); } #[doc = ""] pub unsafe fn queue_end_debug_utils_label(&self, queue: vk::Queue) { - self.debug_utils_fn.queue_end_debug_utils_label_ext(queue); + self.fp.queue_end_debug_utils_label_ext(queue); } #[doc = ""] @@ -94,8 +86,7 @@ impl DebugUtils { queue: vk::Queue, label: &vk::DebugUtilsLabelEXT, ) { - self.debug_utils_fn - .queue_insert_debug_utils_label_ext(queue, label); + self.fp.queue_insert_debug_utils_label_ext(queue, label); } #[doc = ""] @@ -105,7 +96,7 @@ impl DebugUtils { allocator: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut messenger = mem::zeroed(); - self.debug_utils_fn + self.fp .create_debug_utils_messenger_ext( self.handle, create_info, @@ -121,11 +112,8 @@ impl DebugUtils { messenger: vk::DebugUtilsMessengerEXT, allocator: Option<&vk::AllocationCallbacks>, ) { - self.debug_utils_fn.destroy_debug_utils_messenger_ext( - self.handle, - messenger, - allocator.as_raw_ptr(), - ); + self.fp + .destroy_debug_utils_messenger_ext(self.handle, messenger, allocator.as_raw_ptr()); } #[doc = ""] @@ -135,7 +123,7 @@ impl DebugUtils { message_types: vk::DebugUtilsMessageTypeFlagsEXT, callback_data: &vk::DebugUtilsMessengerCallbackDataEXT, ) { - self.debug_utils_fn.submit_debug_utils_message_ext( + self.fp.submit_debug_utils_message_ext( self.handle, message_severity, message_types, @@ -143,8 +131,12 @@ impl DebugUtils { ); } + pub fn name() -> &'static CStr { + vk::ExtDebugUtilsFn::name() + } + pub fn fp(&self) -> &vk::ExtDebugUtilsFn { - &self.debug_utils_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/ext/extended_dynamic_state.rs b/ash/src/extensions/ext/extended_dynamic_state.rs index acd5408..eda5d61 100644 --- a/ash/src/extensions/ext/extended_dynamic_state.rs +++ b/ash/src/extensions/ext/extended_dynamic_state.rs @@ -6,23 +6,15 @@ use std::ptr; #[derive(Clone)] pub struct ExtendedDynamicState { - handle: vk::Instance, - extended_dynamic_state_fn: vk::ExtExtendedDynamicStateFn, + fp: vk::ExtExtendedDynamicStateFn, } impl ExtendedDynamicState { pub fn new(instance: &Instance, device: &Device) -> Self { - let extended_dynamic_state_fn = vk::ExtExtendedDynamicStateFn::load(|name| unsafe { + let fp = vk::ExtExtendedDynamicStateFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); - Self { - handle: instance.handle(), - extended_dynamic_state_fn, - } - } - - pub fn name() -> &'static CStr { - vk::ExtExtendedDynamicStateFn::name() + Self { fp } } #[doc = ""] @@ -31,8 +23,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, cull_mode: vk::CullModeFlags, ) { - self.extended_dynamic_state_fn - .cmd_set_cull_mode_ext(command_buffer, cull_mode) + self.fp.cmd_set_cull_mode_ext(command_buffer, cull_mode) } #[doc = ""] @@ -41,8 +32,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, front_face: vk::FrontFace, ) { - self.extended_dynamic_state_fn - .cmd_set_front_face_ext(command_buffer, front_face) + self.fp.cmd_set_front_face_ext(command_buffer, front_face) } #[doc = ""] @@ -51,7 +41,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, primitive_topology: vk::PrimitiveTopology, ) { - self.extended_dynamic_state_fn + self.fp .cmd_set_primitive_topology_ext(command_buffer, primitive_topology) } @@ -61,12 +51,11 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, viewports: &[vk::Viewport], ) { - self.extended_dynamic_state_fn - .cmd_set_viewport_with_count_ext( - command_buffer, - viewports.len() as u32, - viewports.as_ptr(), - ) + self.fp.cmd_set_viewport_with_count_ext( + command_buffer, + viewports.len() as u32, + viewports.as_ptr(), + ) } #[doc = ""] @@ -75,12 +64,11 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, scissors: &[vk::Rect2D], ) { - self.extended_dynamic_state_fn - .cmd_set_scissor_with_count_ext( - command_buffer, - scissors.len() as u32, - scissors.as_ptr(), - ) + self.fp.cmd_set_scissor_with_count_ext( + command_buffer, + scissors.len() as u32, + scissors.as_ptr(), + ) } #[doc = ""] @@ -106,7 +94,7 @@ impl ExtendedDynamicState { } else { ptr::null() }; - self.extended_dynamic_state_fn.cmd_bind_vertex_buffers2_ext( + self.fp.cmd_bind_vertex_buffers2_ext( command_buffer, first_binding, buffers.len() as u32, @@ -123,7 +111,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, depth_test_enable: bool, ) { - self.extended_dynamic_state_fn + self.fp .cmd_set_depth_test_enable_ext(command_buffer, depth_test_enable.into()) } @@ -133,7 +121,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, depth_write_enable: bool, ) { - self.extended_dynamic_state_fn + self.fp .cmd_set_depth_write_enable_ext(command_buffer, depth_write_enable.into()) } @@ -143,7 +131,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, depth_compare_op: vk::CompareOp, ) { - self.extended_dynamic_state_fn + self.fp .cmd_set_depth_compare_op_ext(command_buffer, depth_compare_op) } @@ -153,7 +141,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, depth_bounds_test_enable: bool, ) { - self.extended_dynamic_state_fn + self.fp .cmd_set_depth_bounds_test_enable_ext(command_buffer, depth_bounds_test_enable.into()) } @@ -163,7 +151,7 @@ impl ExtendedDynamicState { command_buffer: vk::CommandBuffer, stencil_test_enable: bool, ) { - self.extended_dynamic_state_fn + self.fp .cmd_set_stencil_test_enable_ext(command_buffer, stencil_test_enable.into()) } @@ -177,7 +165,7 @@ impl ExtendedDynamicState { depth_fail_op: vk::StencilOp, compare_op: vk::CompareOp, ) { - self.extended_dynamic_state_fn.cmd_set_stencil_op_ext( + self.fp.cmd_set_stencil_op_ext( command_buffer, face_mask, fail_op, @@ -187,11 +175,11 @@ impl ExtendedDynamicState { ) } - pub fn fp(&self) -> &vk::ExtExtendedDynamicStateFn { - &self.extended_dynamic_state_fn + pub fn name() -> &'static CStr { + vk::ExtExtendedDynamicStateFn::name() } - pub fn instance(&self) -> vk::Instance { - self.handle + pub fn fp(&self) -> &vk::ExtExtendedDynamicStateFn { + &self.fp } } diff --git a/ash/src/extensions/ext/full_screen_exclusive.rs b/ash/src/extensions/ext/full_screen_exclusive.rs index 59d546d..0d7fd45 100644 --- a/ash/src/extensions/ext/full_screen_exclusive.rs +++ b/ash/src/extensions/ext/full_screen_exclusive.rs @@ -7,22 +7,16 @@ use std::mem; #[derive(Clone)] pub struct FullScreenExclusive { handle: vk::Device, - full_screen_exclusive_fn: vk::ExtFullScreenExclusiveFn, + fp: vk::ExtFullScreenExclusiveFn, } impl FullScreenExclusive { pub fn new(instance: &Instance, device: &Device) -> Self { - let full_screen_exclusive_fn = vk::ExtFullScreenExclusiveFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::ExtFullScreenExclusiveFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - full_screen_exclusive_fn, - } - } - - pub fn name() -> &'static CStr { - vk::ExtFullScreenExclusiveFn::name() + Self { handle, fp } } #[doc = ""] @@ -30,7 +24,7 @@ impl FullScreenExclusive { &self, swapchain: vk::SwapchainKHR, ) -> VkResult<()> { - self.full_screen_exclusive_fn + self.fp .acquire_full_screen_exclusive_mode_ext(self.handle, swapchain) .result() } @@ -42,13 +36,12 @@ impl FullScreenExclusive { surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.full_screen_exclusive_fn - .get_physical_device_surface_present_modes2_ext( - physical_device, - surface_info, - count, - data, - ) + self.fp.get_physical_device_surface_present_modes2_ext( + physical_device, + surface_info, + count, + data, + ) }) } @@ -57,7 +50,7 @@ impl FullScreenExclusive { &self, swapchain: vk::SwapchainKHR, ) -> VkResult<()> { - self.full_screen_exclusive_fn + self.fp .release_full_screen_exclusive_mode_ext(self.handle, swapchain) .result() } @@ -68,7 +61,7 @@ impl FullScreenExclusive { surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, ) -> VkResult { let mut present_modes = mem::zeroed(); - self.full_screen_exclusive_fn + self.fp .get_device_group_surface_present_modes2_ext( self.handle, surface_info, @@ -77,8 +70,12 @@ impl FullScreenExclusive { .result_with_success(present_modes) } + pub fn name() -> &'static CStr { + vk::ExtFullScreenExclusiveFn::name() + } + pub fn fp(&self) -> &vk::ExtFullScreenExclusiveFn { - &self.full_screen_exclusive_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/ext/metal_surface.rs b/ash/src/extensions/ext/metal_surface.rs index 6cf3207..d4be230 100644 --- a/ash/src/extensions/ext/metal_surface.rs +++ b/ash/src/extensions/ext/metal_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct MetalSurface { handle: vk::Instance, - metal_surface_fn: vk::ExtMetalSurfaceFn, + fp: vk::ExtMetalSurfaceFn, } impl MetalSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::ExtMetalSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::ExtMetalSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - metal_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::ExtMetalSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl MetalSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.metal_surface_fn + self.fp .create_metal_surface_ext( self.handle, create_info, @@ -43,8 +37,12 @@ impl MetalSurface { .result_with_success(surface) } + pub fn name() -> &'static CStr { + vk::ExtMetalSurfaceFn::name() + } + pub fn fp(&self) -> &vk::ExtMetalSurfaceFn { - &self.metal_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/ext/tooling_info.rs b/ash/src/extensions/ext/tooling_info.rs index 0b0c8ae..ccc8544 100644 --- a/ash/src/extensions/ext/tooling_info.rs +++ b/ash/src/extensions/ext/tooling_info.rs @@ -6,23 +6,15 @@ use std::mem; #[derive(Clone)] pub struct ToolingInfo { - handle: vk::Instance, - tooling_info_fn: vk::ExtToolingInfoFn, + fp: vk::ExtToolingInfoFn, } impl ToolingInfo { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let tooling_info_fn = vk::ExtToolingInfoFn::load(|name| unsafe { + let fp = vk::ExtToolingInfoFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); - Self { - handle: instance.handle(), - tooling_info_fn, - } - } - - pub fn name() -> &'static CStr { - vk::ExtToolingInfoFn::name() + Self { fp } } #[doc = ""] @@ -31,16 +23,16 @@ impl ToolingInfo { physical_device: vk::PhysicalDevice, ) -> VkResult> { read_into_defaulted_vector(|count, data| { - self.tooling_info_fn + self.fp .get_physical_device_tool_properties_ext(physical_device, count, data) }) } - pub fn fp(&self) -> &vk::ExtToolingInfoFn { - &self.tooling_info_fn + pub fn name() -> &'static CStr { + vk::ExtToolingInfoFn::name() } - pub fn instance(&self) -> vk::Instance { - self.handle + pub fn fp(&self) -> &vk::ExtToolingInfoFn { + &self.fp } } diff --git a/ash/src/extensions/khr/acceleration_structure.rs b/ash/src/extensions/khr/acceleration_structure.rs index 801f3e1..6b9b8e8 100644 --- a/ash/src/extensions/khr/acceleration_structure.rs +++ b/ash/src/extensions/khr/acceleration_structure.rs @@ -8,18 +8,16 @@ use std::mem; #[derive(Clone)] pub struct AccelerationStructure { handle: vk::Device, - acceleration_structure_fn: vk::KhrAccelerationStructureFn, + fp: vk::KhrAccelerationStructureFn, } impl AccelerationStructure { pub fn new(instance: &Instance, device: &Device) -> Self { - let acceleration_structure_fn = vk::KhrAccelerationStructureFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrAccelerationStructureFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - acceleration_structure_fn, - } + Self { handle, fp } } pub unsafe fn get_properties( @@ -41,7 +39,7 @@ impl AccelerationStructure { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut accel_struct = mem::zeroed(); - self.acceleration_structure_fn + self.fp .create_acceleration_structure_khr( self.handle, create_info, @@ -57,12 +55,11 @@ impl AccelerationStructure { 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(), - ); + self.fp.destroy_acceleration_structure_khr( + self.handle, + accel_struct, + allocation_callbacks.as_raw_ptr(), + ); } #[doc = ""] @@ -83,13 +80,12 @@ impl AccelerationStructure { }) .collect::>(); - self.acceleration_structure_fn - .cmd_build_acceleration_structures_khr( - command_buffer, - infos.len() as _, - infos.as_ptr(), - build_range_infos.as_ptr(), - ); + self.fp.cmd_build_acceleration_structures_khr( + command_buffer, + infos.len() as _, + infos.as_ptr(), + build_range_infos.as_ptr(), + ); } #[doc = ""] @@ -114,15 +110,14 @@ impl AccelerationStructure { }) .collect::>(); - 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(), - ); + self.fp.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 = ""] @@ -143,7 +138,7 @@ impl AccelerationStructure { }) .collect::>(); - self.acceleration_structure_fn + self.fp .build_acceleration_structures_khr( self.handle, deferred_operation, @@ -160,7 +155,7 @@ impl AccelerationStructure { deferred_operation: vk::DeferredOperationKHR, info: &vk::CopyAccelerationStructureInfoKHR, ) -> VkResult<()> { - self.acceleration_structure_fn + self.fp .copy_acceleration_structure_khr(self.handle, deferred_operation, info as *const _) .result() } @@ -171,7 +166,7 @@ impl AccelerationStructure { deferred_operation: vk::DeferredOperationKHR, info: &vk::CopyAccelerationStructureToMemoryInfoKHR, ) -> VkResult<()> { - self.acceleration_structure_fn + self.fp .copy_acceleration_structure_to_memory_khr( self.handle, deferred_operation, @@ -186,7 +181,7 @@ impl AccelerationStructure { deferred_operation: vk::DeferredOperationKHR, info: &vk::CopyMemoryToAccelerationStructureInfoKHR, ) -> VkResult<()> { - self.acceleration_structure_fn + self.fp .copy_memory_to_acceleration_structure_khr( self.handle, deferred_operation, @@ -203,7 +198,7 @@ impl AccelerationStructure { data: &mut [u8], stride: usize, ) -> VkResult<()> { - self.acceleration_structure_fn + self.fp .write_acceleration_structures_properties_khr( self.handle, acceleration_structures.len() as _, @@ -222,7 +217,7 @@ impl AccelerationStructure { command_buffer: vk::CommandBuffer, info: &vk::CopyAccelerationStructureInfoKHR, ) { - self.acceleration_structure_fn + self.fp .cmd_copy_acceleration_structure_khr(command_buffer, info); } @@ -232,7 +227,7 @@ impl AccelerationStructure { command_buffer: vk::CommandBuffer, info: &vk::CopyAccelerationStructureToMemoryInfoKHR, ) { - self.acceleration_structure_fn + self.fp .cmd_copy_acceleration_structure_to_memory_khr(command_buffer, info as *const _); } @@ -242,7 +237,7 @@ impl AccelerationStructure { command_buffer: vk::CommandBuffer, info: &vk::CopyMemoryToAccelerationStructureInfoKHR, ) { - self.acceleration_structure_fn + self.fp .cmd_copy_memory_to_acceleration_structure_khr(command_buffer, info as *const _); } @@ -251,7 +246,7 @@ impl AccelerationStructure { &self, info: &vk::AccelerationStructureDeviceAddressInfoKHR, ) -> vk::DeviceAddress { - self.acceleration_structure_fn + self.fp .get_acceleration_structure_device_address_khr(self.handle, info as *const _) } @@ -264,15 +259,14 @@ impl AccelerationStructure { 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, - ); + self.fp.cmd_write_acceleration_structures_properties_khr( + command_buffer, + structures.len() as _, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); } #[doc = ""] @@ -282,12 +276,11 @@ impl AccelerationStructure { ) -> vk::AccelerationStructureCompatibilityKHR { let mut compatibility = vk::AccelerationStructureCompatibilityKHR::default(); - self.acceleration_structure_fn - .get_device_acceleration_structure_compatibility_khr( - self.handle, - version, - &mut compatibility as *mut _, - ); + self.fp.get_device_acceleration_structure_compatibility_khr( + self.handle, + version, + &mut compatibility as *mut _, + ); compatibility } @@ -303,14 +296,13 @@ impl AccelerationStructure { let mut size_info = vk::AccelerationStructureBuildSizesInfoKHR::default(); - self.acceleration_structure_fn - .get_acceleration_structure_build_sizes_khr( - self.handle, - build_type, - build_info as *const _, - max_primitive_counts.as_ptr(), - &mut size_info as *mut _, - ); + self.fp.get_acceleration_structure_build_sizes_khr( + self.handle, + build_type, + build_info as *const _, + max_primitive_counts.as_ptr(), + &mut size_info as *mut _, + ); size_info } @@ -320,7 +312,7 @@ impl AccelerationStructure { } pub fn fp(&self) -> &vk::KhrAccelerationStructureFn { - &self.acceleration_structure_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/android_surface.rs b/ash/src/extensions/khr/android_surface.rs index 354279e..336ae10 100755 --- a/ash/src/extensions/khr/android_surface.rs +++ b/ash/src/extensions/khr/android_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct AndroidSurface { handle: vk::Instance, - android_surface_fn: vk::KhrAndroidSurfaceFn, + fp: vk::KhrAndroidSurfaceFn, } impl AndroidSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::KhrAndroidSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::KhrAndroidSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - android_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrAndroidSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl AndroidSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.android_surface_fn + self.fp .create_android_surface_khr( self.handle, create_info, @@ -43,8 +37,12 @@ impl AndroidSurface { .result_with_success(surface) } + pub fn name() -> &'static CStr { + vk::KhrAndroidSurfaceFn::name() + } + pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn { - &self.android_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/khr/buffer_device_address.rs b/ash/src/extensions/khr/buffer_device_address.rs index 382df45..26e8308 100644 --- a/ash/src/extensions/khr/buffer_device_address.rs +++ b/ash/src/extensions/khr/buffer_device_address.rs @@ -6,18 +6,16 @@ use std::mem; #[derive(Clone)] pub struct BufferDeviceAddress { handle: vk::Device, - fns: vk::KhrBufferDeviceAddressFn, + fp: vk::KhrBufferDeviceAddressFn, } impl BufferDeviceAddress { pub fn new(instance: &Instance, device: &Device) -> Self { - let fns = vk::KhrBufferDeviceAddressFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrBufferDeviceAddressFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - fns, - } + Self { handle, fp } } #[doc = ""] @@ -25,7 +23,7 @@ impl BufferDeviceAddress { &self, info: &vk::BufferDeviceAddressInfoKHR, ) -> vk::DeviceAddress { - self.fns.get_buffer_device_address_khr(self.handle, info) + self.fp.get_buffer_device_address_khr(self.handle, info) } #[doc = ""] @@ -33,7 +31,7 @@ impl BufferDeviceAddress { &self, info: &vk::BufferDeviceAddressInfoKHR, ) -> u64 { - self.fns + self.fp .get_buffer_opaque_capture_address_khr(self.handle, info) } @@ -42,7 +40,7 @@ impl BufferDeviceAddress { &self, info: &vk::DeviceMemoryOpaqueCaptureAddressInfoKHR, ) -> u64 { - self.fns + self.fp .get_device_memory_opaque_capture_address_khr(self.handle, info) } @@ -51,7 +49,7 @@ impl BufferDeviceAddress { } pub fn fp(&self) -> &vk::KhrBufferDeviceAddressFn { - &self.fns + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/create_render_pass2.rs b/ash/src/extensions/khr/create_render_pass2.rs index 09e1a4c..537906a 100644 --- a/ash/src/extensions/khr/create_render_pass2.rs +++ b/ash/src/extensions/khr/create_render_pass2.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct CreateRenderPass2 { handle: vk::Device, - khr_create_renderpass2_fn: vk::KhrCreateRenderpass2Fn, + fp: vk::KhrCreateRenderpass2Fn, } impl CreateRenderPass2 { pub fn new(instance: &Instance, device: &Device) -> Self { - let khr_create_renderpass2_fn = vk::KhrCreateRenderpass2Fn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrCreateRenderpass2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - khr_create_renderpass2_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrCreateRenderpass2Fn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl CreateRenderPass2 { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut renderpass = mem::zeroed(); - self.khr_create_renderpass2_fn + self.fp .create_render_pass2_khr( self.handle, create_info, @@ -50,7 +44,7 @@ impl CreateRenderPass2 { render_pass_begin_info: &vk::RenderPassBeginInfo, subpass_begin_info: &vk::SubpassBeginInfo, ) { - self.khr_create_renderpass2_fn.cmd_begin_render_pass2_khr( + self.fp.cmd_begin_render_pass2_khr( command_buffer, render_pass_begin_info, subpass_begin_info, @@ -64,11 +58,8 @@ impl CreateRenderPass2 { subpass_begin_info: &vk::SubpassBeginInfo, subpass_end_info: &vk::SubpassEndInfo, ) { - self.khr_create_renderpass2_fn.cmd_next_subpass2_khr( - command_buffer, - subpass_begin_info, - subpass_end_info, - ); + self.fp + .cmd_next_subpass2_khr(command_buffer, subpass_begin_info, subpass_end_info); } #[doc = ""] @@ -77,12 +68,16 @@ impl CreateRenderPass2 { command_buffer: vk::CommandBuffer, subpass_end_info: &vk::SubpassEndInfo, ) { - self.khr_create_renderpass2_fn + self.fp .cmd_end_render_pass2_khr(command_buffer, subpass_end_info); } + pub fn name() -> &'static CStr { + vk::KhrCreateRenderpass2Fn::name() + } + pub fn fp(&self) -> &vk::KhrCreateRenderpass2Fn { - &self.khr_create_renderpass2_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/deferred_host_operations.rs b/ash/src/extensions/khr/deferred_host_operations.rs index d4b2c3d..ba84207 100644 --- a/ash/src/extensions/khr/deferred_host_operations.rs +++ b/ash/src/extensions/khr/deferred_host_operations.rs @@ -8,18 +8,16 @@ use std::mem; #[derive(Clone)] pub struct DeferredHostOperations { handle: vk::Device, - deferred_host_operations_fn: vk::KhrDeferredHostOperationsFn, + fp: vk::KhrDeferredHostOperationsFn, } impl DeferredHostOperations { pub fn new(instance: &Instance, device: &Device) -> Self { - let deferred_host_operations_fn = vk::KhrDeferredHostOperationsFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrDeferredHostOperationsFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - deferred_host_operations_fn, - } + Self { handle, fp } } #[doc = ""] @@ -28,7 +26,7 @@ impl DeferredHostOperations { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut operation = mem::zeroed(); - self.deferred_host_operations_fn + self.fp .create_deferred_operation_khr( self.handle, allocation_callbacks.as_raw_ptr(), @@ -42,7 +40,7 @@ impl DeferredHostOperations { &self, operation: vk::DeferredOperationKHR, ) -> VkResult<()> { - self.deferred_host_operations_fn + self.fp .deferred_operation_join_khr(self.handle, operation) .result() } @@ -53,12 +51,11 @@ impl DeferredHostOperations { operation: vk::DeferredOperationKHR, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.deferred_host_operations_fn - .destroy_deferred_operation_khr( - self.handle, - operation, - allocation_callbacks.as_raw_ptr(), - ); + self.fp.destroy_deferred_operation_khr( + self.handle, + operation, + allocation_callbacks.as_raw_ptr(), + ); } #[doc = ""] @@ -66,7 +63,7 @@ impl DeferredHostOperations { &self, operation: vk::DeferredOperationKHR, ) -> u32 { - self.deferred_host_operations_fn + self.fp .get_deferred_operation_max_concurrency_khr(self.handle, operation) } @@ -75,7 +72,7 @@ impl DeferredHostOperations { &self, operation: vk::DeferredOperationKHR, ) -> VkResult<()> { - self.deferred_host_operations_fn + self.fp .get_deferred_operation_result_khr(self.handle, operation) .result() } @@ -85,7 +82,7 @@ impl DeferredHostOperations { } pub fn fp(&self) -> &vk::KhrDeferredHostOperationsFn { - &self.deferred_host_operations_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/display.rs b/ash/src/extensions/khr/display.rs index b24d597..0d1ee9a 100755 --- a/ash/src/extensions/khr/display.rs +++ b/ash/src/extensions/khr/display.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct Display { handle: vk::Instance, - display_fn: vk::KhrDisplayFn, + fp: vk::KhrDisplayFn, } impl Display { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let display_fn = vk::KhrDisplayFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::KhrDisplayFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - display_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrDisplayFn::name() + Self { handle, fp } } #[doc = ""] @@ -32,7 +26,7 @@ impl Display { physical_device: vk::PhysicalDevice, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.display_fn + self.fp .get_physical_device_display_properties_khr(physical_device, count, data) }) } @@ -43,7 +37,7 @@ impl Display { physical_device: vk::PhysicalDevice, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.display_fn + self.fp .get_physical_device_display_plane_properties_khr(physical_device, count, data) }) } @@ -55,7 +49,7 @@ impl Display { plane_index: u32, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.display_fn.get_display_plane_supported_displays_khr( + self.fp.get_display_plane_supported_displays_khr( physical_device, plane_index, count, @@ -71,7 +65,7 @@ impl Display { display: vk::DisplayKHR, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.display_fn + self.fp .get_display_mode_properties_khr(physical_device, display, count, data) }) } @@ -85,7 +79,7 @@ impl Display { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut display_mode = mem::MaybeUninit::zeroed(); - self.display_fn + self.fp .create_display_mode_khr( physical_device, display, @@ -104,7 +98,7 @@ impl Display { plane_index: u32, ) -> VkResult { let mut display_plane_capabilities = mem::MaybeUninit::zeroed(); - self.display_fn + self.fp .get_display_plane_capabilities_khr( physical_device, mode, @@ -121,7 +115,7 @@ impl Display { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::MaybeUninit::zeroed(); - self.display_fn + self.fp .create_display_plane_surface_khr( self.handle, create_info, @@ -131,8 +125,12 @@ impl Display { .result_with_success(surface.assume_init()) } + pub fn name() -> &'static CStr { + vk::KhrDisplayFn::name() + } + pub fn fp(&self) -> &vk::KhrDisplayFn { - &self.display_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/khr/display_swapchain.rs b/ash/src/extensions/khr/display_swapchain.rs index ef8b975..588d01d 100755 --- a/ash/src/extensions/khr/display_swapchain.rs +++ b/ash/src/extensions/khr/display_swapchain.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct DisplaySwapchain { handle: vk::Device, - swapchain_fn: vk::KhrDisplaySwapchainFn, + fp: vk::KhrDisplaySwapchainFn, } impl DisplaySwapchain { pub fn new(instance: &Instance, device: &Device) -> Self { - let swapchain_fn = vk::KhrDisplaySwapchainFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrDisplaySwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - swapchain_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrDisplaySwapchainFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl DisplaySwapchain { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult> { let mut swapchains = Vec::with_capacity(create_infos.len()); - let err_code = self.swapchain_fn.create_shared_swapchains_khr( + let err_code = self.fp.create_shared_swapchains_khr( self.handle, create_infos.len() as u32, create_infos.as_ptr(), @@ -44,8 +38,12 @@ impl DisplaySwapchain { err_code.result_with_success(swapchains) } + pub fn name() -> &'static CStr { + vk::KhrDisplaySwapchainFn::name() + } + pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn { - &self.swapchain_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/draw_indirect_count.rs b/ash/src/extensions/khr/draw_indirect_count.rs index 2aa325a..133eb74 100644 --- a/ash/src/extensions/khr/draw_indirect_count.rs +++ b/ash/src/extensions/khr/draw_indirect_count.rs @@ -5,23 +5,15 @@ use std::mem; #[derive(Clone)] pub struct DrawIndirectCount { - handle: vk::Device, - draw_indirect_count_fn: vk::KhrDrawIndirectCountFn, + fp: vk::KhrDrawIndirectCountFn, } impl DrawIndirectCount { pub fn new(instance: &Instance, device: &Device) -> Self { - let draw_indirect_count_fn = vk::KhrDrawIndirectCountFn::load(|name| unsafe { + let fp = vk::KhrDrawIndirectCountFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); - Self { - handle: device.handle(), - draw_indirect_count_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrDrawIndirectCountFn::name() + Self { fp } } #[doc = ""] @@ -35,16 +27,15 @@ impl DrawIndirectCount { max_draw_count: u32, stride: u32, ) { - self.draw_indirect_count_fn - .cmd_draw_indexed_indirect_count_khr( - command_buffer, - buffer, - offset, - count_buffer, - count_buffer_offset, - max_draw_count, - stride, - ); + self.fp.cmd_draw_indexed_indirect_count_khr( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); } #[doc = ""] @@ -58,15 +49,22 @@ impl DrawIndirectCount { max_draw_count: u32, stride: u32, ) { - self.draw_indirect_count_fn - .cmd_draw_indexed_indirect_count_khr( - command_buffer, - buffer, - offset, - count_buffer, - count_buffer_offset, - max_draw_count, - stride, - ); + self.fp.cmd_draw_indexed_indirect_count_khr( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + pub fn name() -> &'static CStr { + vk::KhrDrawIndirectCountFn::name() + } + + pub fn fp(&self) -> &vk::KhrDrawIndirectCountFn { + &self.fp } } diff --git a/ash/src/extensions/khr/dynamic_rendering.rs b/ash/src/extensions/khr/dynamic_rendering.rs index 57925f2..983a145 100644 --- a/ash/src/extensions/khr/dynamic_rendering.rs +++ b/ash/src/extensions/khr/dynamic_rendering.rs @@ -5,25 +5,15 @@ use std::mem; #[derive(Clone)] pub struct DynamicRendering { - fns: vk::KhrDynamicRenderingFn, + fp: vk::KhrDynamicRenderingFn, } impl DynamicRendering { pub fn new(instance: &Instance, device: &Device) -> Self { - let dynamic_rendering_fn = vk::KhrDynamicRenderingFn::load(|name| unsafe { + let fp = vk::KhrDynamicRenderingFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); - Self { - fns: dynamic_rendering_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrDynamicRenderingFn::name() - } - - pub fn fp(&self) -> &vk::KhrDynamicRenderingFn { - &self.fns + Self { fp } } #[doc = ""] @@ -32,12 +22,20 @@ impl DynamicRendering { command_buffer: vk::CommandBuffer, rendering_info: &vk::RenderingInfoKHR, ) { - self.fns + self.fp .cmd_begin_rendering_khr(command_buffer, rendering_info) } #[doc = ""] pub unsafe fn cmd_end_rendering(&self, command_buffer: vk::CommandBuffer) { - self.fns.cmd_end_rendering_khr(command_buffer) + self.fp.cmd_end_rendering_khr(command_buffer) + } + + pub fn name() -> &'static CStr { + vk::KhrDynamicRenderingFn::name() + } + + pub fn fp(&self) -> &vk::KhrDynamicRenderingFn { + &self.fp } } diff --git a/ash/src/extensions/khr/external_fence_fd.rs b/ash/src/extensions/khr/external_fence_fd.rs index 246cc7e..a243e4f 100644 --- a/ash/src/extensions/khr/external_fence_fd.rs +++ b/ash/src/extensions/khr/external_fence_fd.rs @@ -7,27 +7,21 @@ use std::mem; #[derive(Clone)] pub struct ExternalFenceFd { handle: vk::Device, - external_fence_fd_fn: vk::KhrExternalFenceFdFn, + fp: vk::KhrExternalFenceFdFn, } impl ExternalFenceFd { pub fn new(instance: &Instance, device: &Device) -> Self { - let external_fence_fd_fn = vk::KhrExternalFenceFdFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrExternalFenceFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - external_fence_fd_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrExternalFenceFdFn::name() + Self { handle, fp } } #[doc = ""] pub unsafe fn import_fence_fd(&self, import_info: &vk::ImportFenceFdInfoKHR) -> VkResult<()> { - self.external_fence_fd_fn + self.fp .import_fence_fd_khr(self.handle, import_info) .result() } @@ -35,14 +29,17 @@ impl ExternalFenceFd { #[doc = ""] pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR) -> VkResult { let mut fd = -1; - - self.external_fence_fd_fn + self.fp .get_fence_fd_khr(self.handle, get_info, &mut fd) .result_with_success(fd) } + pub fn name() -> &'static CStr { + vk::KhrExternalFenceFdFn::name() + } + pub fn fp(&self) -> &vk::KhrExternalFenceFdFn { - &self.external_fence_fd_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/external_memory_fd.rs b/ash/src/extensions/khr/external_memory_fd.rs index 7eeaa3e..1f752a5 100644 --- a/ash/src/extensions/khr/external_memory_fd.rs +++ b/ash/src/extensions/khr/external_memory_fd.rs @@ -7,29 +7,22 @@ use std::mem; #[derive(Clone)] pub struct ExternalMemoryFd { handle: vk::Device, - external_memory_fd_fn: vk::KhrExternalMemoryFdFn, + fp: vk::KhrExternalMemoryFdFn, } impl ExternalMemoryFd { pub fn new(instance: &Instance, device: &Device) -> Self { - let external_memory_fd_fn = vk::KhrExternalMemoryFdFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrExternalMemoryFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - external_memory_fd_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrExternalMemoryFdFn::name() + Self { handle, fp } } #[doc = ""] pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult { let mut fd = -1; - - self.external_memory_fd_fn + self.fp .get_memory_fd_khr(self.handle, create_info, &mut fd) .result_with_success(fd) } @@ -41,13 +34,17 @@ impl ExternalMemoryFd { fd: i32, ) -> VkResult { let mut memory_fd_properties = Default::default(); - self.external_memory_fd_fn + self.fp .get_memory_fd_properties_khr(self.handle, handle_type, fd, &mut memory_fd_properties) .result_with_success(memory_fd_properties) } + pub fn name() -> &'static CStr { + vk::KhrExternalMemoryFdFn::name() + } + pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn { - &self.external_memory_fd_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/external_semaphore_fd.rs b/ash/src/extensions/khr/external_semaphore_fd.rs index 6d99201..1a7e45e 100644 --- a/ash/src/extensions/khr/external_semaphore_fd.rs +++ b/ash/src/extensions/khr/external_semaphore_fd.rs @@ -7,22 +7,16 @@ use std::mem; #[derive(Clone)] pub struct ExternalSemaphoreFd { handle: vk::Device, - external_semaphore_fd_fn: vk::KhrExternalSemaphoreFdFn, + fp: vk::KhrExternalSemaphoreFdFn, } impl ExternalSemaphoreFd { pub fn new(instance: &Instance, device: &Device) -> Self { - let external_semaphore_fd_fn = vk::KhrExternalSemaphoreFdFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrExternalSemaphoreFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - external_semaphore_fd_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrExternalSemaphoreFdFn::name() + Self { handle, fp } } #[doc = ""] @@ -30,7 +24,7 @@ impl ExternalSemaphoreFd { &self, import_info: &vk::ImportSemaphoreFdInfoKHR, ) -> VkResult<()> { - self.external_semaphore_fd_fn + self.fp .import_semaphore_fd_khr(self.handle, import_info) .result() } @@ -38,14 +32,17 @@ impl ExternalSemaphoreFd { #[doc = ""] pub unsafe fn get_semaphore_fd(&self, get_info: &vk::SemaphoreGetFdInfoKHR) -> VkResult { let mut fd = -1; - - self.external_semaphore_fd_fn + self.fp .get_semaphore_fd_khr(self.handle, get_info, &mut fd) .result_with_success(fd) } + pub fn name() -> &'static CStr { + vk::KhrExternalSemaphoreFdFn::name() + } + pub fn fp(&self) -> &vk::KhrExternalSemaphoreFdFn { - &self.external_semaphore_fd_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/get_memory_requirements2.rs b/ash/src/extensions/khr/get_memory_requirements2.rs index 6cb8f53..dc15119 100644 --- a/ash/src/extensions/khr/get_memory_requirements2.rs +++ b/ash/src/extensions/khr/get_memory_requirements2.rs @@ -7,22 +7,16 @@ use std::ptr; #[derive(Clone)] pub struct GetMemoryRequirements2 { handle: vk::Device, - get_memory_requirements2_fn: vk::KhrGetMemoryRequirements2Fn, + fp: vk::KhrGetMemoryRequirements2Fn, } impl GetMemoryRequirements2 { pub fn new(instance: &Instance, device: &Device) -> Self { - let get_memory_requirements2_fn = vk::KhrGetMemoryRequirements2Fn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrGetMemoryRequirements2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - get_memory_requirements2_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrGetMemoryRequirements2Fn::name() + Self { handle, fp } } #[doc = ""] @@ -31,7 +25,7 @@ impl GetMemoryRequirements2 { info: &vk::BufferMemoryRequirementsInfo2KHR, memory_requirements: &mut vk::MemoryRequirements2KHR, ) { - self.get_memory_requirements2_fn + self.fp .get_buffer_memory_requirements2_khr(self.handle, info, memory_requirements); } @@ -41,7 +35,7 @@ impl GetMemoryRequirements2 { info: &vk::ImageMemoryRequirementsInfo2KHR, memory_requirements: &mut vk::MemoryRequirements2KHR, ) { - self.get_memory_requirements2_fn + self.fp .get_image_memory_requirements2_khr(self.handle, info, memory_requirements); } @@ -51,13 +45,12 @@ impl GetMemoryRequirements2 { info: &vk::ImageSparseMemoryRequirementsInfo2KHR, ) -> usize { let mut count = 0; - self.get_memory_requirements2_fn - .get_image_sparse_memory_requirements2_khr( - self.handle, - info, - &mut count, - ptr::null_mut(), - ); + self.fp.get_image_sparse_memory_requirements2_khr( + self.handle, + info, + &mut count, + ptr::null_mut(), + ); count as usize } @@ -71,17 +64,20 @@ impl GetMemoryRequirements2 { out: &mut [vk::SparseImageMemoryRequirements2KHR], ) { let mut count = out.len() as u32; - self.get_memory_requirements2_fn - .get_image_sparse_memory_requirements2_khr( - self.handle, - info, - &mut count, - out.as_mut_ptr(), - ); + self.fp.get_image_sparse_memory_requirements2_khr( + self.handle, + info, + &mut count, + out.as_mut_ptr(), + ); + } + + pub fn name() -> &'static CStr { + vk::KhrGetMemoryRequirements2Fn::name() } pub fn fp(&self) -> &vk::KhrGetMemoryRequirements2Fn { - &self.get_memory_requirements2_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/get_physical_device_properties2.rs b/ash/src/extensions/khr/get_physical_device_properties2.rs index 6473b5a..268d67d 100644 --- a/ash/src/extensions/khr/get_physical_device_properties2.rs +++ b/ash/src/extensions/khr/get_physical_device_properties2.rs @@ -7,24 +7,15 @@ use std::ptr; #[derive(Clone)] pub struct GetPhysicalDeviceProperties2 { - handle: vk::Instance, - get_physical_device_properties2_fn: vk::KhrGetPhysicalDeviceProperties2Fn, + fp: vk::KhrGetPhysicalDeviceProperties2Fn, } impl GetPhysicalDeviceProperties2 { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let get_physical_device_properties2_fn = - vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) - }); - Self { - handle: instance.handle(), - get_physical_device_properties2_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrGetPhysicalDeviceProperties2Fn::name() + let fp = vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } } #[doc = ""] @@ -33,7 +24,7 @@ impl GetPhysicalDeviceProperties2 { physical_device: vk::PhysicalDevice, features: &mut vk::PhysicalDeviceFeatures2KHR, ) { - self.get_physical_device_properties2_fn + self.fp .get_physical_device_features2_khr(physical_device, features); } @@ -44,8 +35,11 @@ impl GetPhysicalDeviceProperties2 { format: vk::Format, format_properties: &mut vk::FormatProperties2KHR, ) { - self.get_physical_device_properties2_fn - .get_physical_device_format_properties2_khr(physical_device, format, format_properties); + self.fp.get_physical_device_format_properties2_khr( + physical_device, + format, + format_properties, + ); } #[doc = ""] @@ -55,7 +49,7 @@ impl GetPhysicalDeviceProperties2 { image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR, image_format_properties: &mut vk::ImageFormatProperties2KHR, ) -> VkResult<()> { - self.get_physical_device_properties2_fn + self.fp .get_physical_device_image_format_properties2_khr( physical_device, image_format_info, @@ -70,7 +64,7 @@ impl GetPhysicalDeviceProperties2 { physical_device: vk::PhysicalDevice, memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR, ) { - self.get_physical_device_properties2_fn + self.fp .get_physical_device_memory_properties2_khr(physical_device, memory_properties); } @@ -80,7 +74,7 @@ impl GetPhysicalDeviceProperties2 { physical_device: vk::PhysicalDevice, properties: &mut vk::PhysicalDeviceProperties2KHR, ) { - self.get_physical_device_properties2_fn + self.fp .get_physical_device_properties2_khr(physical_device, properties); } @@ -90,12 +84,11 @@ impl GetPhysicalDeviceProperties2 { physical_device: vk::PhysicalDevice, ) -> usize { let mut count = 0; - self.get_physical_device_properties2_fn - .get_physical_device_queue_family_properties2_khr( - physical_device, - &mut count, - ptr::null_mut(), - ); + self.fp.get_physical_device_queue_family_properties2_khr( + physical_device, + &mut count, + ptr::null_mut(), + ); count as usize } @@ -109,12 +102,11 @@ impl GetPhysicalDeviceProperties2 { out: &mut [vk::QueueFamilyProperties2KHR], ) { let mut count = out.len() as u32; - self.get_physical_device_properties2_fn - .get_physical_device_queue_family_properties2_khr( - physical_device, - &mut count, - out.as_mut_ptr(), - ); + self.fp.get_physical_device_queue_family_properties2_khr( + physical_device, + &mut count, + out.as_mut_ptr(), + ); } /// Retrieve the number of elements to pass to [`Self::get_physical_device_sparse_image_format_properties2()`] @@ -124,7 +116,7 @@ impl GetPhysicalDeviceProperties2 { format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, ) -> usize { let mut count = 0; - self.get_physical_device_properties2_fn + self.fp .get_physical_device_sparse_image_format_properties2_khr( physical_device, format_info, @@ -145,7 +137,7 @@ impl GetPhysicalDeviceProperties2 { out: &mut [vk::SparseImageFormatProperties2KHR], ) { let mut count = out.len() as u32; - self.get_physical_device_properties2_fn + self.fp .get_physical_device_sparse_image_format_properties2_khr( physical_device, format_info, @@ -154,11 +146,11 @@ impl GetPhysicalDeviceProperties2 { ); } - pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn { - &self.get_physical_device_properties2_fn + pub fn name() -> &'static CStr { + vk::KhrGetPhysicalDeviceProperties2Fn::name() } - pub fn instance(&self) -> vk::Instance { - self.handle + pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn { + &self.fp } } diff --git a/ash/src/extensions/khr/maintenance1.rs b/ash/src/extensions/khr/maintenance1.rs index cea9709..058dfab 100644 --- a/ash/src/extensions/khr/maintenance1.rs +++ b/ash/src/extensions/khr/maintenance1.rs @@ -6,22 +6,16 @@ use std::mem; #[derive(Clone)] pub struct Maintenance1 { handle: vk::Device, - fns: vk::KhrMaintenance1Fn, + fp: vk::KhrMaintenance1Fn, } impl Maintenance1 { pub fn new(instance: &Instance, device: &Device) -> Self { - let fns = vk::KhrMaintenance1Fn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrMaintenance1Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - fns, - } - } - - pub fn name() -> &'static CStr { - vk::KhrMaintenance1Fn::name() + Self { handle, fp } } #[doc = ""] @@ -30,12 +24,16 @@ impl Maintenance1 { command_pool: vk::CommandPool, flags: vk::CommandPoolTrimFlagsKHR, ) { - self.fns + self.fp .trim_command_pool_khr(self.handle, command_pool, flags); } + pub fn name() -> &'static CStr { + vk::KhrMaintenance1Fn::name() + } + pub fn fp(&self) -> &vk::KhrMaintenance1Fn { - &self.fns + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/maintenance3.rs b/ash/src/extensions/khr/maintenance3.rs index 4d8d72d..5028b05 100644 --- a/ash/src/extensions/khr/maintenance3.rs +++ b/ash/src/extensions/khr/maintenance3.rs @@ -6,22 +6,16 @@ use std::mem; #[derive(Clone)] pub struct Maintenance3 { handle: vk::Device, - fns: vk::KhrMaintenance3Fn, + fp: vk::KhrMaintenance3Fn, } impl Maintenance3 { pub fn new(instance: &Instance, device: &Device) -> Self { - let fns = vk::KhrMaintenance3Fn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrMaintenance3Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - fns, - } - } - - pub fn name() -> &'static CStr { - vk::KhrMaintenance3Fn::name() + Self { handle, fp } } #[doc = ""] @@ -30,12 +24,16 @@ impl Maintenance3 { create_info: &vk::DescriptorSetLayoutCreateInfo, out: &mut vk::DescriptorSetLayoutSupportKHR, ) { - self.fns + self.fp .get_descriptor_set_layout_support_khr(self.handle, create_info, out); } + pub fn name() -> &'static CStr { + vk::KhrMaintenance3Fn::name() + } + pub fn fp(&self) -> &vk::KhrMaintenance3Fn { - &self.fns + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/maintenance4.rs b/ash/src/extensions/khr/maintenance4.rs index acdcaa9..5f234e0 100644 --- a/ash/src/extensions/khr/maintenance4.rs +++ b/ash/src/extensions/khr/maintenance4.rs @@ -6,18 +6,16 @@ use std::mem; #[derive(Clone)] pub struct Maintenance4 { handle: vk::Device, - fns: vk::KhrMaintenance4Fn, + fp: vk::KhrMaintenance4Fn, } impl Maintenance4 { pub fn new(instance: &Instance, device: &Device) -> Self { - let fns = vk::KhrMaintenance4Fn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrMaintenance4Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - fns, - } + Self { handle, fp } } #[doc = ""] @@ -26,7 +24,7 @@ impl Maintenance4 { create_info: &vk::DeviceBufferMemoryRequirementsKHR, out: &mut vk::MemoryRequirements2, ) { - self.fns + self.fp .get_device_buffer_memory_requirements_khr(self.handle, create_info, out) } @@ -36,7 +34,7 @@ impl Maintenance4 { create_info: &vk::DeviceImageMemoryRequirementsKHR, out: &mut vk::MemoryRequirements2, ) { - self.fns + self.fp .get_device_image_memory_requirements_khr(self.handle, create_info, out) } @@ -46,7 +44,7 @@ impl Maintenance4 { create_info: &vk::DeviceImageMemoryRequirementsKHR, ) -> usize { let mut count = 0; - self.fns.get_device_image_sparse_memory_requirements_khr( + self.fp.get_device_image_sparse_memory_requirements_khr( self.handle, create_info, &mut count, @@ -65,7 +63,7 @@ impl Maintenance4 { out: &mut [vk::SparseImageMemoryRequirements2], ) { let mut count = out.len() as u32; - self.fns.get_device_image_sparse_memory_requirements_khr( + self.fp.get_device_image_sparse_memory_requirements_khr( self.handle, create_info, &mut count, @@ -79,7 +77,7 @@ impl Maintenance4 { } pub fn fp(&self) -> &vk::KhrMaintenance4Fn { - &self.fns + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/pipeline_executable_properties.rs b/ash/src/extensions/khr/pipeline_executable_properties.rs index 5dbd060..3c4f459 100644 --- a/ash/src/extensions/khr/pipeline_executable_properties.rs +++ b/ash/src/extensions/khr/pipeline_executable_properties.rs @@ -7,23 +7,16 @@ use std::mem; #[derive(Clone)] pub struct PipelineExecutableProperties { handle: vk::Device, - pipeline_executable_properties_fn: vk::KhrPipelineExecutablePropertiesFn, + fp: vk::KhrPipelineExecutablePropertiesFn, } impl PipelineExecutableProperties { pub fn new(instance: &Instance, device: &Device) -> Self { - let pipeline_executable_properties_fn = - vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) - }); - Self { - handle: device.handle(), - pipeline_executable_properties_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrPipelineExecutablePropertiesFn::name() + let handle = device.handle(); + let fp = vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } } #[doc = ""] @@ -32,7 +25,7 @@ impl PipelineExecutableProperties { executable_info: &vk::PipelineExecutableInfoKHR, ) -> VkResult> { read_into_defaulted_vector(|count, data| { - self.pipeline_executable_properties_fn + self.fp .get_pipeline_executable_internal_representations_khr( self.handle, executable_info, @@ -45,11 +38,10 @@ impl PipelineExecutableProperties { #[doc = ""] pub unsafe fn get_pipeline_executable_properties( &self, - pipeline_info: &vk::PipelineInfoKHR, ) -> VkResult> { read_into_defaulted_vector(|count, data| { - self.pipeline_executable_properties_fn + self.fp .get_pipeline_executable_properties_khr(self.handle, pipeline_info, count, data) }) } @@ -57,17 +49,24 @@ impl PipelineExecutableProperties { #[doc = ""] pub unsafe fn get_pipeline_executable_statistics( &self, - executable_info: &vk::PipelineExecutableInfoKHR, ) -> VkResult> { read_into_defaulted_vector(|count, data| { - self.pipeline_executable_properties_fn - .get_pipeline_executable_statistics_khr(self.handle, executable_info, count, data) + self.fp.get_pipeline_executable_statistics_khr( + self.handle, + executable_info, + count, + data, + ) }) } + pub fn name() -> &'static CStr { + vk::KhrPipelineExecutablePropertiesFn::name() + } + pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn { - &self.pipeline_executable_properties_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/present_wait.rs b/ash/src/extensions/khr/present_wait.rs index bcdc70a..2d7a9c5 100644 --- a/ash/src/extensions/khr/present_wait.rs +++ b/ash/src/extensions/khr/present_wait.rs @@ -7,16 +7,16 @@ use std::mem; #[derive(Clone)] pub struct PresentWait { handle: vk::Device, - fns: vk::KhrPresentWaitFn, + fp: vk::KhrPresentWaitFn, } impl PresentWait { pub fn new(instance: &Instance, device: &Device) -> Self { let handle = device.handle(); - let fns = vk::KhrPresentWaitFn::load(|name| unsafe { + let fp = vk::KhrPresentWaitFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { handle, fns } + Self { handle, fp } } #[doc = ""] @@ -26,7 +26,7 @@ impl PresentWait { present_id: u64, timeout: u64, ) -> VkResult<()> { - self.fns + self.fp .wait_for_present_khr(self.handle, swapchain, present_id, timeout) .result() } @@ -36,7 +36,7 @@ impl PresentWait { } pub fn fp(&self) -> &vk::KhrPresentWaitFn { - &self.fns + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/push_descriptor.rs b/ash/src/extensions/khr/push_descriptor.rs index eb90c97..e4d700f 100644 --- a/ash/src/extensions/khr/push_descriptor.rs +++ b/ash/src/extensions/khr/push_descriptor.rs @@ -6,23 +6,15 @@ use std::mem; #[derive(Clone)] pub struct PushDescriptor { - handle: vk::Instance, - push_descriptors_fn: vk::KhrPushDescriptorFn, + fp: vk::KhrPushDescriptorFn, } impl PushDescriptor { pub fn new(instance: &Instance, device: &Device) -> Self { - let push_descriptors_fn = vk::KhrPushDescriptorFn::load(|name| unsafe { + let fp = vk::KhrPushDescriptorFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); - Self { - handle: instance.handle(), - push_descriptors_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrPushDescriptorFn::name() + Self { fp } } #[doc = ""] @@ -34,7 +26,7 @@ impl PushDescriptor { set: u32, descriptor_writes: &[vk::WriteDescriptorSet], ) { - self.push_descriptors_fn.cmd_push_descriptor_set_khr( + self.fp.cmd_push_descriptor_set_khr( command_buffer, pipeline_bind_point, layout, @@ -53,21 +45,20 @@ impl PushDescriptor { set: u32, p_data: *const c_void, ) { - self.push_descriptors_fn - .cmd_push_descriptor_set_with_template_khr( - command_buffer, - descriptor_update_template, - layout, - set, - p_data, - ); + self.fp.cmd_push_descriptor_set_with_template_khr( + command_buffer, + descriptor_update_template, + layout, + set, + p_data, + ); + } + + pub fn name() -> &'static CStr { + vk::KhrPushDescriptorFn::name() } pub fn fp(&self) -> &vk::KhrPushDescriptorFn { - &self.push_descriptors_fn - } - - pub fn instance(&self) -> vk::Instance { - self.handle + &self.fp } } diff --git a/ash/src/extensions/khr/ray_tracing_pipeline.rs b/ash/src/extensions/khr/ray_tracing_pipeline.rs index 97edad7..dc5bc8a 100644 --- a/ash/src/extensions/khr/ray_tracing_pipeline.rs +++ b/ash/src/extensions/khr/ray_tracing_pipeline.rs @@ -8,18 +8,16 @@ use std::mem; #[derive(Clone)] pub struct RayTracingPipeline { handle: vk::Device, - ray_tracing_fn: vk::KhrRayTracingPipelineFn, + fp: vk::KhrRayTracingPipelineFn, } impl RayTracingPipeline { pub fn new(instance: &Instance, device: &Device) -> Self { - let ray_tracing_fn = vk::KhrRayTracingPipelineFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrRayTracingPipelineFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - ray_tracing_fn, - } + Self { handle, fp } } pub unsafe fn get_properties( @@ -46,7 +44,7 @@ impl RayTracingPipeline { height: u32, depth: u32, ) { - self.ray_tracing_fn.cmd_trace_rays_khr( + self.fp.cmd_trace_rays_khr( command_buffer, raygen_shader_binding_tables as *const _, miss_shader_binding_tables as *const _, @@ -67,7 +65,7 @@ impl RayTracingPipeline { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult> { let mut pipelines = vec![mem::zeroed(); create_info.len()]; - self.ray_tracing_fn + self.fp .create_ray_tracing_pipelines_khr( self.handle, deferred_operation, @@ -89,16 +87,14 @@ impl RayTracingPipeline { data_size: usize, ) -> VkResult> { let mut data = Vec::::with_capacity(data_size); - let err_code = self - .ray_tracing_fn - .get_ray_tracing_shader_group_handles_khr( - self.handle, - pipeline, - first_group, - group_count, - data_size, - data.as_mut_ptr() as *mut std::ffi::c_void, - ); + let err_code = self.fp.get_ray_tracing_shader_group_handles_khr( + self.handle, + pipeline, + first_group, + group_count, + data_size, + data.as_mut_ptr() as *mut std::ffi::c_void, + ); data.set_len(data_size); err_code.result_with_success(data) } @@ -113,7 +109,7 @@ impl RayTracingPipeline { ) -> VkResult> { let mut data: Vec = Vec::with_capacity(data_size); - self.ray_tracing_fn + self.fp .get_ray_tracing_capture_replay_shader_group_handles_khr( self.handle, pipeline, @@ -135,7 +131,7 @@ impl RayTracingPipeline { callable_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], indirect_device_address: vk::DeviceAddress, ) { - self.ray_tracing_fn.cmd_trace_rays_indirect_khr( + self.fp.cmd_trace_rays_indirect_khr( command_buffer, raygen_shader_binding_table.as_ptr(), miss_shader_binding_table.as_ptr(), @@ -152,8 +148,12 @@ impl RayTracingPipeline { group: u32, group_shader: vk::ShaderGroupShaderKHR, ) -> vk::DeviceSize { - self.ray_tracing_fn - .get_ray_tracing_shader_group_stack_size_khr(self.handle, pipeline, group, group_shader) + self.fp.get_ray_tracing_shader_group_stack_size_khr( + self.handle, + pipeline, + group, + group_shader, + ) } #[doc = ""] @@ -162,7 +162,7 @@ impl RayTracingPipeline { command_buffer: vk::CommandBuffer, pipeline_stack_size: u32, ) { - self.ray_tracing_fn + self.fp .cmd_set_ray_tracing_pipeline_stack_size_khr(command_buffer, pipeline_stack_size); } @@ -171,7 +171,7 @@ impl RayTracingPipeline { } pub fn fp(&self) -> &vk::KhrRayTracingPipelineFn { - &self.ray_tracing_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/surface.rs b/ash/src/extensions/khr/surface.rs index d5607cd..7e4fd3d 100755 --- a/ash/src/extensions/khr/surface.rs +++ b/ash/src/extensions/khr/surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct Surface { handle: vk::Instance, - surface_fn: vk::KhrSurfaceFn, + fp: vk::KhrSurfaceFn, } impl Surface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::KhrSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::KhrSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -34,7 +28,7 @@ impl Surface { surface: vk::SurfaceKHR, ) -> VkResult { let mut b = 0; - self.surface_fn + self.fp .get_physical_device_surface_support_khr( physical_device, queue_family_index, @@ -51,13 +45,12 @@ impl Surface { surface: vk::SurfaceKHR, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.surface_fn - .get_physical_device_surface_present_modes_khr( - physical_device, - surface, - count, - data, - ) + self.fp.get_physical_device_surface_present_modes_khr( + physical_device, + surface, + count, + data, + ) }) } @@ -68,7 +61,7 @@ impl Surface { surface: vk::SurfaceKHR, ) -> VkResult { let mut surface_capabilities = mem::zeroed(); - self.surface_fn + self.fp .get_physical_device_surface_capabilities_khr( physical_device, surface, @@ -84,12 +77,8 @@ impl Surface { surface: vk::SurfaceKHR, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.surface_fn.get_physical_device_surface_formats_khr( - physical_device, - surface, - count, - data, - ) + self.fp + .get_physical_device_surface_formats_khr(physical_device, surface, count, data) }) } @@ -99,15 +88,16 @@ impl Surface { surface: vk::SurfaceKHR, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.surface_fn.destroy_surface_khr( - self.handle, - surface, - allocation_callbacks.as_raw_ptr(), - ); + self.fp + .destroy_surface_khr(self.handle, surface, allocation_callbacks.as_raw_ptr()); + } + + pub fn name() -> &'static CStr { + vk::KhrSurfaceFn::name() } pub fn fp(&self) -> &vk::KhrSurfaceFn { - &self.surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/khr/swapchain.rs b/ash/src/extensions/khr/swapchain.rs index 9fa86a6..682ff04 100755 --- a/ash/src/extensions/khr/swapchain.rs +++ b/ash/src/extensions/khr/swapchain.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct Swapchain { handle: vk::Device, - swapchain_fn: vk::KhrSwapchainFn, + fp: vk::KhrSwapchainFn, } impl Swapchain { pub fn new(instance: &Instance, device: &Device) -> Self { - let swapchain_fn = vk::KhrSwapchainFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrSwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - swapchain_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrSwapchainFn::name() + Self { handle, fp } } #[doc = ""] @@ -32,11 +26,8 @@ impl Swapchain { swapchain: vk::SwapchainKHR, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.swapchain_fn.destroy_swapchain_khr( - self.handle, - swapchain, - allocation_callbacks.as_raw_ptr(), - ); + self.fp + .destroy_swapchain_khr(self.handle, swapchain, allocation_callbacks.as_raw_ptr()); } /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. @@ -49,7 +40,7 @@ impl Swapchain { fence: vk::Fence, ) -> VkResult<(u32, bool)> { let mut index = 0; - let err_code = self.swapchain_fn.acquire_next_image_khr( + let err_code = self.fp.acquire_next_image_khr( self.handle, swapchain, timeout, @@ -71,7 +62,7 @@ impl Swapchain { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut swapchain = mem::zeroed(); - self.swapchain_fn + self.fp .create_swapchain_khr( self.handle, create_info, @@ -86,9 +77,9 @@ impl Swapchain { pub unsafe fn queue_present( &self, queue: vk::Queue, - create_info: &vk::PresentInfoKHR, + present_info: &vk::PresentInfoKHR, ) -> VkResult { - let err_code = self.swapchain_fn.queue_present_khr(queue, create_info); + let err_code = self.fp.queue_present_khr(queue, present_info); match err_code { vk::Result::SUCCESS => Ok(false), vk::Result::SUBOPTIMAL_KHR => Ok(true), @@ -102,13 +93,17 @@ impl Swapchain { swapchain: vk::SwapchainKHR, ) -> VkResult> { read_into_uninitialized_vector(|count, data| { - self.swapchain_fn + self.fp .get_swapchain_images_khr(self.handle, swapchain, count, data) }) } + pub fn name() -> &'static CStr { + vk::KhrSwapchainFn::name() + } + pub fn fp(&self) -> &vk::KhrSwapchainFn { - &self.swapchain_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/synchronization2.rs b/ash/src/extensions/khr/synchronization2.rs index 4f0d4cd..d53cae6 100644 --- a/ash/src/extensions/khr/synchronization2.rs +++ b/ash/src/extensions/khr/synchronization2.rs @@ -6,31 +6,15 @@ use std::mem; #[derive(Clone)] pub struct Synchronization2 { - handle: vk::Device, - synchronization2_fn: vk::KhrSynchronization2Fn, + fp: vk::KhrSynchronization2Fn, } impl Synchronization2 { pub fn new(instance: &Instance, device: &Device) -> Self { - let synchronization2_fn = vk::KhrSynchronization2Fn::load(|name| unsafe { + let fp = vk::KhrSynchronization2Fn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); - Self { - handle: device.handle(), - synchronization2_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrSynchronization2Fn::name() - } - - pub fn fp(&self) -> &vk::KhrSynchronization2Fn { - &self.synchronization2_fn - } - - pub fn device(&self) -> vk::Device { - self.handle + Self { fp } } #[doc = ""] @@ -39,7 +23,7 @@ impl Synchronization2 { command_buffer: vk::CommandBuffer, dependency_info: &vk::DependencyInfoKHR, ) { - self.synchronization2_fn + self.fp .cmd_pipeline_barrier2_khr(command_buffer, dependency_info) } @@ -50,7 +34,7 @@ impl Synchronization2 { event: vk::Event, stage_mask: vk::PipelineStageFlags2KHR, ) { - self.synchronization2_fn + self.fp .cmd_reset_event2_khr(command_buffer, event, stage_mask) } @@ -61,7 +45,7 @@ impl Synchronization2 { event: vk::Event, dependency_info: &vk::DependencyInfoKHR, ) { - self.synchronization2_fn + self.fp .cmd_set_event2_khr(command_buffer, event, dependency_info) } @@ -73,7 +57,7 @@ impl Synchronization2 { dependency_infos: &[vk::DependencyInfoKHR], ) { assert_eq!(events.len(), dependency_infos.len()); - self.synchronization2_fn.cmd_wait_events2_khr( + self.fp.cmd_wait_events2_khr( command_buffer, events.len() as u32, events.as_ptr(), @@ -89,7 +73,7 @@ impl Synchronization2 { query_pool: vk::QueryPool, query: u32, ) { - self.synchronization2_fn + self.fp .cmd_write_timestamp2_khr(command_buffer, stage, query_pool, query) } @@ -100,8 +84,16 @@ impl Synchronization2 { submits: &[vk::SubmitInfo2KHR], fence: vk::Fence, ) -> VkResult<()> { - self.synchronization2_fn + self.fp .queue_submit2_khr(queue, submits.len() as u32, submits.as_ptr(), fence) .result() } + + pub fn name() -> &'static CStr { + vk::KhrSynchronization2Fn::name() + } + + pub fn fp(&self) -> &vk::KhrSynchronization2Fn { + &self.fp + } } diff --git a/ash/src/extensions/khr/timeline_semaphore.rs b/ash/src/extensions/khr/timeline_semaphore.rs index 2bb11b2..5896330 100644 --- a/ash/src/extensions/khr/timeline_semaphore.rs +++ b/ash/src/extensions/khr/timeline_semaphore.rs @@ -7,28 +7,22 @@ use std::mem; #[derive(Clone)] pub struct TimelineSemaphore { handle: vk::Device, - timeline_semaphore_fn: vk::KhrTimelineSemaphoreFn, + fp: vk::KhrTimelineSemaphoreFn, } impl TimelineSemaphore { pub fn new(instance: &Instance, device: &Device) -> Self { - let timeline_semaphore_fn = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - timeline_semaphore_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrTimelineSemaphoreFn::name() + Self { handle, fp } } #[doc = ""] pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult { let mut value = 0; - self.timeline_semaphore_fn + self.fp .get_semaphore_counter_value_khr(self.handle, semaphore, &mut value) .result_with_success(value) } @@ -39,20 +33,24 @@ impl TimelineSemaphore { wait_info: &vk::SemaphoreWaitInfo, timeout: u64, ) -> VkResult<()> { - self.timeline_semaphore_fn + self.fp .wait_semaphores_khr(self.handle, wait_info, timeout) .result() } #[doc = ""] pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> { - self.timeline_semaphore_fn + self.fp .signal_semaphore_khr(self.handle, signal_info) .result() } + pub fn name() -> &'static CStr { + vk::KhrTimelineSemaphoreFn::name() + } + pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn { - &self.timeline_semaphore_fn + &self.fp } pub fn device(&self) -> vk::Device { diff --git a/ash/src/extensions/khr/wayland_surface.rs b/ash/src/extensions/khr/wayland_surface.rs index 241cdea..67848bc 100755 --- a/ash/src/extensions/khr/wayland_surface.rs +++ b/ash/src/extensions/khr/wayland_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct WaylandSurface { handle: vk::Instance, - wayland_surface_fn: vk::KhrWaylandSurfaceFn, + fp: vk::KhrWaylandSurfaceFn, } impl WaylandSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::KhrWaylandSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::KhrWaylandSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - wayland_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrWaylandSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl WaylandSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.wayland_surface_fn + self.fp .create_wayland_surface_khr( self.handle, create_info, @@ -51,7 +45,7 @@ impl WaylandSurface { wl_display: &mut vk::wl_display, ) -> bool { let b = self - .wayland_surface_fn + .fp .get_physical_device_wayland_presentation_support_khr( physical_device, queue_family_index, @@ -61,8 +55,12 @@ impl WaylandSurface { b > 0 } + pub fn name() -> &'static CStr { + vk::KhrWaylandSurfaceFn::name() + } + pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn { - &self.wayland_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/khr/win32_surface.rs b/ash/src/extensions/khr/win32_surface.rs index aef2d44..3713c19 100755 --- a/ash/src/extensions/khr/win32_surface.rs +++ b/ash/src/extensions/khr/win32_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct Win32Surface { handle: vk::Instance, - win32_surface_fn: vk::KhrWin32SurfaceFn, + fp: vk::KhrWin32SurfaceFn, } impl Win32Surface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::KhrWin32SurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - win32_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrWin32SurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl Win32Surface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.win32_surface_fn + self.fp .create_win32_surface_khr( self.handle, create_info, @@ -49,18 +43,20 @@ impl Win32Surface { physical_device: vk::PhysicalDevice, queue_family_index: u32, ) -> bool { - let b = self - .win32_surface_fn - .get_physical_device_win32_presentation_support_khr( - physical_device, - queue_family_index, - ); + let b = self.fp.get_physical_device_win32_presentation_support_khr( + physical_device, + queue_family_index, + ); b > 0 } + pub fn name() -> &'static CStr { + vk::KhrWin32SurfaceFn::name() + } + pub fn fp(&self) -> &vk::KhrWin32SurfaceFn { - &self.win32_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/khr/xcb_surface.rs b/ash/src/extensions/khr/xcb_surface.rs index e538ce6..db30e29 100755 --- a/ash/src/extensions/khr/xcb_surface.rs +++ b/ash/src/extensions/khr/xcb_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct XcbSurface { handle: vk::Instance, - xcb_surface_fn: vk::KhrXcbSurfaceFn, + fp: vk::KhrXcbSurfaceFn, } impl XcbSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::KhrXcbSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - xcb_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrXcbSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl XcbSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.xcb_surface_fn + self.fp .create_xcb_surface_khr( self.handle, create_info, @@ -51,20 +45,22 @@ impl XcbSurface { connection: &mut vk::xcb_connection_t, visual_id: vk::xcb_visualid_t, ) -> bool { - let b = self - .xcb_surface_fn - .get_physical_device_xcb_presentation_support_khr( - physical_device, - queue_family_index, - connection, - visual_id, - ); + let b = self.fp.get_physical_device_xcb_presentation_support_khr( + physical_device, + queue_family_index, + connection, + visual_id, + ); b > 0 } + pub fn name() -> &'static CStr { + vk::KhrXcbSurfaceFn::name() + } + pub fn fp(&self) -> &vk::KhrXcbSurfaceFn { - &self.xcb_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/khr/xlib_surface.rs b/ash/src/extensions/khr/xlib_surface.rs index 5b0de68..16e4bcc 100755 --- a/ash/src/extensions/khr/xlib_surface.rs +++ b/ash/src/extensions/khr/xlib_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct XlibSurface { handle: vk::Instance, - xlib_surface_fn: vk::KhrXlibSurfaceFn, + fp: vk::KhrXlibSurfaceFn, } impl XlibSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::KhrXlibSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::KhrXlibSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - xlib_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::KhrXlibSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl XlibSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.xlib_surface_fn + self.fp .create_xlib_surface_khr( self.handle, create_info, @@ -51,20 +45,22 @@ impl XlibSurface { display: &mut vk::Display, visual_id: vk::VisualID, ) -> bool { - let b = self - .xlib_surface_fn - .get_physical_device_xlib_presentation_support_khr( - physical_device, - queue_family_index, - display, - visual_id, - ); + let b = self.fp.get_physical_device_xlib_presentation_support_khr( + physical_device, + queue_family_index, + display, + visual_id, + ); b > 0 } + pub fn name() -> &'static CStr { + vk::KhrXlibSurfaceFn::name() + } + pub fn fp(&self) -> &vk::KhrXlibSurfaceFn { - &self.xlib_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/mvk/ios_surface.rs b/ash/src/extensions/mvk/ios_surface.rs index 3b12f3a..3ab7ec8 100755 --- a/ash/src/extensions/mvk/ios_surface.rs +++ b/ash/src/extensions/mvk/ios_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct IOSSurface { handle: vk::Instance, - ios_surface_fn: vk::MvkIosSurfaceFn, + fp: vk::MvkIosSurfaceFn, } impl IOSSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::MvkIosSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::MvkIosSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - ios_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::MvkIosSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl IOSSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.ios_surface_fn + self.fp .create_ios_surface_mvk( self.handle, create_info, @@ -43,8 +37,12 @@ impl IOSSurface { .result_with_success(surface) } + pub fn name() -> &'static CStr { + vk::MvkIosSurfaceFn::name() + } + pub fn fp(&self) -> &vk::MvkIosSurfaceFn { - &self.ios_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/mvk/macos_surface.rs b/ash/src/extensions/mvk/macos_surface.rs index b20e3bb..e916ef6 100755 --- a/ash/src/extensions/mvk/macos_surface.rs +++ b/ash/src/extensions/mvk/macos_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct MacOSSurface { handle: vk::Instance, - macos_surface_fn: vk::MvkMacosSurfaceFn, + fp: vk::MvkMacosSurfaceFn, } impl MacOSSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::MvkMacosSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::MvkMacosSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - macos_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::MvkMacosSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl MacOSSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.macos_surface_fn + self.fp .create_mac_os_surface_mvk( self.handle, create_info, @@ -43,8 +37,12 @@ impl MacOSSurface { .result_with_success(surface) } + pub fn name() -> &'static CStr { + vk::MvkMacosSurfaceFn::name() + } + pub fn fp(&self) -> &vk::MvkMacosSurfaceFn { - &self.macos_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/nn/vi_surface.rs b/ash/src/extensions/nn/vi_surface.rs index 8634d12..03ae975 100644 --- a/ash/src/extensions/nn/vi_surface.rs +++ b/ash/src/extensions/nn/vi_surface.rs @@ -8,22 +8,16 @@ use std::mem; #[derive(Clone)] pub struct ViSurface { handle: vk::Instance, - vi_surface_fn: vk::NnViSurfaceFn, + fp: vk::NnViSurfaceFn, } impl ViSurface { pub fn new(entry: &Entry, instance: &Instance) -> Self { - let surface_fn = vk::NnViSurfaceFn::load(|name| unsafe { - mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + let handle = instance.handle(); + let fp = vk::NnViSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) }); - Self { - handle: instance.handle(), - vi_surface_fn: surface_fn, - } - } - - pub fn name() -> &'static CStr { - vk::NnViSurfaceFn::name() + Self { handle, fp } } #[doc = ""] @@ -33,7 +27,7 @@ impl ViSurface { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut surface = mem::zeroed(); - self.vi_surface_fn + self.fp .create_vi_surface_nn( self.handle, create_info, @@ -43,8 +37,12 @@ impl ViSurface { .result_with_success(surface) } + pub fn name() -> &'static CStr { + vk::NnViSurfaceFn::name() + } + pub fn fp(&self) -> &vk::NnViSurfaceFn { - &self.vi_surface_fn + &self.fp } pub fn instance(&self) -> vk::Instance { diff --git a/ash/src/extensions/nv/device_diagnostic_checkpoints.rs b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs index 8465aba..a55bbde 100644 --- a/ash/src/extensions/nv/device_diagnostic_checkpoints.rs +++ b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs @@ -6,18 +6,15 @@ use std::os::raw::c_void; #[derive(Clone)] pub struct DeviceDiagnosticCheckpoints { - device_diagnostic_checkpoints_fn: vk::NvDeviceDiagnosticCheckpointsFn, + fp: vk::NvDeviceDiagnosticCheckpointsFn, } impl DeviceDiagnosticCheckpoints { pub fn new(instance: &Instance, device: &Device) -> Self { - let device_diagnostic_checkpoints_fn = - vk::NvDeviceDiagnosticCheckpointsFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) - }); - Self { - device_diagnostic_checkpoints_fn, - } + let fp = vk::NvDeviceDiagnosticCheckpointsFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } } #[doc = ""] @@ -26,23 +23,25 @@ impl DeviceDiagnosticCheckpoints { command_buffer: vk::CommandBuffer, p_checkpoint_marker: *const c_void, ) { - self.device_diagnostic_checkpoints_fn + self.fp .cmd_set_checkpoint_nv(command_buffer, p_checkpoint_marker); } #[doc = ""] pub unsafe fn get_queue_checkpoint_data(&self, queue: vk::Queue) -> Vec { let mut checkpoint_data_count: u32 = 0; - self.device_diagnostic_checkpoints_fn - .get_queue_checkpoint_data_nv(queue, &mut checkpoint_data_count, std::ptr::null_mut()); + self.fp.get_queue_checkpoint_data_nv( + queue, + &mut checkpoint_data_count, + std::ptr::null_mut(), + ); let mut checkpoint_data: Vec = vec![vk::CheckpointDataNV::default(); checkpoint_data_count as _]; - self.device_diagnostic_checkpoints_fn - .get_queue_checkpoint_data_nv( - queue, - &mut checkpoint_data_count, - checkpoint_data.as_mut_ptr(), - ); + self.fp.get_queue_checkpoint_data_nv( + queue, + &mut checkpoint_data_count, + checkpoint_data.as_mut_ptr(), + ); checkpoint_data } @@ -51,6 +50,6 @@ impl DeviceDiagnosticCheckpoints { } pub fn fp(&self) -> &vk::NvDeviceDiagnosticCheckpointsFn { - &self.device_diagnostic_checkpoints_fn + &self.fp } } diff --git a/ash/src/extensions/nv/mesh_shader.rs b/ash/src/extensions/nv/mesh_shader.rs index 95e2375..63fb4da 100755 --- a/ash/src/extensions/nv/mesh_shader.rs +++ b/ash/src/extensions/nv/mesh_shader.rs @@ -5,15 +5,15 @@ use std::mem; #[derive(Clone)] pub struct MeshShader { - mesh_shader_fn: vk::NvMeshShaderFn, + fp: vk::NvMeshShaderFn, } impl MeshShader { pub fn new(instance: &Instance, device: &Device) -> Self { - let mesh_shader_fn = vk::NvMeshShaderFn::load(|name| unsafe { + let fp = vk::NvMeshShaderFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); - Self { mesh_shader_fn } + Self { fp } } #[doc = ""] @@ -23,7 +23,7 @@ impl MeshShader { task_count: u32, first_task: u32, ) { - self.mesh_shader_fn + self.fp .cmd_draw_mesh_tasks_nv(command_buffer, task_count, first_task); } @@ -36,13 +36,8 @@ impl MeshShader { draw_count: u32, stride: u32, ) { - self.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_nv( - command_buffer, - buffer, - offset, - draw_count, - stride, - ); + self.fp + .cmd_draw_mesh_tasks_indirect_nv(command_buffer, buffer, offset, draw_count, stride); } #[doc = ""] @@ -56,7 +51,7 @@ impl MeshShader { max_draw_count: u32, stride: u32, ) { - self.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_count_nv( + self.fp.cmd_draw_mesh_tasks_indirect_count_nv( command_buffer, buffer, offset, @@ -72,6 +67,6 @@ impl MeshShader { } pub fn fp(&self) -> &vk::NvMeshShaderFn { - &self.mesh_shader_fn + &self.fp } } diff --git a/ash/src/extensions/nv/ray_tracing.rs b/ash/src/extensions/nv/ray_tracing.rs index c773957..1a46f3f 100755 --- a/ash/src/extensions/nv/ray_tracing.rs +++ b/ash/src/extensions/nv/ray_tracing.rs @@ -8,18 +8,16 @@ use std::mem; #[derive(Clone)] pub struct RayTracing { handle: vk::Device, - ray_tracing_fn: vk::NvRayTracingFn, + fp: vk::NvRayTracingFn, } impl RayTracing { pub fn new(instance: &Instance, device: &Device) -> Self { - let ray_tracing_fn = vk::NvRayTracingFn::load(|name| unsafe { - mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + let handle = device.handle(); + let fp = vk::NvRayTracingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) }); - Self { - handle: device.handle(), - ray_tracing_fn, - } + Self { handle, fp } } pub unsafe fn get_properties( @@ -41,7 +39,7 @@ impl RayTracing { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut accel_struct = mem::zeroed(); - self.ray_tracing_fn + self.fp .create_acceleration_structure_nv( self.handle, create_info, @@ -57,7 +55,7 @@ impl RayTracing { accel_struct: vk::AccelerationStructureNV, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.ray_tracing_fn.destroy_acceleration_structure_nv( + self.fp.destroy_acceleration_structure_nv( self.handle, accel_struct, allocation_callbacks.as_raw_ptr(), @@ -70,12 +68,11 @@ impl RayTracing { info: &vk::AccelerationStructureMemoryRequirementsInfoNV, ) -> vk::MemoryRequirements2KHR { let mut requirements = mem::zeroed(); - self.ray_tracing_fn - .get_acceleration_structure_memory_requirements_nv( - self.handle, - info, - &mut requirements, - ); + self.fp.get_acceleration_structure_memory_requirements_nv( + self.handle, + info, + &mut requirements, + ); requirements } @@ -84,7 +81,7 @@ impl RayTracing { &self, bind_info: &[vk::BindAccelerationStructureMemoryInfoNV], ) -> VkResult<()> { - self.ray_tracing_fn + self.fp .bind_acceleration_structure_memory_nv( self.handle, bind_info.len() as u32, @@ -106,7 +103,7 @@ impl RayTracing { scratch: vk::Buffer, scratch_offset: vk::DeviceSize, ) { - self.ray_tracing_fn.cmd_build_acceleration_structure_nv( + self.fp.cmd_build_acceleration_structure_nv( command_buffer, info, instance_data, @@ -127,7 +124,7 @@ impl RayTracing { src: vk::AccelerationStructureNV, mode: vk::CopyAccelerationStructureModeNV, ) { - self.ray_tracing_fn + self.fp .cmd_copy_acceleration_structure_nv(command_buffer, dst, src, mode); } @@ -150,7 +147,7 @@ impl RayTracing { height: u32, depth: u32, ) { - self.ray_tracing_fn.cmd_trace_rays_nv( + self.fp.cmd_trace_rays_nv( command_buffer, raygen_shader_binding_table_buffer, raygen_shader_binding_offset, @@ -177,7 +174,7 @@ impl RayTracing { allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult> { let mut pipelines = vec![mem::zeroed(); create_info.len()]; - self.ray_tracing_fn + self.fp .create_ray_tracing_pipelines_nv( self.handle, pipeline_cache, @@ -197,7 +194,7 @@ impl RayTracing { group_count: u32, data: &mut [u8], ) -> VkResult<()> { - self.ray_tracing_fn + self.fp .get_ray_tracing_shader_group_handles_nv( self.handle, pipeline, @@ -216,7 +213,7 @@ impl RayTracing { ) -> VkResult { let mut handle: u64 = 0; let handle_ptr: *mut u64 = &mut handle; - self.ray_tracing_fn + self.fp .get_acceleration_structure_handle_nv( self.handle, accel_struct, @@ -235,20 +232,19 @@ impl RayTracing { query_pool: vk::QueryPool, first_query: u32, ) { - self.ray_tracing_fn - .cmd_write_acceleration_structures_properties_nv( - command_buffer, - structures.len() as u32, - structures.as_ptr(), - query_type, - query_pool, - first_query, - ); + self.fp.cmd_write_acceleration_structures_properties_nv( + command_buffer, + structures.len() as u32, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); } #[doc = ""] pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> { - self.ray_tracing_fn + self.fp .compile_deferred_nv(self.handle, pipeline, shader) .result() } @@ -258,7 +254,7 @@ impl RayTracing { } pub fn fp(&self) -> &vk::NvRayTracingFn { - &self.ray_tracing_fn + &self.fp } pub fn device(&self) -> vk::Device {