From f5e7cfe89651e9c498918a98c9a47fc01f77b959 Mon Sep 17 00:00:00 2001 From: Rua Date: Fri, 30 Apr 2021 17:13:23 +0200 Subject: [PATCH] Impl trait functions directly on EntryCustom/Instance/Device (#412) * Implement EntryV1_x, InstanceV1_x, DeviceV1_x functions directly --- ash-window/examples/winit.rs | 2 +- ash-window/src/lib.rs | 19 +- ash/src/device.rs | 761 +++++++++--------- ash/src/entry.rs | 281 +++---- ash/src/entry_libloading.rs | 2 +- .../extensions/ext/buffer_device_address.rs | 4 +- ash/src/extensions/ext/debug_marker.rs | 4 +- ash/src/extensions/ext/debug_report.rs | 4 +- ash/src/extensions/ext/debug_utils.rs | 4 +- .../extensions/ext/extended_dynamic_state.rs | 4 +- .../extensions/ext/full_screen_exclusive.rs | 4 +- ash/src/extensions/ext/metal_surface.rs | 4 +- ash/src/extensions/ext/tooling_info.rs | 4 +- .../extensions/khr/acceleration_structure.rs | 8 +- ash/src/extensions/khr/android_surface.rs | 4 +- .../extensions/khr/buffer_device_address.rs | 4 +- ash/src/extensions/khr/create_render_pass2.rs | 4 +- .../khr/deferred_host_operations.rs | 4 +- ash/src/extensions/khr/display.rs | 4 +- ash/src/extensions/khr/display_swapchain.rs | 4 +- ash/src/extensions/khr/draw_indirect_count.rs | 4 +- ash/src/extensions/khr/external_fence_fd.rs | 4 +- ash/src/extensions/khr/external_memory_fd.rs | 4 +- .../extensions/khr/external_semaphore_fd.rs | 4 +- .../khr/get_memory_requirements2.rs | 4 +- .../khr/get_physical_device_properties2.rs | 4 +- ash/src/extensions/khr/maintenance1.rs | 4 +- ash/src/extensions/khr/maintenance3.rs | 4 +- .../khr/pipeline_executable_properties.rs | 4 +- ash/src/extensions/khr/push_descriptor.rs | 4 +- .../extensions/khr/ray_tracing_pipeline.rs | 8 +- ash/src/extensions/khr/surface.rs | 4 +- ash/src/extensions/khr/swapchain.rs | 4 +- ash/src/extensions/khr/timeline_semaphore.rs | 4 +- ash/src/extensions/khr/wayland_surface.rs | 4 +- ash/src/extensions/khr/win32_surface.rs | 4 +- ash/src/extensions/khr/xcb_surface.rs | 4 +- ash/src/extensions/khr/xlib_surface.rs | 4 +- ash/src/extensions/mvk/ios_surface.rs | 4 +- ash/src/extensions/mvk/macos_surface.rs | 4 +- ash/src/extensions/nn/vi_surface.rs | 4 +- .../nv/device_diagnostic_checkpoints.rs | 4 +- ash/src/extensions/nv/mesh_shader.rs | 4 +- ash/src/extensions/nv/ray_tracing.rs | 8 +- ash/src/instance.rs | 246 +++--- ash/src/lib.rs | 3 +- ash/tests/constant_size_arrays.rs | 1 - examples/src/lib.rs | 10 +- 48 files changed, 729 insertions(+), 764 deletions(-) diff --git a/ash-window/examples/winit.rs b/ash-window/examples/winit.rs index ff653cb..66cbb06 100644 --- a/ash-window/examples/winit.rs +++ b/ash-window/examples/winit.rs @@ -5,7 +5,7 @@ //! //! On instance extensions platform specific extensions need to be enabled. -use ash::{version::EntryV1_0, vk}; +use ash::vk; use std::error::Error; fn main() -> Result<(), Box> { diff --git a/ash-window/src/lib.rs b/ash-window/src/lib.rs index 66d6a57..70b14bf 100644 --- a/ash-window/src/lib.rs +++ b/ash-window/src/lib.rs @@ -1,9 +1,4 @@ -use ash::{ - extensions::khr, - prelude::*, - version::{EntryV1_0, InstanceV1_0}, - vk, -}; +use ash::{extensions::khr, prelude::*, vk, EntryCustom, Instance}; use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; use std::ffi::CStr; @@ -19,16 +14,12 @@ use ash::extensions::ext; // portability extensions /// In order for the created `SurfaceKHR` to be valid for the duration of its /// usage, the `Instance` this was called on must be dropped later than the /// resulting `SurfaceKHR`. -pub unsafe fn create_surface( - entry: &E, - instance: &I, +pub unsafe fn create_surface( + entry: &EntryCustom, + instance: &Instance, window_handle: &dyn HasRawWindowHandle, allocation_callbacks: Option<&vk::AllocationCallbacks>, -) -> VkResult -where - E: EntryV1_0, - I: InstanceV1_0, -{ +) -> VkResult { match window_handle.raw_window_handle() { #[cfg(target_os = "windows")] RawWindowHandle::Windows(handle) => { diff --git a/ash/src/device.rs b/ash/src/device.rs index fb2dc14..ecc14e4 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -6,12 +6,45 @@ use std::mem; use std::os::raw::c_void; use std::ptr; +#[doc = ""] +#[derive(Clone)] +pub struct Device { + pub(crate) handle: vk::Device, + + pub(crate) device_fn_1_0: vk::DeviceFnV1_0, + pub(crate) device_fn_1_1: vk::DeviceFnV1_1, + pub(crate) device_fn_1_2: vk::DeviceFnV1_2, +} + +impl Device { + pub unsafe fn load(instance_fn: &vk::InstanceFnV1_0, device: vk::Device) -> Self { + let load_fn = |name: &std::ffi::CStr| { + mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr())) + }; + + Device { + handle: device, + + device_fn_1_0: vk::DeviceFnV1_0::load(load_fn), + device_fn_1_1: vk::DeviceFnV1_1::load(load_fn), + device_fn_1_2: vk::DeviceFnV1_2::load(load_fn), + } + } + + pub fn handle(&self) -> vk::Device { + self.handle + } +} + +/// Vulkan core 1.2 #[allow(non_camel_case_types)] -pub trait DeviceV1_2: DeviceV1_1 { - fn fp_v1_2(&self) -> &vk::DeviceFnV1_2; +impl Device { + pub fn fp_v1_2(&self) -> &vk::DeviceFnV1_2 { + &self.device_fn_1_2 + } #[doc = ""] - unsafe fn cmd_draw_indirect_count( + pub unsafe fn cmd_draw_indirect_count( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, @@ -21,7 +54,7 @@ pub trait DeviceV1_2: DeviceV1_1 { max_draw_count: u32, stride: u32, ) { - self.fp_v1_2().cmd_draw_indirect_count( + self.device_fn_1_2.cmd_draw_indirect_count( command_buffer, buffer, offset, @@ -33,7 +66,7 @@ pub trait DeviceV1_2: DeviceV1_1 { } #[doc = ""] - unsafe fn cmd_draw_indexed_indirect_count( + pub unsafe fn cmd_draw_indexed_indirect_count( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, @@ -43,7 +76,7 @@ pub trait DeviceV1_2: DeviceV1_1 { max_draw_count: u32, stride: u32, ) { - self.fp_v1_2().cmd_draw_indexed_indirect_count( + self.device_fn_1_2.cmd_draw_indexed_indirect_count( command_buffer, buffer, offset, @@ -55,13 +88,13 @@ pub trait DeviceV1_2: DeviceV1_1 { } #[doc = ""] - unsafe fn create_render_pass2( + pub unsafe fn create_render_pass2( &self, create_info: &vk::RenderPassCreateInfo2, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut renderpass = mem::zeroed(); - self.fp_v1_2() + self.device_fn_1_2 .create_render_pass2( self.handle(), create_info, @@ -72,13 +105,13 @@ pub trait DeviceV1_2: DeviceV1_1 { } #[doc = ""] - unsafe fn cmd_begin_render_pass2( + pub unsafe fn cmd_begin_render_pass2( &self, command_buffer: vk::CommandBuffer, render_pass_begin_info: &vk::RenderPassBeginInfo, subpass_begin_info: &vk::SubpassBeginInfo, ) { - self.fp_v1_2().cmd_begin_render_pass2( + self.device_fn_1_2.cmd_begin_render_pass2( command_buffer, render_pass_begin_info, subpass_begin_info, @@ -86,115 +119,127 @@ pub trait DeviceV1_2: DeviceV1_1 { } #[doc = ""] - unsafe fn cmd_next_subpass2( + pub unsafe fn cmd_next_subpass2( &self, command_buffer: vk::CommandBuffer, subpass_begin_info: &vk::SubpassBeginInfo, subpass_end_info: &vk::SubpassEndInfo, ) { - self.fp_v1_2() + self.device_fn_1_2 .cmd_next_subpass2(command_buffer, subpass_begin_info, subpass_end_info); } #[doc = ""] - unsafe fn cmd_end_render_pass2( + pub unsafe fn cmd_end_render_pass2( &self, command_buffer: vk::CommandBuffer, subpass_end_info: &vk::SubpassEndInfo, ) { - self.fp_v1_2() + self.device_fn_1_2 .cmd_end_render_pass2(command_buffer, subpass_end_info); } #[doc = ""] - unsafe fn reset_query_pool( + pub unsafe fn reset_query_pool( &self, query_pool: vk::QueryPool, first_query: u32, query_count: u32, ) { - self.fp_v1_2() + self.device_fn_1_2 .reset_query_pool(self.handle(), query_pool, first_query, query_count); } #[doc = ""] - unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult { + pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult { let mut value = 0; - self.fp_v1_2() + self.device_fn_1_2 .get_semaphore_counter_value(self.handle(), semaphore, &mut value) .result_with_success(value) } #[doc = ""] - unsafe fn wait_semaphores( + pub unsafe fn wait_semaphores( &self, wait_info: &vk::SemaphoreWaitInfo, timeout: u64, ) -> VkResult<()> { - self.fp_v1_2() + self.device_fn_1_2 .wait_semaphores(self.handle(), wait_info, timeout) .into() } #[doc = ""] - unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> { - self.fp_v1_2() + pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> { + self.device_fn_1_2 .signal_semaphore(self.handle(), signal_info) .into() } #[doc = ""] - unsafe fn get_buffer_device_address( + pub unsafe fn get_buffer_device_address( &self, info: &vk::BufferDeviceAddressInfo, ) -> vk::DeviceAddress { - self.fp_v1_2() + self.device_fn_1_2 .get_buffer_device_address(self.handle(), info) } #[doc = ""] - unsafe fn get_buffer_opaque_capture_address(&self, info: &vk::BufferDeviceAddressInfo) -> u64 { - self.fp_v1_2() + pub unsafe fn get_buffer_opaque_capture_address( + &self, + info: &vk::BufferDeviceAddressInfo, + ) -> u64 { + self.device_fn_1_2 .get_buffer_opaque_capture_address(self.handle(), info) } #[doc = ""] - unsafe fn get_device_memory_opaque_capture_address( + pub unsafe fn get_device_memory_opaque_capture_address( &self, info: &vk::DeviceMemoryOpaqueCaptureAddressInfo, ) -> u64 { - self.fp_v1_2() + self.device_fn_1_2 .get_device_memory_opaque_capture_address(self.handle(), info) } } +/// Vulkan core 1.1 #[allow(non_camel_case_types)] -pub trait DeviceV1_1: DeviceV1_0 { - fn fp_v1_1(&self) -> &vk::DeviceFnV1_1; +impl Device { + pub fn fp_v1_1(&self) -> &vk::DeviceFnV1_1 { + &self.device_fn_1_1 + } #[doc = ""] - unsafe fn bind_buffer_memory2(&self, bind_infos: &[vk::BindBufferMemoryInfo]) -> VkResult<()> { - self.fp_v1_1() + pub unsafe fn bind_buffer_memory2( + &self, + bind_infos: &[vk::BindBufferMemoryInfo], + ) -> VkResult<()> { + self.device_fn_1_1 .bind_buffer_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr()) .into() } #[doc = ""] - unsafe fn bind_image_memory2(&self, bind_infos: &[vk::BindImageMemoryInfo]) -> VkResult<()> { - self.fp_v1_1() + pub unsafe fn bind_image_memory2( + &self, + bind_infos: &[vk::BindImageMemoryInfo], + ) -> VkResult<()> { + self.device_fn_1_1 .bind_image_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr()) .into() } #[doc = ""] - unsafe fn get_device_group_peer_memory_features( + pub unsafe fn get_device_group_peer_memory_features( &self, heap_index: u32, local_device_index: u32, remote_device_index: u32, ) -> vk::PeerMemoryFeatureFlags { let mut peer_memory_features = mem::zeroed(); - self.fp_v1_1().get_device_group_peer_memory_features( + self.device_fn_1_1.get_device_group_peer_memory_features( self.handle(), heap_index, local_device_index, @@ -205,13 +250,13 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_set_device_mask(&self, command_buffer: vk::CommandBuffer, device_mask: u32) { - self.fp_v1_1() + pub unsafe fn cmd_set_device_mask(&self, command_buffer: vk::CommandBuffer, device_mask: u32) { + self.device_fn_1_1 .cmd_set_device_mask(command_buffer, device_mask); } #[doc = ""] - unsafe fn cmd_dispatch_base( + pub unsafe fn cmd_dispatch_base( &self, command_buffer: vk::CommandBuffer, base_group_x: u32, @@ -221,7 +266,7 @@ pub trait DeviceV1_1: DeviceV1_0 { group_count_y: u32, group_count_z: u32, ) { - self.fp_v1_1().cmd_dispatch_base( + self.device_fn_1_1.cmd_dispatch_base( command_buffer, base_group_x, base_group_y, @@ -233,31 +278,31 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn get_image_memory_requirements2( + pub unsafe fn get_image_memory_requirements2( &self, info: &vk::ImageMemoryRequirementsInfo2, out: &mut vk::MemoryRequirements2, ) { - self.fp_v1_1() + self.device_fn_1_1 .get_image_memory_requirements2(self.handle(), info, out); } #[doc = ""] - unsafe fn get_buffer_memory_requirements2( + pub unsafe fn get_buffer_memory_requirements2( &self, info: &vk::BufferMemoryRequirementsInfo2, out: &mut vk::MemoryRequirements2, ) { - self.fp_v1_1() + self.device_fn_1_1 .get_buffer_memory_requirements2(self.handle(), info, out); } - unsafe fn get_image_sparse_memory_requirements2_len( + pub unsafe fn get_image_sparse_memory_requirements2_len( &self, info: &vk::ImageSparseMemoryRequirementsInfo2, ) -> usize { let mut count = mem::zeroed(); - self.fp_v1_1().get_image_sparse_memory_requirements2( + self.device_fn_1_1.get_image_sparse_memory_requirements2( self.handle(), info, &mut count, @@ -267,13 +312,13 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn get_image_sparse_memory_requirements2( + pub unsafe fn get_image_sparse_memory_requirements2( &self, info: &vk::ImageSparseMemoryRequirementsInfo2, out: &mut [vk::SparseImageMemoryRequirements2], ) { let mut count = out.len() as u32; - self.fp_v1_1().get_image_sparse_memory_requirements2( + self.device_fn_1_1.get_image_sparse_memory_requirements2( self.handle(), info, &mut count, @@ -282,23 +327,23 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn trim_command_pool( + pub unsafe fn trim_command_pool( &self, command_pool: vk::CommandPool, flags: vk::CommandPoolTrimFlags, ) { - self.fp_v1_1() + self.device_fn_1_1 .trim_command_pool(self.handle(), command_pool, flags); } #[doc = ""] - unsafe fn create_sampler_ycbcr_conversion( + pub unsafe fn create_sampler_ycbcr_conversion( &self, create_info: &vk::SamplerYcbcrConversionCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut ycbcr_conversion = mem::zeroed(); - self.fp_v1_1() + self.device_fn_1_1 .create_sampler_ycbcr_conversion( self.handle(), create_info, @@ -309,12 +354,12 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_sampler_ycbcr_conversion( + pub unsafe fn destroy_sampler_ycbcr_conversion( &self, ycbcr_conversion: vk::SamplerYcbcrConversion, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_1().destroy_sampler_ycbcr_conversion( + self.device_fn_1_1.destroy_sampler_ycbcr_conversion( self.handle(), ycbcr_conversion, allocation_callbacks.as_raw_ptr(), @@ -322,13 +367,13 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn create_descriptor_update_template( + pub unsafe fn create_descriptor_update_template( &self, create_info: &vk::DescriptorUpdateTemplateCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut descriptor_update_template = mem::zeroed(); - self.fp_v1_1() + self.device_fn_1_1 .create_descriptor_update_template( self.handle(), create_info, @@ -339,12 +384,12 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_descriptor_update_template( + pub unsafe fn destroy_descriptor_update_template( &self, descriptor_update_template: vk::DescriptorUpdateTemplate, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_1().destroy_descriptor_update_template( + self.device_fn_1_1.destroy_descriptor_update_template( self.handle(), descriptor_update_template, allocation_callbacks.as_raw_ptr(), @@ -352,13 +397,13 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn update_descriptor_set_with_template( + pub unsafe fn update_descriptor_set_with_template( &self, descriptor_set: vk::DescriptorSet, descriptor_update_template: vk::DescriptorUpdateTemplate, data: *const c_void, ) { - self.fp_v1_1().update_descriptor_set_with_template( + self.device_fn_1_1.update_descriptor_set_with_template( self.handle(), descriptor_set, descriptor_update_template, @@ -367,53 +412,59 @@ pub trait DeviceV1_1: DeviceV1_0 { } #[doc = ""] - unsafe fn get_descriptor_set_layout_support( + pub unsafe fn get_descriptor_set_layout_support( &self, create_info: &vk::DescriptorSetLayoutCreateInfo, out: &mut vk::DescriptorSetLayoutSupport, ) { - self.fp_v1_1() + self.device_fn_1_1 .get_descriptor_set_layout_support(self.handle(), create_info, out); } } +/// Vulkan core 1.0 #[allow(non_camel_case_types)] -pub trait DeviceV1_0 { - fn handle(&self) -> vk::Device; - fn fp_v1_0(&self) -> &vk::DeviceFnV1_0; +impl Device { + pub fn fp_v1_0(&self) -> &vk::DeviceFnV1_0 { + &self.device_fn_1_0 + } + #[doc = ""] - unsafe fn destroy_device(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0() + pub unsafe fn destroy_device(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) { + self.device_fn_1_0 .destroy_device(self.handle(), allocation_callbacks.as_raw_ptr()); } #[doc = ""] - unsafe fn destroy_sampler( + pub unsafe fn destroy_sampler( &self, sampler: vk::Sampler, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() - .destroy_sampler(self.handle(), sampler, allocation_callbacks.as_raw_ptr()); + self.device_fn_1_0.destroy_sampler( + self.handle(), + sampler, + allocation_callbacks.as_raw_ptr(), + ); } #[doc = ""] - unsafe fn free_memory( + pub unsafe fn free_memory( &self, memory: vk::DeviceMemory, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() + self.device_fn_1_0 .free_memory(self.handle(), memory, allocation_callbacks.as_raw_ptr()); } #[doc = ""] - unsafe fn free_command_buffers( + pub unsafe fn free_command_buffers( &self, command_pool: vk::CommandPool, command_buffers: &[vk::CommandBuffer], ) { - self.fp_v1_0().free_command_buffers( + self.device_fn_1_0.free_command_buffers( self.handle(), command_pool, command_buffers.len() as u32, @@ -422,13 +473,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_event( + pub unsafe fn create_event( &self, create_info: &vk::EventCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut event = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_event( self.handle(), create_info, @@ -441,8 +492,8 @@ pub trait DeviceV1_0 { /// Returns true if the event was set, and false if the event was reset, otherwise it will /// return the error code. #[doc = ""] - unsafe fn get_event_status(&self, event: vk::Event) -> VkResult { - let err_code = self.fp_v1_0().get_event_status(self.handle(), event); + pub unsafe fn get_event_status(&self, event: vk::Event) -> VkResult { + let err_code = self.device_fn_1_0.get_event_status(self.handle(), event); match err_code { vk::Result::EVENT_SET => Ok(true), vk::Result::EVENT_RESET => Ok(false), @@ -451,37 +502,37 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> { - self.fp_v1_0().set_event(self.handle(), event).into() + pub unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> { + self.device_fn_1_0.set_event(self.handle(), event).into() } #[doc = ""] - unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> { - self.fp_v1_0().reset_event(self.handle(), event).into() + pub unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> { + self.device_fn_1_0.reset_event(self.handle(), event).into() } #[doc = ""] - unsafe fn cmd_set_event( + pub unsafe fn cmd_set_event( &self, command_buffer: vk::CommandBuffer, event: vk::Event, stage_mask: vk::PipelineStageFlags, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_set_event(command_buffer, event, stage_mask); } #[doc = ""] - unsafe fn cmd_reset_event( + pub unsafe fn cmd_reset_event( &self, command_buffer: vk::CommandBuffer, event: vk::Event, stage_mask: vk::PipelineStageFlags, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_reset_event(command_buffer, event, stage_mask); } #[doc = ""] - unsafe fn cmd_wait_events( + pub unsafe fn cmd_wait_events( &self, command_buffer: vk::CommandBuffer, events: &[vk::Event], @@ -491,7 +542,7 @@ pub trait DeviceV1_0 { buffer_memory_barriers: &[vk::BufferMemoryBarrier], image_memory_barriers: &[vk::ImageMemoryBarrier], ) { - self.fp_v1_0().cmd_wait_events( + self.device_fn_1_0.cmd_wait_events( command_buffer, events.len() as _, events.as_ptr(), @@ -507,52 +558,55 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_fence( + pub unsafe fn destroy_fence( &self, fence: vk::Fence, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() + self.device_fn_1_0 .destroy_fence(self.handle(), fence, allocation_callbacks.as_raw_ptr()); } #[doc = ""] - unsafe fn destroy_event( + pub unsafe fn destroy_event( &self, event: vk::Event, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() + self.device_fn_1_0 .destroy_event(self.handle(), event, allocation_callbacks.as_raw_ptr()); } #[doc = ""] - unsafe fn destroy_image( + pub unsafe fn destroy_image( &self, image: vk::Image, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() + self.device_fn_1_0 .destroy_image(self.handle(), image, allocation_callbacks.as_raw_ptr()); } #[doc = ""] - unsafe fn destroy_command_pool( + pub unsafe fn destroy_command_pool( &self, pool: vk::CommandPool, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() - .destroy_command_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr()); + self.device_fn_1_0.destroy_command_pool( + self.handle(), + pool, + allocation_callbacks.as_raw_ptr(), + ); } #[doc = ""] - unsafe fn destroy_image_view( + pub unsafe fn destroy_image_view( &self, image_view: vk::ImageView, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_image_view( + self.device_fn_1_0.destroy_image_view( self.handle(), image_view, allocation_callbacks.as_raw_ptr(), @@ -560,12 +614,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_render_pass( + pub unsafe fn destroy_render_pass( &self, renderpass: vk::RenderPass, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_render_pass( + self.device_fn_1_0.destroy_render_pass( self.handle(), renderpass, allocation_callbacks.as_raw_ptr(), @@ -573,12 +627,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_framebuffer( + pub unsafe fn destroy_framebuffer( &self, framebuffer: vk::Framebuffer, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_framebuffer( + self.device_fn_1_0.destroy_framebuffer( self.handle(), framebuffer, allocation_callbacks.as_raw_ptr(), @@ -586,12 +640,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_pipeline_layout( + pub unsafe fn destroy_pipeline_layout( &self, pipeline_layout: vk::PipelineLayout, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_pipeline_layout( + self.device_fn_1_0.destroy_pipeline_layout( self.handle(), pipeline_layout, allocation_callbacks.as_raw_ptr(), @@ -599,12 +653,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_pipeline_cache( + pub unsafe fn destroy_pipeline_cache( &self, pipeline_cache: vk::PipelineCache, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_pipeline_cache( + self.device_fn_1_0.destroy_pipeline_cache( self.handle(), pipeline_cache, allocation_callbacks.as_raw_ptr(), @@ -612,22 +666,22 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_buffer( + pub unsafe fn destroy_buffer( &self, buffer: vk::Buffer, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() + self.device_fn_1_0 .destroy_buffer(self.handle(), buffer, allocation_callbacks.as_raw_ptr()); } #[doc = ""] - unsafe fn destroy_shader_module( + pub unsafe fn destroy_shader_module( &self, shader: vk::ShaderModule, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_shader_module( + self.device_fn_1_0.destroy_shader_module( self.handle(), shader, allocation_callbacks.as_raw_ptr(), @@ -635,22 +689,25 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_pipeline( + pub unsafe fn destroy_pipeline( &self, pipeline: vk::Pipeline, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() - .destroy_pipeline(self.handle(), pipeline, allocation_callbacks.as_raw_ptr()); + self.device_fn_1_0.destroy_pipeline( + self.handle(), + pipeline, + allocation_callbacks.as_raw_ptr(), + ); } #[doc = ""] - unsafe fn destroy_semaphore( + pub unsafe fn destroy_semaphore( &self, semaphore: vk::Semaphore, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_semaphore( + self.device_fn_1_0.destroy_semaphore( self.handle(), semaphore, allocation_callbacks.as_raw_ptr(), @@ -658,12 +715,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_descriptor_pool( + pub unsafe fn destroy_descriptor_pool( &self, pool: vk::DescriptorPool, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_descriptor_pool( + self.device_fn_1_0.destroy_descriptor_pool( self.handle(), pool, allocation_callbacks.as_raw_ptr(), @@ -671,22 +728,25 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_query_pool( + pub unsafe fn destroy_query_pool( &self, pool: vk::QueryPool, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0() - .destroy_query_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr()); + self.device_fn_1_0.destroy_query_pool( + self.handle(), + pool, + allocation_callbacks.as_raw_ptr(), + ); } #[doc = ""] - unsafe fn destroy_descriptor_set_layout( + pub unsafe fn destroy_descriptor_set_layout( &self, layout: vk::DescriptorSetLayout, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_descriptor_set_layout( + self.device_fn_1_0.destroy_descriptor_set_layout( self.handle(), layout, allocation_callbacks.as_raw_ptr(), @@ -694,12 +754,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn free_descriptor_sets( + pub unsafe fn free_descriptor_sets( &self, pool: vk::DescriptorPool, descriptor_sets: &[vk::DescriptorSet], ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .free_descriptor_sets( self.handle(), pool, @@ -710,12 +770,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn update_descriptor_sets( + pub unsafe fn update_descriptor_sets( &self, descriptor_writes: &[vk::WriteDescriptorSet], descriptor_copies: &[vk::CopyDescriptorSet], ) { - self.fp_v1_0().update_descriptor_sets( + self.device_fn_1_0.update_descriptor_sets( self.handle(), descriptor_writes.len() as u32, descriptor_writes.as_ptr(), @@ -725,13 +785,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_sampler( + pub unsafe fn create_sampler( &self, create_info: &vk::SamplerCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut sampler = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_sampler( self.handle(), create_info, @@ -742,7 +802,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_blit_image( + pub unsafe fn cmd_blit_image( &self, command_buffer: vk::CommandBuffer, src_image: vk::Image, @@ -752,7 +812,7 @@ pub trait DeviceV1_0 { regions: &[vk::ImageBlit], filter: vk::Filter, ) { - self.fp_v1_0().cmd_blit_image( + self.device_fn_1_0.cmd_blit_image( command_buffer, src_image, src_image_layout, @@ -765,7 +825,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_resolve_image( + pub unsafe fn cmd_resolve_image( &self, command_buffer: vk::CommandBuffer, src_image: vk::Image, @@ -774,7 +834,7 @@ pub trait DeviceV1_0 { dst_image_layout: vk::ImageLayout, regions: &[vk::ImageResolve], ) { - self.fp_v1_0().cmd_resolve_image( + self.device_fn_1_0.cmd_resolve_image( command_buffer, src_image, src_image_layout, @@ -786,7 +846,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_fill_buffer( + pub unsafe fn cmd_fill_buffer( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, @@ -794,19 +854,19 @@ pub trait DeviceV1_0 { size: vk::DeviceSize, data: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_fill_buffer(command_buffer, buffer, offset, size, data); } #[doc = ""] - unsafe fn cmd_update_buffer( + pub unsafe fn cmd_update_buffer( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, offset: vk::DeviceSize, data: &[u8], ) { - self.fp_v1_0().cmd_update_buffer( + self.device_fn_1_0.cmd_update_buffer( command_buffer, buffer, offset, @@ -816,14 +876,14 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_copy_buffer( + pub unsafe fn cmd_copy_buffer( &self, command_buffer: vk::CommandBuffer, src_buffer: vk::Buffer, dst_buffer: vk::Buffer, regions: &[vk::BufferCopy], ) { - self.fp_v1_0().cmd_copy_buffer( + self.device_fn_1_0.cmd_copy_buffer( command_buffer, src_buffer, dst_buffer, @@ -833,7 +893,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_copy_image_to_buffer( + pub unsafe fn cmd_copy_image_to_buffer( &self, command_buffer: vk::CommandBuffer, src_image: vk::Image, @@ -841,7 +901,7 @@ pub trait DeviceV1_0 { dst_buffer: vk::Buffer, regions: &[vk::BufferImageCopy], ) { - self.fp_v1_0().cmd_copy_image_to_buffer( + self.device_fn_1_0.cmd_copy_image_to_buffer( command_buffer, src_image, src_image_layout, @@ -852,7 +912,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_copy_buffer_to_image( + pub unsafe fn cmd_copy_buffer_to_image( &self, command_buffer: vk::CommandBuffer, src_buffer: vk::Buffer, @@ -860,7 +920,7 @@ pub trait DeviceV1_0 { dst_image_layout: vk::ImageLayout, regions: &[vk::BufferImageCopy], ) { - self.fp_v1_0().cmd_copy_buffer_to_image( + self.device_fn_1_0.cmd_copy_buffer_to_image( command_buffer, src_buffer, dst_image, @@ -871,7 +931,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_copy_image( + pub unsafe fn cmd_copy_image( &self, command_buffer: vk::CommandBuffer, src_image: vk::Image, @@ -880,7 +940,7 @@ pub trait DeviceV1_0 { dst_image_layout: vk::ImageLayout, regions: &[vk::ImageCopy], ) { - self.fp_v1_0().cmd_copy_image( + self.device_fn_1_0.cmd_copy_image( command_buffer, src_image, src_image_layout, @@ -892,12 +952,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn allocate_descriptor_sets( + pub unsafe fn allocate_descriptor_sets( &self, create_info: &vk::DescriptorSetAllocateInfo, ) -> VkResult> { let mut desc_set = Vec::with_capacity(create_info.descriptor_set_count as usize); - let err_code = self.fp_v1_0().allocate_descriptor_sets( + let err_code = self.device_fn_1_0.allocate_descriptor_sets( self.handle(), create_info, desc_set.as_mut_ptr(), @@ -908,13 +968,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_descriptor_set_layout( + pub unsafe fn create_descriptor_set_layout( &self, create_info: &vk::DescriptorSetLayoutCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut layout = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_descriptor_set_layout( self.handle(), create_info, @@ -925,18 +985,18 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn device_wait_idle(&self) -> VkResult<()> { - self.fp_v1_0().device_wait_idle(self.handle()).into() + pub unsafe fn device_wait_idle(&self) -> VkResult<()> { + self.device_fn_1_0.device_wait_idle(self.handle()).into() } #[doc = ""] - unsafe fn create_descriptor_pool( + pub unsafe fn create_descriptor_pool( &self, create_info: &vk::DescriptorPoolCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut pool = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_descriptor_pool( self.handle(), create_info, @@ -947,59 +1007,59 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn reset_descriptor_pool( + pub unsafe fn reset_descriptor_pool( &self, pool: vk::DescriptorPool, flags: vk::DescriptorPoolResetFlags, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .reset_descriptor_pool(self.handle(), pool, flags) .into() } #[doc = ""] - unsafe fn reset_command_pool( + pub unsafe fn reset_command_pool( &self, command_pool: vk::CommandPool, flags: vk::CommandPoolResetFlags, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .reset_command_pool(self.handle(), command_pool, flags) .into() } #[doc = ""] - unsafe fn reset_command_buffer( + pub unsafe fn reset_command_buffer( &self, command_buffer: vk::CommandBuffer, flags: vk::CommandBufferResetFlags, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .reset_command_buffer(command_buffer, flags) .into() } #[doc = ""] - unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> { - self.fp_v1_0() + pub unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> { + self.device_fn_1_0 .reset_fences(self.handle(), fences.len() as u32, fences.as_ptr()) .into() } #[doc = ""] - unsafe fn cmd_bind_index_buffer( + pub unsafe fn cmd_bind_index_buffer( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, offset: vk::DeviceSize, index_type: vk::IndexType, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_bind_index_buffer(command_buffer, buffer, offset, index_type); } #[doc = ""] - unsafe fn cmd_clear_color_image( + pub unsafe fn cmd_clear_color_image( &self, command_buffer: vk::CommandBuffer, image: vk::Image, @@ -1007,7 +1067,7 @@ pub trait DeviceV1_0 { clear_color_value: &vk::ClearColorValue, ranges: &[vk::ImageSubresourceRange], ) { - self.fp_v1_0().cmd_clear_color_image( + self.device_fn_1_0.cmd_clear_color_image( command_buffer, image, image_layout, @@ -1018,7 +1078,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_clear_depth_stencil_image( + pub unsafe fn cmd_clear_depth_stencil_image( &self, command_buffer: vk::CommandBuffer, image: vk::Image, @@ -1026,7 +1086,7 @@ pub trait DeviceV1_0 { clear_depth_stencil_value: &vk::ClearDepthStencilValue, ranges: &[vk::ImageSubresourceRange], ) { - self.fp_v1_0().cmd_clear_depth_stencil_image( + self.device_fn_1_0.cmd_clear_depth_stencil_image( command_buffer, image, image_layout, @@ -1037,13 +1097,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_clear_attachments( + pub unsafe fn cmd_clear_attachments( &self, command_buffer: vk::CommandBuffer, attachments: &[vk::ClearAttachment], rects: &[vk::ClearRect], ) { - self.fp_v1_0().cmd_clear_attachments( + self.device_fn_1_0.cmd_clear_attachments( command_buffer, attachments.len() as u32, attachments.as_ptr(), @@ -1053,7 +1113,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_draw_indexed( + pub unsafe fn cmd_draw_indexed( &self, command_buffer: vk::CommandBuffer, index_count: u32, @@ -1062,7 +1122,7 @@ pub trait DeviceV1_0 { vertex_offset: i32, first_instance: u32, ) { - self.fp_v1_0().cmd_draw_indexed( + self.device_fn_1_0.cmd_draw_indexed( command_buffer, index_count, instance_count, @@ -1073,7 +1133,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_draw_indexed_indirect( + pub unsafe fn cmd_draw_indexed_indirect( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, @@ -1081,7 +1141,7 @@ pub trait DeviceV1_0 { draw_count: u32, stride: u32, ) { - self.fp_v1_0().cmd_draw_indexed_indirect( + self.device_fn_1_0.cmd_draw_indexed_indirect( command_buffer, buffer, offset, @@ -1091,12 +1151,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_execute_commands( + pub unsafe fn cmd_execute_commands( &self, primary_command_buffer: vk::CommandBuffer, secondary_command_buffers: &[vk::CommandBuffer], ) { - self.fp_v1_0().cmd_execute_commands( + self.device_fn_1_0.cmd_execute_commands( primary_command_buffer, secondary_command_buffers.len() as u32, secondary_command_buffers.as_ptr(), @@ -1104,7 +1164,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_bind_descriptor_sets( + pub unsafe fn cmd_bind_descriptor_sets( &self, command_buffer: vk::CommandBuffer, pipeline_bind_point: vk::PipelineBindPoint, @@ -1113,7 +1173,7 @@ pub trait DeviceV1_0 { descriptor_sets: &[vk::DescriptorSet], dynamic_offsets: &[u32], ) { - self.fp_v1_0().cmd_bind_descriptor_sets( + self.device_fn_1_0.cmd_bind_descriptor_sets( command_buffer, pipeline_bind_point, layout, @@ -1126,7 +1186,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_copy_query_pool_results( + pub unsafe fn cmd_copy_query_pool_results( &self, command_buffer: vk::CommandBuffer, query_pool: vk::QueryPool, @@ -1137,7 +1197,7 @@ pub trait DeviceV1_0 { stride: vk::DeviceSize, flags: vk::QueryResultFlags, ) { - self.fp_v1_0().cmd_copy_query_pool_results( + self.device_fn_1_0.cmd_copy_query_pool_results( command_buffer, query_pool, first_query, @@ -1150,7 +1210,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_push_constants( + pub unsafe fn cmd_push_constants( &self, command_buffer: vk::CommandBuffer, layout: vk::PipelineLayout, @@ -1158,7 +1218,7 @@ pub trait DeviceV1_0 { offset: u32, constants: &[u8], ) { - self.fp_v1_0().cmd_push_constants( + self.device_fn_1_0.cmd_push_constants( command_buffer, layout, stage_flags, @@ -1169,44 +1229,45 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_begin_render_pass( + pub unsafe fn cmd_begin_render_pass( &self, command_buffer: vk::CommandBuffer, create_info: &vk::RenderPassBeginInfo, contents: vk::SubpassContents, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_begin_render_pass(command_buffer, create_info, contents); } #[doc = ""] - unsafe fn cmd_next_subpass( + pub unsafe fn cmd_next_subpass( &self, command_buffer: vk::CommandBuffer, contents: vk::SubpassContents, ) { - self.fp_v1_0().cmd_next_subpass(command_buffer, contents); + self.device_fn_1_0 + .cmd_next_subpass(command_buffer, contents); } #[doc = ""] - unsafe fn cmd_bind_pipeline( + pub unsafe fn cmd_bind_pipeline( &self, command_buffer: vk::CommandBuffer, pipeline_bind_point: vk::PipelineBindPoint, pipeline: vk::Pipeline, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_bind_pipeline(command_buffer, pipeline_bind_point, pipeline); } #[doc = ""] - unsafe fn cmd_set_scissor( + pub unsafe fn cmd_set_scissor( &self, command_buffer: vk::CommandBuffer, first_scissor: u32, scissors: &[vk::Rect2D], ) { - self.fp_v1_0().cmd_set_scissor( + self.device_fn_1_0.cmd_set_scissor( command_buffer, first_scissor, scissors.len() as u32, @@ -1215,13 +1276,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_set_line_width(&self, command_buffer: vk::CommandBuffer, line_width: f32) { - self.fp_v1_0() + pub unsafe fn cmd_set_line_width(&self, command_buffer: vk::CommandBuffer, line_width: f32) { + self.device_fn_1_0 .cmd_set_line_width(command_buffer, line_width); } #[doc = ""] - unsafe fn cmd_bind_vertex_buffers( + pub unsafe fn cmd_bind_vertex_buffers( &self, command_buffer: vk::CommandBuffer, first_binding: u32, @@ -1229,7 +1290,7 @@ pub trait DeviceV1_0 { offsets: &[vk::DeviceSize], ) { debug_assert_eq!(buffers.len(), offsets.len()); - self.fp_v1_0().cmd_bind_vertex_buffers( + self.device_fn_1_0.cmd_bind_vertex_buffers( command_buffer, first_binding, buffers.len() as u32, @@ -1239,12 +1300,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_end_render_pass(&self, command_buffer: vk::CommandBuffer) { - self.fp_v1_0().cmd_end_render_pass(command_buffer); + pub unsafe fn cmd_end_render_pass(&self, command_buffer: vk::CommandBuffer) { + self.device_fn_1_0.cmd_end_render_pass(command_buffer); } #[doc = ""] - unsafe fn cmd_draw( + pub unsafe fn cmd_draw( &self, command_buffer: vk::CommandBuffer, vertex_count: u32, @@ -1252,7 +1313,7 @@ pub trait DeviceV1_0 { first_vertex: u32, first_instance: u32, ) { - self.fp_v1_0().cmd_draw( + self.device_fn_1_0.cmd_draw( command_buffer, vertex_count, instance_count, @@ -1262,7 +1323,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_draw_indirect( + pub unsafe fn cmd_draw_indirect( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, @@ -1270,41 +1331,45 @@ pub trait DeviceV1_0 { draw_count: u32, stride: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_draw_indirect(command_buffer, buffer, offset, draw_count, stride); } #[doc = ""] - unsafe fn cmd_dispatch( + pub unsafe fn cmd_dispatch( &self, command_buffer: vk::CommandBuffer, group_count_x: u32, group_count_y: u32, group_count_z: u32, ) { - self.fp_v1_0() - .cmd_dispatch(command_buffer, group_count_x, group_count_y, group_count_z); + self.device_fn_1_0.cmd_dispatch( + command_buffer, + group_count_x, + group_count_y, + group_count_z, + ); } #[doc = ""] - unsafe fn cmd_dispatch_indirect( + pub unsafe fn cmd_dispatch_indirect( &self, command_buffer: vk::CommandBuffer, buffer: vk::Buffer, offset: vk::DeviceSize, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_dispatch_indirect(command_buffer, buffer, offset); } #[doc = ""] - unsafe fn cmd_set_viewport( + pub unsafe fn cmd_set_viewport( &self, command_buffer: vk::CommandBuffer, first_viewport: u32, viewports: &[vk::Viewport], ) { - self.fp_v1_0().cmd_set_viewport( + self.device_fn_1_0.cmd_set_viewport( command_buffer, first_viewport, viewports.len() as u32, @@ -1313,73 +1378,73 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_set_depth_bias( + pub unsafe fn cmd_set_depth_bias( &self, command_buffer: vk::CommandBuffer, constant_factor: f32, clamp: f32, slope_factor: f32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_set_depth_bias(command_buffer, constant_factor, clamp, slope_factor); } #[doc = ""] - unsafe fn cmd_set_blend_constants( + pub unsafe fn cmd_set_blend_constants( &self, command_buffer: vk::CommandBuffer, blend_constants: &[f32; 4], ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_set_blend_constants(command_buffer, blend_constants); } #[doc = ""] - unsafe fn cmd_set_depth_bounds( + pub unsafe fn cmd_set_depth_bounds( &self, command_buffer: vk::CommandBuffer, min_depth_bounds: f32, max_depth_bounds: f32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_set_depth_bounds(command_buffer, min_depth_bounds, max_depth_bounds); } #[doc = ""] - unsafe fn cmd_set_stencil_compare_mask( + pub unsafe fn cmd_set_stencil_compare_mask( &self, command_buffer: vk::CommandBuffer, face_mask: vk::StencilFaceFlags, compare_mask: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_set_stencil_compare_mask(command_buffer, face_mask, compare_mask); } #[doc = ""] - unsafe fn cmd_set_stencil_write_mask( + pub unsafe fn cmd_set_stencil_write_mask( &self, command_buffer: vk::CommandBuffer, face_mask: vk::StencilFaceFlags, write_mask: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_set_stencil_write_mask(command_buffer, face_mask, write_mask); } #[doc = ""] - unsafe fn cmd_set_stencil_reference( + pub unsafe fn cmd_set_stencil_reference( &self, command_buffer: vk::CommandBuffer, face_mask: vk::StencilFaceFlags, reference: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_set_stencil_reference(command_buffer, face_mask, reference); } #[doc = ""] - unsafe fn get_query_pool_results( + pub unsafe fn get_query_pool_results( &self, query_pool: vk::QueryPool, first_query: u32, @@ -1393,7 +1458,7 @@ pub trait DeviceV1_0 { "query_count was higher than the length of the slice" ); let data_size = mem::size_of::() * data_length; - self.fp_v1_0() + self.device_fn_1_0 .get_query_pool_results( self.handle(), query_pool, @@ -1408,60 +1473,60 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn cmd_begin_query( + pub unsafe fn cmd_begin_query( &self, command_buffer: vk::CommandBuffer, query_pool: vk::QueryPool, query: u32, flags: vk::QueryControlFlags, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_begin_query(command_buffer, query_pool, query, flags); } #[doc = ""] - unsafe fn cmd_end_query( + pub unsafe fn cmd_end_query( &self, command_buffer: vk::CommandBuffer, query_pool: vk::QueryPool, query: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_end_query(command_buffer, query_pool, query); } #[doc = ""] - unsafe fn cmd_reset_query_pool( + pub unsafe fn cmd_reset_query_pool( &self, command_buffer: vk::CommandBuffer, pool: vk::QueryPool, first_query: u32, query_count: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_reset_query_pool(command_buffer, pool, first_query, query_count); } #[doc = ""] - unsafe fn cmd_write_timestamp( + pub unsafe fn cmd_write_timestamp( &self, command_buffer: vk::CommandBuffer, pipeline_stage: vk::PipelineStageFlags, query_pool: vk::QueryPool, query: u32, ) { - self.fp_v1_0() + self.device_fn_1_0 .cmd_write_timestamp(command_buffer, pipeline_stage, query_pool, query); } #[doc = ""] - unsafe fn create_semaphore( + pub unsafe fn create_semaphore( &self, create_info: &vk::SemaphoreCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut semaphore = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_semaphore( self.handle(), create_info, @@ -1472,14 +1537,14 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_graphics_pipelines( + pub unsafe fn create_graphics_pipelines( &self, pipeline_cache: vk::PipelineCache, create_infos: &[vk::GraphicsPipelineCreateInfo], allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> Result, (Vec, vk::Result)> { let mut pipelines = Vec::with_capacity(create_infos.len()); - let err_code = self.fp_v1_0().create_graphics_pipelines( + let err_code = self.device_fn_1_0.create_graphics_pipelines( self.handle(), pipeline_cache, create_infos.len() as u32, @@ -1495,14 +1560,14 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_compute_pipelines( + pub unsafe fn create_compute_pipelines( &self, pipeline_cache: vk::PipelineCache, create_infos: &[vk::ComputePipelineCreateInfo], allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> Result, (Vec, vk::Result)> { let mut pipelines = Vec::with_capacity(create_infos.len()); - let err_code = self.fp_v1_0().create_compute_pipelines( + let err_code = self.device_fn_1_0.create_compute_pipelines( self.handle(), pipeline_cache, create_infos.len() as u32, @@ -1518,13 +1583,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_buffer( + pub unsafe fn create_buffer( &self, create_info: &vk::BufferCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut buffer = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_buffer( self.handle(), create_info, @@ -1535,13 +1600,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_pipeline_layout( + pub unsafe fn create_pipeline_layout( &self, create_info: &vk::PipelineLayoutCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut pipeline_layout = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_pipeline_layout( self.handle(), create_info, @@ -1552,13 +1617,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_pipeline_cache( + pub unsafe fn create_pipeline_cache( &self, create_info: &vk::PipelineCacheCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut pipeline_cache = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_pipeline_cache( self.handle(), create_info, @@ -1569,12 +1634,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn get_pipeline_cache_data( + pub unsafe fn get_pipeline_cache_data( &self, pipeline_cache: vk::PipelineCache, ) -> VkResult> { let mut data_size: usize = 0; - self.fp_v1_0() + self.device_fn_1_0 .get_pipeline_cache_data( self.handle(), pipeline_cache, @@ -1583,7 +1648,7 @@ pub trait DeviceV1_0 { ) .result()?; let mut data: Vec = Vec::with_capacity(data_size); - let err_code = self.fp_v1_0().get_pipeline_cache_data( + let err_code = self.device_fn_1_0.get_pipeline_cache_data( self.handle(), pipeline_cache, &mut data_size, @@ -1594,12 +1659,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn merge_pipeline_caches( + pub unsafe fn merge_pipeline_caches( &self, dst_cache: vk::PipelineCache, src_caches: &[vk::PipelineCache], ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .merge_pipeline_caches( self.handle(), dst_cache, @@ -1610,7 +1675,7 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn map_memory( + pub unsafe fn map_memory( &self, memory: vk::DeviceMemory, offset: vk::DeviceSize, @@ -1618,41 +1683,44 @@ pub trait DeviceV1_0 { flags: vk::MemoryMapFlags, ) -> VkResult<*mut c_void> { let mut data: *mut c_void = ptr::null_mut(); - self.fp_v1_0() + self.device_fn_1_0 .map_memory(self.handle(), memory, offset, size, flags, &mut data) .result_with_success(data) } #[doc = ""] - unsafe fn unmap_memory(&self, memory: vk::DeviceMemory) { - self.fp_v1_0().unmap_memory(self.handle(), memory); + pub unsafe fn unmap_memory(&self, memory: vk::DeviceMemory) { + self.device_fn_1_0.unmap_memory(self.handle(), memory); } #[doc = ""] - unsafe fn invalidate_mapped_memory_ranges( + pub unsafe fn invalidate_mapped_memory_ranges( &self, ranges: &[vk::MappedMemoryRange], ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .invalidate_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr()) .into() } #[doc = ""] - unsafe fn flush_mapped_memory_ranges(&self, ranges: &[vk::MappedMemoryRange]) -> VkResult<()> { - self.fp_v1_0() + pub unsafe fn flush_mapped_memory_ranges( + &self, + ranges: &[vk::MappedMemoryRange], + ) -> VkResult<()> { + self.device_fn_1_0 .flush_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr()) .into() } #[doc = ""] - unsafe fn create_framebuffer( + pub unsafe fn create_framebuffer( &self, create_info: &vk::FramebufferCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut framebuffer = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_framebuffer( self.handle(), create_info, @@ -1663,15 +1731,19 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn get_device_queue(&self, queue_family_index: u32, queue_index: u32) -> vk::Queue { + pub unsafe fn get_device_queue(&self, queue_family_index: u32, queue_index: u32) -> vk::Queue { let mut queue = mem::zeroed(); - self.fp_v1_0() - .get_device_queue(self.handle(), queue_family_index, queue_index, &mut queue); + self.device_fn_1_0.get_device_queue( + self.handle(), + queue_family_index, + queue_index, + &mut queue, + ); queue } #[doc = ""] - unsafe fn cmd_pipeline_barrier( + pub unsafe fn cmd_pipeline_barrier( &self, command_buffer: vk::CommandBuffer, src_stage_mask: vk::PipelineStageFlags, @@ -1681,7 +1753,7 @@ pub trait DeviceV1_0 { buffer_memory_barriers: &[vk::BufferMemoryBarrier], image_memory_barriers: &[vk::ImageMemoryBarrier], ) { - self.fp_v1_0().cmd_pipeline_barrier( + self.device_fn_1_0.cmd_pipeline_barrier( command_buffer, src_stage_mask, dst_stage_mask, @@ -1696,13 +1768,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_render_pass( + pub unsafe fn create_render_pass( &self, create_info: &vk::RenderPassCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut renderpass = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_render_pass( self.handle(), create_info, @@ -1713,29 +1785,29 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn begin_command_buffer( + pub unsafe fn begin_command_buffer( &self, command_buffer: vk::CommandBuffer, begin_info: &vk::CommandBufferBeginInfo, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .begin_command_buffer(command_buffer, begin_info) .into() } #[doc = ""] - unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> { - self.fp_v1_0().end_command_buffer(command_buffer).into() + pub unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> { + self.device_fn_1_0.end_command_buffer(command_buffer).into() } #[doc = ""] - unsafe fn wait_for_fences( + pub unsafe fn wait_for_fences( &self, fences: &[vk::Fence], wait_all: bool, timeout: u64, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .wait_for_fences( self.handle(), fences.len() as u32, @@ -1747,8 +1819,8 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn get_fence_status(&self, fence: vk::Fence) -> VkResult { - let err_code = self.fp_v1_0().get_fence_status(self.handle(), fence); + pub unsafe fn get_fence_status(&self, fence: vk::Fence) -> VkResult { + let err_code = self.device_fn_1_0.get_fence_status(self.handle(), fence); match err_code { vk::Result::SUCCESS => Ok(true), vk::Result::NOT_READY => Ok(false), @@ -1757,42 +1829,42 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> { - self.fp_v1_0().queue_wait_idle(queue).into() + pub unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> { + self.device_fn_1_0.queue_wait_idle(queue).into() } #[doc = ""] - unsafe fn queue_submit( + pub unsafe fn queue_submit( &self, queue: vk::Queue, submits: &[vk::SubmitInfo], fence: vk::Fence, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .queue_submit(queue, submits.len() as u32, submits.as_ptr(), fence) .into() } #[doc = ""] - unsafe fn queue_bind_sparse( + pub unsafe fn queue_bind_sparse( &self, queue: vk::Queue, bind_info: &[vk::BindSparseInfo], fence: vk::Fence, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .queue_bind_sparse(queue, bind_info.len() as u32, bind_info.as_ptr(), fence) .into() } #[doc = ""] - unsafe fn create_buffer_view( + pub unsafe fn create_buffer_view( &self, create_info: &vk::BufferViewCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut buffer_view = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_buffer_view( self.handle(), create_info, @@ -1803,12 +1875,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn destroy_buffer_view( + pub unsafe fn destroy_buffer_view( &self, buffer_view: vk::BufferView, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { - self.fp_v1_0().destroy_buffer_view( + self.device_fn_1_0.destroy_buffer_view( self.handle(), buffer_view, allocation_callbacks.as_raw_ptr(), @@ -1816,13 +1888,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_image_view( + pub unsafe fn create_image_view( &self, create_info: &vk::ImageViewCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut image_view = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_image_view( self.handle(), create_info, @@ -1833,12 +1905,12 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn allocate_command_buffers( + pub unsafe fn allocate_command_buffers( &self, create_info: &vk::CommandBufferAllocateInfo, ) -> VkResult> { let mut buffers = Vec::with_capacity(create_info.command_buffer_count as usize); - let err_code = self.fp_v1_0().allocate_command_buffers( + let err_code = self.device_fn_1_0.allocate_command_buffers( self.handle(), create_info, buffers.as_mut_ptr(), @@ -1848,13 +1920,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_command_pool( + pub unsafe fn create_command_pool( &self, create_info: &vk::CommandPoolCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut pool = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_command_pool( self.handle(), create_info, @@ -1865,13 +1937,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_query_pool( + pub unsafe fn create_query_pool( &self, create_info: &vk::QueryPoolCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut pool = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_query_pool( self.handle(), create_info, @@ -1882,13 +1954,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_image( + pub unsafe fn create_image( &self, create_info: &vk::ImageCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut image = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_image( self.handle(), create_info, @@ -1899,41 +1971,48 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn get_image_subresource_layout( + pub unsafe fn get_image_subresource_layout( &self, image: vk::Image, - subresource: &vk::ImageSubresource, + subresource: vk::ImageSubresource, ) -> vk::SubresourceLayout { let mut layout = mem::zeroed(); - self.fp_v1_0() - .get_image_subresource_layout(self.handle(), image, subresource, &mut layout); + self.device_fn_1_0.get_image_subresource_layout( + self.handle(), + image, + &subresource, + &mut layout, + ); layout } #[doc = ""] - unsafe fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements { + pub unsafe fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements { let mut mem_req = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .get_image_memory_requirements(self.handle(), image, &mut mem_req); mem_req } #[doc = ""] - unsafe fn get_buffer_memory_requirements(&self, buffer: vk::Buffer) -> vk::MemoryRequirements { + pub unsafe fn get_buffer_memory_requirements( + &self, + buffer: vk::Buffer, + ) -> vk::MemoryRequirements { let mut mem_req = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .get_buffer_memory_requirements(self.handle(), buffer, &mut mem_req); mem_req } #[doc = ""] - unsafe fn allocate_memory( + pub unsafe fn allocate_memory( &self, create_info: &vk::MemoryAllocateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut memory = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .allocate_memory( self.handle(), create_info, @@ -1944,13 +2023,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_shader_module( + pub unsafe fn create_shader_module( &self, create_info: &vk::ShaderModuleCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut shader = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_shader_module( self.handle(), create_info, @@ -1961,13 +2040,13 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn create_fence( + pub unsafe fn create_fence( &self, create_info: &vk::FenceCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut fence = mem::zeroed(); - self.fp_v1_0() + self.device_fn_1_0 .create_fence( self.handle(), create_info, @@ -1978,91 +2057,37 @@ pub trait DeviceV1_0 { } #[doc = ""] - unsafe fn bind_buffer_memory( + pub unsafe fn bind_buffer_memory( &self, buffer: vk::Buffer, device_memory: vk::DeviceMemory, offset: vk::DeviceSize, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .bind_buffer_memory(self.handle(), buffer, device_memory, offset) .into() } #[doc = ""] - unsafe fn bind_image_memory( + pub unsafe fn bind_image_memory( &self, image: vk::Image, device_memory: vk::DeviceMemory, offset: vk::DeviceSize, ) -> VkResult<()> { - self.fp_v1_0() + self.device_fn_1_0 .bind_image_memory(self.handle(), image, device_memory, offset) .into() } #[doc = ""] - unsafe fn get_render_area_granularity(&self, render_pass: vk::RenderPass) -> vk::Extent2D { + pub unsafe fn get_render_area_granularity(&self, render_pass: vk::RenderPass) -> vk::Extent2D { let mut granularity = mem::zeroed(); - self.fp_v1_0() - .get_render_area_granularity(self.handle(), render_pass, &mut granularity); + self.device_fn_1_0.get_render_area_granularity( + self.handle(), + render_pass, + &mut granularity, + ); granularity } } - -#[doc = ""] -#[derive(Clone)] -pub struct Device { - handle: vk::Device, - device_fn_1_0: vk::DeviceFnV1_0, - device_fn_1_1: vk::DeviceFnV1_1, - device_fn_1_2: vk::DeviceFnV1_2, -} - -impl Device { - pub unsafe fn load(instance_fn: &vk::InstanceFnV1_0, device: vk::Device) -> Self { - let device_fn_1_0 = vk::DeviceFnV1_0::load(|name| { - mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr())) - }); - let device_fn_1_1 = vk::DeviceFnV1_1::load(|name| { - mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr())) - }); - let device_fn_1_2 = vk::DeviceFnV1_2::load(|name| { - mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr())) - }); - Device { - handle: device, - device_fn_1_0, - device_fn_1_1, - device_fn_1_2, - } - } -} - -impl DeviceV1_0 for Device { - fn handle(&self) -> vk::Device { - self.handle - } - - fn fp_v1_0(&self) -> &vk::DeviceFnV1_0 { - &self.device_fn_1_0 - } -} - -impl DeviceV1_1 for Device { - fn fp_v1_1(&self) -> &vk::DeviceFnV1_1 { - &self.device_fn_1_1 - } -} - -impl DeviceV1_2 for Device { - fn fp_v1_2(&self) -> &vk::DeviceFnV1_2 { - &self.device_fn_1_2 - } -} - -impl Device { - pub fn handle(&self) -> vk::Device { - self.handle - } -} diff --git a/ash/src/entry.rs b/ash/src/entry.rs index 29fccbf..e3928b0 100644 --- a/ash/src/entry.rs +++ b/ash/src/entry.rs @@ -20,149 +20,8 @@ pub struct EntryCustom { lib: L, } -#[derive(Clone, Debug)] -pub enum InstanceError { - LoadError(Vec<&'static str>), - VkError(vk::Result), -} - -impl fmt::Display for InstanceError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - InstanceError::LoadError(e) => write!(f, "{}", e.join("; ")), - InstanceError::VkError(e) => write!(f, "{}", e), - } - } -} - -impl Error for InstanceError {} - +/// Vulkan core 1.0 #[allow(non_camel_case_types)] -pub trait EntryV1_0 { - type Instance; - fn fp_v1_0(&self) -> &vk::EntryFnV1_0; - fn static_fn(&self) -> &vk::StaticFn; - #[doc = ""] - /// - /// # Safety - /// In order for the created `Instance` to be valid for the duration of its - /// usage, the `Entry` this was called on must be dropped later than the - /// resulting `Instance`. - unsafe fn create_instance( - &self, - create_info: &vk::InstanceCreateInfo, - allocation_callbacks: Option<&vk::AllocationCallbacks>, - ) -> Result; - - #[doc = ""] - fn enumerate_instance_layer_properties(&self) -> VkResult> { - unsafe { - let mut num = 0; - self.fp_v1_0() - .enumerate_instance_layer_properties(&mut num, ptr::null_mut()) - .result()?; - let mut v = Vec::with_capacity(num as usize); - let err_code = self - .fp_v1_0() - .enumerate_instance_layer_properties(&mut num, v.as_mut_ptr()); - v.set_len(num as usize); - err_code.result_with_success(v) - } - } - - #[doc = ""] - fn enumerate_instance_extension_properties(&self) -> VkResult> { - unsafe { - let mut num = 0; - self.fp_v1_0() - .enumerate_instance_extension_properties(ptr::null(), &mut num, ptr::null_mut()) - .result()?; - let mut data = Vec::with_capacity(num as usize); - let err_code = self.fp_v1_0().enumerate_instance_extension_properties( - ptr::null(), - &mut num, - data.as_mut_ptr(), - ); - data.set_len(num as usize); - err_code.result_with_success(data) - } - } - - #[doc = ""] - unsafe fn get_instance_proc_addr( - &self, - instance: vk::Instance, - p_name: *const c_char, - ) -> vk::PFN_vkVoidFunction { - self.static_fn().get_instance_proc_addr(instance, p_name) - } -} - -impl EntryV1_0 for EntryCustom { - type Instance = Instance; - #[doc = ""] - /// - /// # Safety - /// In order for the created `Instance` to be valid for the duration of its - /// usage, the `Entry` this was called on must be dropped later than the - /// resulting `Instance`. - unsafe fn create_instance( - &self, - create_info: &vk::InstanceCreateInfo, - allocation_callbacks: Option<&vk::AllocationCallbacks>, - ) -> Result { - let mut instance: vk::Instance = mem::zeroed(); - self.fp_v1_0() - .create_instance( - create_info, - allocation_callbacks.as_raw_ptr(), - &mut instance, - ) - .result() - .map_err(InstanceError::VkError)?; - Ok(Instance::load(&self.static_fn, instance)) - } - fn fp_v1_0(&self) -> &vk::EntryFnV1_0 { - &self.entry_fn_1_0 - } - fn static_fn(&self) -> &vk::StaticFn { - &self.static_fn - } -} - -#[allow(non_camel_case_types)] -pub trait EntryV1_1: EntryV1_0 { - fn fp_v1_1(&self) -> &vk::EntryFnV1_1; - - #[deprecated = "This function is unavailable and therefore panics on Vulkan 1.0, please use `try_enumerate_instance_version` instead"] - #[doc = ""] - fn enumerate_instance_version(&self) -> VkResult { - unsafe { - let mut api_version = 0; - self.fp_v1_1() - .enumerate_instance_version(&mut api_version) - .result_with_success(api_version) - } - } -} - -impl EntryV1_1 for EntryCustom { - fn fp_v1_1(&self) -> &vk::EntryFnV1_1 { - &self.entry_fn_1_1 - } -} - -#[allow(non_camel_case_types)] -pub trait EntryV1_2: EntryV1_1 { - fn fp_v1_2(&self) -> &vk::EntryFnV1_2; -} - -impl EntryV1_2 for EntryCustom { - fn fp_v1_2(&self) -> &vk::EntryFnV1_2 { - &self.entry_fn_1_2 - } -} - impl EntryCustom { pub fn new_custom( mut lib: L, @@ -173,18 +32,12 @@ impl EntryCustom { { // Bypass the normal StaticFn::load so we can return an error let static_fn = vk::StaticFn::load_checked(|name| load(&mut lib, name))?; - - let entry_fn_1_0 = vk::EntryFnV1_0::load(|name| unsafe { + let load_fn = |name: &std::ffi::CStr| unsafe { mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr())) - }); - - let entry_fn_1_1 = vk::EntryFnV1_1::load(|name| unsafe { - mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr())) - }); - - let entry_fn_1_2 = vk::EntryFnV1_2::load(|name| unsafe { - mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr())) - }); + }; + let entry_fn_1_0 = vk::EntryFnV1_0::load(load_fn); + let entry_fn_1_1 = vk::EntryFnV1_1::load(load_fn); + let entry_fn_1_2 = vk::EntryFnV1_2::load(load_fn); Ok(EntryCustom { static_fn, @@ -195,6 +48,14 @@ impl EntryCustom { }) } + pub fn fp_v1_0(&self) -> &vk::EntryFnV1_0 { + &self.entry_fn_1_0 + } + + pub fn static_fn(&self) -> &vk::StaticFn { + &self.static_fn + } + #[doc = ""] /// ```no_run /// # use ash::{Entry, vk}; @@ -218,7 +79,7 @@ impl EntryCustom { let enumerate_instance_version: Option = { let name = b"vkEnumerateInstanceVersion\0".as_ptr() as *const _; mem::transmute( - self.static_fn() + self.static_fn .get_instance_proc_addr(vk::Instance::null(), name), ) }; @@ -230,8 +91,120 @@ impl EntryCustom { } } } + + #[doc = ""] + /// + /// # Safety + /// In order for the created `Instance` to be valid for the duration of its + /// usage, the `Entry` this was called on must be dropped later than the + /// resulting `Instance`. + pub unsafe fn create_instance( + &self, + create_info: &vk::InstanceCreateInfo, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> Result { + let mut instance: vk::Instance = mem::zeroed(); + self.entry_fn_1_0 + .create_instance( + create_info, + allocation_callbacks.as_raw_ptr(), + &mut instance, + ) + .result() + .map_err(InstanceError::VkError)?; + Ok(Instance::load(&self.static_fn, instance)) + } + + #[doc = ""] + pub fn enumerate_instance_layer_properties(&self) -> VkResult> { + unsafe { + let mut num = 0; + self.entry_fn_1_0 + .enumerate_instance_layer_properties(&mut num, ptr::null_mut()) + .result()?; + let mut v = Vec::with_capacity(num as usize); + let err_code = self + .entry_fn_1_0 + .enumerate_instance_layer_properties(&mut num, v.as_mut_ptr()); + v.set_len(num as usize); + err_code.result_with_success(v) + } + } + + #[doc = ""] + pub fn enumerate_instance_extension_properties( + &self, + ) -> VkResult> { + unsafe { + let mut num = 0; + self.entry_fn_1_0 + .enumerate_instance_extension_properties(ptr::null(), &mut num, ptr::null_mut()) + .result()?; + let mut data = Vec::with_capacity(num as usize); + let err_code = self.entry_fn_1_0.enumerate_instance_extension_properties( + ptr::null(), + &mut num, + data.as_mut_ptr(), + ); + data.set_len(num as usize); + err_code.result_with_success(data) + } + } + + #[doc = ""] + pub unsafe fn get_instance_proc_addr( + &self, + instance: vk::Instance, + p_name: *const c_char, + ) -> vk::PFN_vkVoidFunction { + self.static_fn.get_instance_proc_addr(instance, p_name) + } } +/// Vulkan core 1.1 +#[allow(non_camel_case_types)] +impl EntryCustom { + pub fn fp_v1_1(&self) -> &vk::EntryFnV1_1 { + &self.entry_fn_1_1 + } + + #[deprecated = "This function is unavailable and therefore panics on Vulkan 1.0, please use `try_enumerate_instance_version` instead"] + #[doc = ""] + pub fn enumerate_instance_version(&self) -> VkResult { + unsafe { + let mut api_version = 0; + self.entry_fn_1_1 + .enumerate_instance_version(&mut api_version) + .result_with_success(api_version) + } + } +} + +/// Vulkan core 1.2 +#[allow(non_camel_case_types)] +impl EntryCustom { + pub fn fp_v1_2(&self) -> &vk::EntryFnV1_2 { + &self.entry_fn_1_2 + } +} + +#[derive(Clone, Debug)] +pub enum InstanceError { + LoadError(Vec<&'static str>), + VkError(vk::Result), +} + +impl fmt::Display for InstanceError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + InstanceError::LoadError(e) => write!(f, "{}", e.join("; ")), + InstanceError::VkError(e) => write!(f, "{}", e), + } + } +} + +impl Error for InstanceError {} + impl vk::StaticFn { pub fn load_checked(mut _f: F) -> Result where diff --git a/ash/src/entry_libloading.rs b/ash/src/entry_libloading.rs index 8acb030..d9457b8 100644 --- a/ash/src/entry_libloading.rs +++ b/ash/src/entry_libloading.rs @@ -63,7 +63,7 @@ impl EntryCustom> { /// for [`Library::new`] and [`Library::get`] apply here. /// /// ```no_run - /// use ash::{vk, Entry, version::EntryV1_0}; + /// use ash::{vk, Entry}; /// # fn main() -> Result<(), Box> { /// let entry = unsafe { Entry::new() }?; /// let app_info = vk::ApplicationInfo { diff --git a/ash/src/extensions/ext/buffer_device_address.rs b/ash/src/extensions/ext/buffer_device_address.rs index a26bc81..3b1a36f 100644 --- a/ash/src/extensions/ext/buffer_device_address.rs +++ b/ash/src/extensions/ext/buffer_device_address.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct BufferDeviceAddress { } impl BufferDeviceAddress { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/ext/debug_marker.rs b/ash/src/extensions/ext/debug_marker.rs index 19fe5b8..2823dbb 100755 --- a/ash/src/extensions/ext/debug_marker.rs +++ b/ash/src/extensions/ext/debug_marker.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct DebugMarker { } impl DebugMarker { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/ext/debug_report.rs b/ash/src/extensions/ext/debug_report.rs index 675f2d6..6e3b967 100755 --- a/ash/src/extensions/ext/debug_report.rs +++ b/ash/src/extensions/ext/debug_report.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct DebugReport { } impl DebugReport { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let debug_report_fn = vk::ExtDebugReportFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/ext/debug_utils.rs b/ash/src/extensions/ext/debug_utils.rs index 67e13e0..3e05f7e 100755 --- a/ash/src/extensions/ext/debug_utils.rs +++ b/ash/src/extensions/ext/debug_utils.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::{vk, RawPtr}; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -12,7 +12,7 @@ pub struct DebugUtils { } impl DebugUtils { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let debug_utils_fn = vk::ExtDebugUtilsFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/ext/extended_dynamic_state.rs b/ash/src/extensions/ext/extended_dynamic_state.rs index 5ad7ae5..a8910ce 100644 --- a/ash/src/extensions/ext/extended_dynamic_state.rs +++ b/ash/src/extensions/ext/extended_dynamic_state.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -12,7 +12,7 @@ pub struct ExtendedDynamicState { } impl ExtendedDynamicState { - pub fn new(instance: &I, device: &D) -> Self { + pub fn new(instance: &Instance, device: &Device) -> Self { let extended_dynamic_state_fn = vk::ExtExtendedDynamicStateFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/ext/full_screen_exclusive.rs b/ash/src/extensions/ext/full_screen_exclusive.rs index 264b705..f76065f 100644 --- a/ash/src/extensions/ext/full_screen_exclusive.rs +++ b/ash/src/extensions/ext/full_screen_exclusive.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -13,7 +13,7 @@ pub struct FullScreenExclusive { } impl FullScreenExclusive { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/ext/metal_surface.rs b/ash/src/extensions/ext/metal_surface.rs index df4b09b..7168df1 100644 --- a/ash/src/extensions/ext/metal_surface.rs +++ b/ash/src/extensions/ext/metal_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct MetalSurface { } impl MetalSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::ExtMetalSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/ext/tooling_info.rs b/ash/src/extensions/ext/tooling_info.rs index 0323374..a225f6f 100644 --- a/ash/src/extensions/ext/tooling_info.rs +++ b/ash/src/extensions/ext/tooling_info.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -13,7 +13,7 @@ pub struct ToolingInfo { } impl ToolingInfo { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let tooling_info_fn = vk::ExtToolingInfoFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/acceleration_structure.rs b/ash/src/extensions/khr/acceleration_structure.rs index 1a24647..3834e4f 100644 --- a/ash/src/extensions/khr/acceleration_structure.rs +++ b/ash/src/extensions/khr/acceleration_structure.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; use crate::vk; use crate::RawPtr; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct AccelerationStructure { } impl AccelerationStructure { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); @@ -23,8 +23,8 @@ impl AccelerationStructure { } } - pub unsafe fn get_properties( - instance: &I, + pub unsafe fn get_properties( + instance: &Instance, pdevice: vk::PhysicalDevice, ) -> vk::PhysicalDeviceAccelerationStructurePropertiesKHR { let mut props_rt = vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default(); diff --git a/ash/src/extensions/khr/android_surface.rs b/ash/src/extensions/khr/android_surface.rs index 80728ab..ce3628f 100755 --- a/ash/src/extensions/khr/android_surface.rs +++ b/ash/src/extensions/khr/android_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct AndroidSurface { } impl AndroidSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::KhrAndroidSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/buffer_device_address.rs b/ash/src/extensions/khr/buffer_device_address.rs index 7b2f2bb..6a5c9f3 100644 --- a/ash/src/extensions/khr/buffer_device_address.rs +++ b/ash/src/extensions/khr/buffer_device_address.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct BufferDeviceAddress { } impl BufferDeviceAddress { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/create_render_pass2.rs b/ash/src/extensions/khr/create_render_pass2.rs index d45dfb8..0dbd0b0 100644 --- a/ash/src/extensions/khr/create_render_pass2.rs +++ b/ash/src/extensions/khr/create_render_pass2.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct CreateRenderPass2 { } impl CreateRenderPass2 { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/deferred_host_operations.rs b/ash/src/extensions/khr/deferred_host_operations.rs index e200013..970042f 100644 --- a/ash/src/extensions/khr/deferred_host_operations.rs +++ b/ash/src/extensions/khr/deferred_host_operations.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct DeferredHostOperations { } impl DeferredHostOperations { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/display.rs b/ash/src/extensions/khr/display.rs index 7569a8c..f963077 100755 --- a/ash/src/extensions/khr/display.rs +++ b/ash/src/extensions/khr/display.rs @@ -1,7 +1,7 @@ use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -13,7 +13,7 @@ pub struct Display { } impl Display { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let display_fn = vk::KhrDisplayFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/display_swapchain.rs b/ash/src/extensions/khr/display_swapchain.rs index 72a6a65..2bc7f2a 100755 --- a/ash/src/extensions/khr/display_swapchain.rs +++ b/ash/src/extensions/khr/display_swapchain.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct DisplaySwapchain { } impl DisplaySwapchain { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/draw_indirect_count.rs b/ash/src/extensions/khr/draw_indirect_count.rs index 84ebb87..d6f8ae2 100644 --- a/ash/src/extensions/khr/draw_indirect_count.rs +++ b/ash/src/extensions/khr/draw_indirect_count.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct DrawIndirectCount { } impl DrawIndirectCount { - pub fn new(instance: &I, device: &D) -> Self { + pub fn new(instance: &Instance, device: &Device) -> Self { let draw_indirect_count_fn = vk::KhrDrawIndirectCountFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/external_fence_fd.rs b/ash/src/extensions/khr/external_fence_fd.rs index 501f876..246cc7e 100644 --- a/ash/src/extensions/khr/external_fence_fd.rs +++ b/ash/src/extensions/khr/external_fence_fd.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct ExternalFenceFd { } impl ExternalFenceFd { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/external_memory_fd.rs b/ash/src/extensions/khr/external_memory_fd.rs index c4cb20f..7eeaa3e 100644 --- a/ash/src/extensions/khr/external_memory_fd.rs +++ b/ash/src/extensions/khr/external_memory_fd.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct ExternalMemoryFd { } impl ExternalMemoryFd { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/external_semaphore_fd.rs b/ash/src/extensions/khr/external_semaphore_fd.rs index 5ab3a3f..6d99201 100644 --- a/ash/src/extensions/khr/external_semaphore_fd.rs +++ b/ash/src/extensions/khr/external_semaphore_fd.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct ExternalSemaphoreFd { } impl ExternalSemaphoreFd { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/get_memory_requirements2.rs b/ash/src/extensions/khr/get_memory_requirements2.rs index 692a6ab..9f9b5f4 100644 --- a/ash/src/extensions/khr/get_memory_requirements2.rs +++ b/ash/src/extensions/khr/get_memory_requirements2.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -12,7 +12,7 @@ pub struct GetMemoryRequirements2 { } impl GetMemoryRequirements2 { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/get_physical_device_properties2.rs b/ash/src/extensions/khr/get_physical_device_properties2.rs index b3ab220..94058f9 100644 --- a/ash/src/extensions/khr/get_physical_device_properties2.rs +++ b/ash/src/extensions/khr/get_physical_device_properties2.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -13,7 +13,7 @@ pub struct GetPhysicalDeviceProperties2 { } impl GetPhysicalDeviceProperties2 { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, 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())) diff --git a/ash/src/extensions/khr/maintenance1.rs b/ash/src/extensions/khr/maintenance1.rs index 24e5fa5..2480143 100644 --- a/ash/src/extensions/khr/maintenance1.rs +++ b/ash/src/extensions/khr/maintenance1.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct Maintenance1 { } impl Maintenance1 { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/maintenance3.rs b/ash/src/extensions/khr/maintenance3.rs index 9ef9b26..ad6c3c6 100644 --- a/ash/src/extensions/khr/maintenance3.rs +++ b/ash/src/extensions/khr/maintenance3.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -11,7 +11,7 @@ pub struct Maintenance3 { } impl Maintenance3 { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/pipeline_executable_properties.rs b/ash/src/extensions/khr/pipeline_executable_properties.rs index 485eda1..88a9e67 100644 --- a/ash/src/extensions/khr/pipeline_executable_properties.rs +++ b/ash/src/extensions/khr/pipeline_executable_properties.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -13,7 +13,7 @@ pub struct PipelineExecutableProperties { } impl PipelineExecutableProperties { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let pipeline_executable_properties_fn = vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) diff --git a/ash/src/extensions/khr/push_descriptor.rs b/ash/src/extensions/khr/push_descriptor.rs index 1daf592..9fc221d 100644 --- a/ash/src/extensions/khr/push_descriptor.rs +++ b/ash/src/extensions/khr/push_descriptor.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::c_void; use std::ffi::CStr; use std::mem; @@ -12,7 +12,7 @@ pub struct PushDescriptor { } impl PushDescriptor { - pub fn new(instance: &I, device: &D) -> Self { + pub fn new(instance: &Instance, device: &Device) -> Self { let push_descriptors_fn = vk::KhrPushDescriptorFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/ray_tracing_pipeline.rs b/ash/src/extensions/khr/ray_tracing_pipeline.rs index 3b3f23c..6d2786b 100644 --- a/ash/src/extensions/khr/ray_tracing_pipeline.rs +++ b/ash/src/extensions/khr/ray_tracing_pipeline.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; use crate::vk; use crate::RawPtr; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct RayTracingPipeline { } impl RayTracingPipeline { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); @@ -23,8 +23,8 @@ impl RayTracingPipeline { } } - pub unsafe fn get_properties( - instance: &I, + pub unsafe fn get_properties( + instance: &Instance, pdevice: vk::PhysicalDevice, ) -> vk::PhysicalDeviceRayTracingPipelinePropertiesKHR { let mut props_rt = vk::PhysicalDeviceRayTracingPipelinePropertiesKHR::default(); diff --git a/ash/src/extensions/khr/surface.rs b/ash/src/extensions/khr/surface.rs index 84c0b5b..57c8b9d 100755 --- a/ash/src/extensions/khr/surface.rs +++ b/ash/src/extensions/khr/surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -14,7 +14,7 @@ pub struct Surface { } impl Surface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::KhrSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/swapchain.rs b/ash/src/extensions/khr/swapchain.rs index 3969f1b..05e14f3 100755 --- a/ash/src/extensions/khr/swapchain.rs +++ b/ash/src/extensions/khr/swapchain.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; use std::ptr; @@ -14,7 +14,7 @@ pub struct Swapchain { } impl Swapchain { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); diff --git a/ash/src/extensions/khr/timeline_semaphore.rs b/ash/src/extensions/khr/timeline_semaphore.rs index e1a7aa7..1b1806e 100644 --- a/ash/src/extensions/khr/timeline_semaphore.rs +++ b/ash/src/extensions/khr/timeline_semaphore.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -12,7 +12,7 @@ pub struct TimelineSemaphore { } impl TimelineSemaphore { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let timeline_semaphore_fn = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/wayland_surface.rs b/ash/src/extensions/khr/wayland_surface.rs index 1b34a6d..e49d8b9 100755 --- a/ash/src/extensions/khr/wayland_surface.rs +++ b/ash/src/extensions/khr/wayland_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct WaylandSurface { } impl WaylandSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::KhrWaylandSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/win32_surface.rs b/ash/src/extensions/khr/win32_surface.rs index 632fa0f..155d957 100755 --- a/ash/src/extensions/khr/win32_surface.rs +++ b/ash/src/extensions/khr/win32_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct Win32Surface { } impl Win32Surface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/xcb_surface.rs b/ash/src/extensions/khr/xcb_surface.rs index 3a433cb..78d7ca3 100755 --- a/ash/src/extensions/khr/xcb_surface.rs +++ b/ash/src/extensions/khr/xcb_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct XcbSurface { } impl XcbSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/khr/xlib_surface.rs b/ash/src/extensions/khr/xlib_surface.rs index 15cbc8c..1ba318d 100755 --- a/ash/src/extensions/khr/xlib_surface.rs +++ b/ash/src/extensions/khr/xlib_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct XlibSurface { } impl XlibSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::KhrXlibSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/mvk/ios_surface.rs b/ash/src/extensions/mvk/ios_surface.rs index 7044bf8..08544b6 100755 --- a/ash/src/extensions/mvk/ios_surface.rs +++ b/ash/src/extensions/mvk/ios_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct IOSSurface { } impl IOSSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::MvkIosSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/mvk/macos_surface.rs b/ash/src/extensions/mvk/macos_surface.rs index 02a2208..dc003d0 100755 --- a/ash/src/extensions/mvk/macos_surface.rs +++ b/ash/src/extensions/mvk/macos_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct MacOSSurface { } impl MacOSSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::MvkMacosSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/nn/vi_surface.rs b/ash/src/extensions/nn/vi_surface.rs index be3ca10..19040aa 100644 --- a/ash/src/extensions/nn/vi_surface.rs +++ b/ash/src/extensions/nn/vi_surface.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use crate::{EntryCustom, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct ViSurface { } impl ViSurface { - pub fn new(entry: &E, instance: &I) -> Self { + pub fn new(entry: &EntryCustom, instance: &Instance) -> Self { let surface_fn = vk::NnViSurfaceFn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/nv/device_diagnostic_checkpoints.rs b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs index 6abc2f2..137a443 100644 --- a/ash/src/extensions/nv/device_diagnostic_checkpoints.rs +++ b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; use std::os::raw::c_void; @@ -11,7 +11,7 @@ pub struct DeviceDiagnosticCheckpoints { } impl DeviceDiagnosticCheckpoints { - pub fn new(instance: &I, device: &D) -> Self { + 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())) diff --git a/ash/src/extensions/nv/mesh_shader.rs b/ash/src/extensions/nv/mesh_shader.rs index a3f838f..388f473 100755 --- a/ash/src/extensions/nv/mesh_shader.rs +++ b/ash/src/extensions/nv/mesh_shader.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -10,7 +10,7 @@ pub struct MeshShader { } impl MeshShader { - pub fn new(instance: &I, device: &D) -> Self { + pub fn new(instance: &Instance, device: &Device) -> Self { let mesh_shader_fn = vk::NvMeshShaderFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); diff --git a/ash/src/extensions/nv/ray_tracing.rs b/ash/src/extensions/nv/ray_tracing.rs index 7fedc88..6f5fc62 100755 --- a/ash/src/extensions/nv/ray_tracing.rs +++ b/ash/src/extensions/nv/ray_tracing.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use crate::prelude::*; -use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; use crate::vk; use crate::RawPtr; +use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; @@ -13,7 +13,7 @@ pub struct RayTracing { } impl RayTracing { - pub fn new(instance: &I, device: &D) -> Self { + 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())) }); @@ -23,8 +23,8 @@ impl RayTracing { } } - pub unsafe fn get_properties( - instance: &I, + pub unsafe fn get_properties( + instance: &Instance, pdevice: vk::PhysicalDevice, ) -> vk::PhysicalDeviceRayTracingPropertiesNV { let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesNV::default(); diff --git a/ash/src/instance.rs b/ash/src/instance.rs index e36f4df..b74c65b 100644 --- a/ash/src/instance.rs +++ b/ash/src/instance.rs @@ -10,146 +10,107 @@ use std::ptr; #[doc = ""] #[derive(Clone)] pub struct Instance { - handle: vk::Instance, - instance_fn_1_0: vk::InstanceFnV1_0, - instance_fn_1_1: vk::InstanceFnV1_1, - instance_fn_1_2: vk::InstanceFnV1_2, + pub(crate) handle: vk::Instance, + + pub(crate) instance_fn_1_0: vk::InstanceFnV1_0, + pub(crate) instance_fn_1_1: vk::InstanceFnV1_1, + pub(crate) instance_fn_1_2: vk::InstanceFnV1_2, } + impl Instance { pub unsafe fn load(static_fn: &vk::StaticFn, instance: vk::Instance) -> Self { - let instance_fn_1_0 = vk::InstanceFnV1_0::load(|name| { + let load_fn = |name: &std::ffi::CStr| { mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr())) - }); - let instance_fn_1_1 = vk::InstanceFnV1_1::load(|name| { - mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr())) - }); - let instance_fn_1_2 = vk::InstanceFnV1_2::load(|name| { - mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr())) - }); + }; Instance { handle: instance, - instance_fn_1_0, - instance_fn_1_1, - instance_fn_1_2, + + instance_fn_1_0: vk::InstanceFnV1_0::load(load_fn), + instance_fn_1_1: vk::InstanceFnV1_1::load(load_fn), + instance_fn_1_2: vk::InstanceFnV1_2::load(load_fn), } } -} -impl InstanceV1_0 for Instance { - type Device = Device; - #[doc = ""] - /// - /// # Safety - /// In order for the created `Device` to be valid for the duration of its - /// usage, the `Instance` this was called on must be dropped later than the - /// resulting `Device`. - unsafe fn create_device( - &self, - physical_device: vk::PhysicalDevice, - create_info: &vk::DeviceCreateInfo, - allocation_callbacks: Option<&vk::AllocationCallbacks>, - ) -> VkResult { - let mut device: vk::Device = mem::zeroed(); - self.fp_v1_0() - .create_device( - physical_device, - create_info, - allocation_callbacks.as_raw_ptr(), - &mut device, - ) - .result()?; - Ok(Device::load(&self.instance_fn_1_0, device)) - } - fn handle(&self) -> vk::Instance { + pub fn handle(&self) -> vk::Instance { self.handle } - - fn fp_v1_0(&self) -> &vk::InstanceFnV1_0 { - &self.instance_fn_1_0 - } } -impl InstanceV1_1 for Instance { - fn fp_v1_1(&self) -> &vk::InstanceFnV1_1 { - &self.instance_fn_1_1 - } -} - -impl InstanceV1_2 for Instance { - fn fp_v1_2(&self) -> &vk::InstanceFnV1_2 { +/// Vulkan core 1.2 +#[allow(non_camel_case_types)] +impl Instance { + pub fn fp_v1_2(&self) -> &vk::InstanceFnV1_2 { &self.instance_fn_1_2 } } +/// Vulkan core 1.1 #[allow(non_camel_case_types)] -pub trait InstanceV1_2: InstanceV1_1 { - fn fp_v1_2(&self) -> &vk::InstanceFnV1_2; -} +impl Instance { + pub fn fp_v1_1(&self) -> &vk::InstanceFnV1_1 { + &self.instance_fn_1_1 + } -#[allow(non_camel_case_types)] -pub trait InstanceV1_1: InstanceV1_0 { - fn fp_v1_1(&self) -> &vk::InstanceFnV1_1; - - unsafe fn enumerate_physical_device_groups_len(&self) -> VkResult { + pub unsafe fn enumerate_physical_device_groups_len(&self) -> VkResult { let mut group_count = mem::zeroed(); - self.fp_v1_1() + self.instance_fn_1_1 .enumerate_physical_device_groups(self.handle(), &mut group_count, ptr::null_mut()) .result_with_success(group_count as usize) } #[doc = ""] - fn enumerate_physical_device_groups( + pub fn enumerate_physical_device_groups( &self, out: &mut [vk::PhysicalDeviceGroupProperties], ) -> VkResult<()> { unsafe { let mut group_count = out.len() as u32; - self.fp_v1_1() + self.instance_fn_1_1 .enumerate_physical_device_groups(self.handle(), &mut group_count, out.as_mut_ptr()) .into() } } #[doc = ""] - unsafe fn get_physical_device_features2( + pub unsafe fn get_physical_device_features2( &self, physical_device: vk::PhysicalDevice, features: &mut vk::PhysicalDeviceFeatures2, ) { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_features2(physical_device, features); } #[doc = ""] - unsafe fn get_physical_device_properties2( + pub unsafe fn get_physical_device_properties2( &self, physical_device: vk::PhysicalDevice, prop: &mut vk::PhysicalDeviceProperties2, ) { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_properties2(physical_device, prop); } #[doc = ""] - unsafe fn get_physical_device_format_properties2( + pub unsafe fn get_physical_device_format_properties2( &self, physical_device: vk::PhysicalDevice, format: vk::Format, out: &mut vk::FormatProperties2, ) { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_format_properties2(physical_device, format, out); } #[doc = ""] - unsafe fn get_physical_device_image_format_properties2( + pub unsafe fn get_physical_device_image_format_properties2( &self, physical_device: vk::PhysicalDevice, format_info: &vk::PhysicalDeviceImageFormatInfo2, image_format_prop: &mut vk::ImageFormatProperties2, ) -> VkResult<()> { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_image_format_properties2( physical_device, format_info, @@ -158,50 +119,52 @@ pub trait InstanceV1_1: InstanceV1_0 { .into() } - unsafe fn get_physical_device_queue_family_properties2_len( + pub unsafe fn get_physical_device_queue_family_properties2_len( &self, physical_device: vk::PhysicalDevice, ) -> usize { let mut queue_count = 0; - self.fp_v1_1().get_physical_device_queue_family_properties2( - physical_device, - &mut queue_count, - ptr::null_mut(), - ); + self.instance_fn_1_1 + .get_physical_device_queue_family_properties2( + physical_device, + &mut queue_count, + ptr::null_mut(), + ); queue_count as usize } #[doc = ""] - unsafe fn get_physical_device_queue_family_properties2( + pub unsafe fn get_physical_device_queue_family_properties2( &self, physical_device: vk::PhysicalDevice, queue_family_props: &mut [vk::QueueFamilyProperties2], ) { let mut queue_count = queue_family_props.len() as u32; - self.fp_v1_1().get_physical_device_queue_family_properties2( - physical_device, - &mut queue_count, - queue_family_props.as_mut_ptr(), - ); + self.instance_fn_1_1 + .get_physical_device_queue_family_properties2( + physical_device, + &mut queue_count, + queue_family_props.as_mut_ptr(), + ); } #[doc = ""] - unsafe fn get_physical_device_memory_properties2( + pub unsafe fn get_physical_device_memory_properties2( &self, physical_device: vk::PhysicalDevice, out: &mut vk::PhysicalDeviceMemoryProperties2, ) { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_memory_properties2(physical_device, out); } - unsafe fn get_physical_device_sparse_image_format_properties2_len( + pub unsafe fn get_physical_device_sparse_image_format_properties2_len( &self, physical_device: vk::PhysicalDevice, format_info: &vk::PhysicalDeviceSparseImageFormatInfo2, ) -> usize { let mut format_count = 0; - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_sparse_image_format_properties2( physical_device, format_info, @@ -212,14 +175,14 @@ pub trait InstanceV1_1: InstanceV1_0 { } #[doc = ""] - unsafe fn get_physical_device_sparse_image_format_properties2( + pub unsafe fn get_physical_device_sparse_image_format_properties2( &self, physical_device: vk::PhysicalDevice, format_info: &vk::PhysicalDeviceSparseImageFormatInfo2, out: &mut [vk::SparseImageFormatProperties2], ) { let mut format_count = out.len() as u32; - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_sparse_image_format_properties2( physical_device, format_info, @@ -229,13 +192,13 @@ pub trait InstanceV1_1: InstanceV1_0 { } #[doc = ""] - unsafe fn get_physical_device_external_buffer_properties( + pub unsafe fn get_physical_device_external_buffer_properties( &self, physical_device: vk::PhysicalDevice, external_buffer_info: &vk::PhysicalDeviceExternalBufferInfo, out: &mut vk::ExternalBufferProperties, ) { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_external_buffer_properties( physical_device, external_buffer_info, @@ -244,13 +207,13 @@ pub trait InstanceV1_1: InstanceV1_0 { } #[doc = ""] - unsafe fn get_physical_device_external_fence_properties( + pub unsafe fn get_physical_device_external_fence_properties( &self, physical_device: vk::PhysicalDevice, external_fence_info: &vk::PhysicalDeviceExternalFenceInfo, out: &mut vk::ExternalFenceProperties, ) { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_external_fence_properties( physical_device, external_fence_info, @@ -259,13 +222,13 @@ pub trait InstanceV1_1: InstanceV1_0 { } #[doc = ""] - unsafe fn get_physical_device_external_semaphore_properties( + pub unsafe fn get_physical_device_external_semaphore_properties( &self, physical_device: vk::PhysicalDevice, external_semaphore_info: &vk::PhysicalDeviceExternalSemaphoreInfo, out: &mut vk::ExternalSemaphoreProperties, ) { - self.fp_v1_1() + self.instance_fn_1_1 .get_physical_device_external_semaphore_properties( physical_device, external_semaphore_info, @@ -274,47 +237,60 @@ pub trait InstanceV1_1: InstanceV1_0 { } } +/// Vulkan core 1.0 #[allow(non_camel_case_types)] -pub trait InstanceV1_0 { - type Device; - fn handle(&self) -> vk::Instance; - fn fp_v1_0(&self) -> &vk::InstanceFnV1_0; +impl Instance { + pub fn fp_v1_0(&self) -> &vk::InstanceFnV1_0 { + &self.instance_fn_1_0 + } + #[doc = ""] /// /// # Safety /// In order for the created `Device` to be valid for the duration of its /// usage, the `Instance` this was called on must be dropped later than the /// resulting `Device`. - unsafe fn create_device( + pub unsafe fn create_device( &self, physical_device: vk::PhysicalDevice, create_info: &vk::DeviceCreateInfo, allocation_callbacks: Option<&vk::AllocationCallbacks>, - ) -> VkResult; + ) -> VkResult { + let mut device: vk::Device = mem::zeroed(); + self.instance_fn_1_0 + .create_device( + physical_device, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut device, + ) + .result()?; + Ok(Device::load(&self.instance_fn_1_0, device)) + } #[doc = ""] - unsafe fn get_device_proc_addr( + pub unsafe fn get_device_proc_addr( &self, device: vk::Device, p_name: *const c_char, ) -> vk::PFN_vkVoidFunction { - self.fp_v1_0().get_device_proc_addr(device, p_name) + self.instance_fn_1_0.get_device_proc_addr(device, p_name) } #[doc = ""] - unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0() + pub unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) { + self.instance_fn_1_0 .destroy_instance(self.handle(), allocation_callbacks.as_raw_ptr()); } #[doc = ""] - unsafe fn get_physical_device_format_properties( + pub unsafe fn get_physical_device_format_properties( &self, physical_device: vk::PhysicalDevice, format: vk::Format, ) -> vk::FormatProperties { let mut format_prop = mem::zeroed(); - self.fp_v1_0().get_physical_device_format_properties( + self.instance_fn_1_0.get_physical_device_format_properties( physical_device, format, &mut format_prop, @@ -323,7 +299,7 @@ pub trait InstanceV1_0 { } #[doc = ""] - unsafe fn get_physical_device_image_format_properties( + pub unsafe fn get_physical_device_image_format_properties( &self, physical_device: vk::PhysicalDevice, format: vk::Format, @@ -333,7 +309,7 @@ pub trait InstanceV1_0 { flags: vk::ImageCreateFlags, ) -> VkResult { let mut image_format_prop = mem::zeroed(); - self.fp_v1_0() + self.instance_fn_1_0 .get_physical_device_image_format_properties( physical_device, format, @@ -347,67 +323,69 @@ pub trait InstanceV1_0 { } #[doc = ""] - unsafe fn get_physical_device_memory_properties( + pub unsafe fn get_physical_device_memory_properties( &self, physical_device: vk::PhysicalDevice, ) -> vk::PhysicalDeviceMemoryProperties { let mut memory_prop = mem::zeroed(); - self.fp_v1_0() + self.instance_fn_1_0 .get_physical_device_memory_properties(physical_device, &mut memory_prop); memory_prop } #[doc = ""] - unsafe fn get_physical_device_properties( + pub unsafe fn get_physical_device_properties( &self, physical_device: vk::PhysicalDevice, ) -> vk::PhysicalDeviceProperties { let mut prop = mem::zeroed(); - self.fp_v1_0() + self.instance_fn_1_0 .get_physical_device_properties(physical_device, &mut prop); prop } #[doc = ""] - unsafe fn get_physical_device_queue_family_properties( + pub unsafe fn get_physical_device_queue_family_properties( &self, physical_device: vk::PhysicalDevice, ) -> Vec { let mut queue_count = 0; - self.fp_v1_0().get_physical_device_queue_family_properties( - physical_device, - &mut queue_count, - ptr::null_mut(), - ); + self.instance_fn_1_0 + .get_physical_device_queue_family_properties( + physical_device, + &mut queue_count, + ptr::null_mut(), + ); let mut queue_families_vec = Vec::with_capacity(queue_count as usize); - self.fp_v1_0().get_physical_device_queue_family_properties( - physical_device, - &mut queue_count, - queue_families_vec.as_mut_ptr(), - ); + self.instance_fn_1_0 + .get_physical_device_queue_family_properties( + physical_device, + &mut queue_count, + queue_families_vec.as_mut_ptr(), + ); queue_families_vec.set_len(queue_count as usize); queue_families_vec } #[doc = ""] - unsafe fn get_physical_device_features( + pub unsafe fn get_physical_device_features( &self, physical_device: vk::PhysicalDevice, ) -> vk::PhysicalDeviceFeatures { let mut prop = mem::zeroed(); - self.fp_v1_0() + self.instance_fn_1_0 .get_physical_device_features(physical_device, &mut prop); prop } #[doc = ""] - unsafe fn enumerate_physical_devices(&self) -> VkResult> { + pub unsafe fn enumerate_physical_devices(&self) -> VkResult> { let mut num = mem::zeroed(); - self.fp_v1_0() + self.instance_fn_1_0 .enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut()) .result()?; let mut physical_devices = Vec::::with_capacity(num as usize); - let err_code = self.fp_v1_0().enumerate_physical_devices( + let err_code = self.instance_fn_1_0.enumerate_physical_devices( self.handle(), &mut num, physical_devices.as_mut_ptr(), @@ -417,16 +395,16 @@ pub trait InstanceV1_0 { } #[doc = ""] - unsafe fn enumerate_device_extension_properties( + pub unsafe fn enumerate_device_extension_properties( &self, device: vk::PhysicalDevice, ) -> VkResult> { let mut num = 0; - self.fp_v1_0() + self.instance_fn_1_0 .enumerate_device_extension_properties(device, ptr::null(), &mut num, ptr::null_mut()) .result()?; let mut data = Vec::with_capacity(num as usize); - let err_code = self.fp_v1_0().enumerate_device_extension_properties( + let err_code = self.instance_fn_1_0.enumerate_device_extension_properties( device, ptr::null(), &mut num, diff --git a/ash/src/lib.rs b/ash/src/lib.rs index f451002..70a40a6 100644 --- a/ash/src/lib.rs +++ b/ash/src/lib.rs @@ -10,7 +10,7 @@ //! ## Examples //! //! ```no_run -//! use ash::{vk, Entry, version::EntryV1_0}; +//! use ash::{vk, Entry}; //! # fn main() -> Result<(), Box> { //! let entry = unsafe { Entry::new() }?; //! let app_info = vk::ApplicationInfo { @@ -39,7 +39,6 @@ mod entry_libloading; mod instance; pub mod prelude; pub mod util; -pub mod version; #[macro_use] pub mod vk; diff --git a/ash/tests/constant_size_arrays.rs b/ash/tests/constant_size_arrays.rs index 28fcd80..a756f34 100644 --- a/ash/tests/constant_size_arrays.rs +++ b/ash/tests/constant_size_arrays.rs @@ -24,7 +24,6 @@ fn assert_struct_field_is_array() { #[test] #[allow(dead_code)] fn assert_ffi_array_param_is_pointer() { - use ash::version::DeviceV1_0; // don't run it, just make sure it compiles unsafe fn dummy(device: &ash::Device, cmd_buffer: ash::vk::CommandBuffer) { let blend_constants: [f32; 4] = [0.0, 0.0, 0.0, 0.0]; diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 13605d5..bea1913 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -6,8 +6,8 @@ use ash::extensions::{ khr::{Surface, Swapchain}, }; -pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0}; -use ash::{vk, Device, Entry, Instance}; +use ash::{vk, Entry}; +pub use ash::{Device, EntryCustom, Instance}; use std::borrow::Cow; use std::cell::RefCell; use std::default::Default; @@ -29,8 +29,8 @@ macro_rules! offset_of { /// is executed. That way we can delay the waiting for the fences by 1 frame which is good for performance. /// Make sure to create the fence in a signaled state on the first use. #[allow(clippy::too_many_arguments)] -pub fn record_submit_commandbuffer( - device: &D, +pub fn record_submit_commandbuffer( + device: &Device, command_buffer: vk::CommandBuffer, command_buffer_reuse_fence: vk::Fence, submit_queue: vk::Queue, @@ -279,7 +279,7 @@ impl ExampleBase { }) .next() }) - .filter_map(|v| v) + .flatten() .next() .expect("Couldn't find suitable device."); let queue_family_index = queue_family_index as u32;