extensions: make naming and layout consistent across all extensions (#494)

* extensions: Make naming and layout consistent across all extensions

breaking change:
- some extensions were exposing `instance()` instead of `device()`

includes:
- renaming function pointer member to `fns`
- moving `name()`, `fp(`), `device()`/`instance()` functions at end of file
- adding missing `device()`/`instance()` functions

see https://github.com/MaikKlein/ash/pull/493

* debug_marker: Remove unneeded `device` from `debug_marker_set_object_name()`

* extensions: Remove unneeded `instance` and `device` struct members and functions

* extensions: renamed all `fns` fields to `fp` to match `pub fn fp()` getter
This commit is contained in:
Philippe Renon 2021-12-11 13:19:34 +01:00 committed by GitHub
parent 0cddbad618
commit 289a57e330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 719 additions and 859 deletions

View file

@ -8,7 +8,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Add `VK_KHR_present_wait` extension (#493) - Added `VK_KHR_present_wait` device extension (#493)
### Changed
- Device extension `khr::PipelineExecutableProperties` and `khr::TimelineSemaphore` now expose `fn device()` instead of `fn instance()` (#499)
- Changed `khr::PipelineExecutableProperties::new()` and `khr::TimelineSemaphore::new()` to take `instance` and `device` as arguments (#499)
### Removed
- Removed `device()` function from `khr::Synchronization2` device extension (#494)
- Removed `instance()` function from `ext::ExtendedDynamicState`, `khr::PushDescriptor`, `ext::ToolingInfo` and `khr::GetPhysicalDeviceProperties2` instance extensions (#494)
- Removed `device` argument from `ext::DebugMarkers::debug_marker_set_object_name` function (#494)
- Removed `From<vk::Result>` trait for `VkResult` (#495)
- Removed `instance` argument from `ext::DebugUtils::submit_debug_utils_message` function (#499)
## [0.33.3] - 2021-09-08 ## [0.33.3] - 2021-09-08

View file

@ -6,18 +6,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct BufferDeviceAddress { pub struct BufferDeviceAddress {
handle: vk::Device, handle: vk::Device,
fns: vk::ExtBufferDeviceAddressFn, fp: vk::ExtBufferDeviceAddressFn,
} }
impl BufferDeviceAddress { impl BufferDeviceAddress {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let fns = vk::ExtBufferDeviceAddressFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::ExtBufferDeviceAddressFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
fns,
}
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressEXT.html>"]
@ -25,7 +23,7 @@ impl BufferDeviceAddress {
&self, &self,
info: &vk::BufferDeviceAddressInfoEXT, info: &vk::BufferDeviceAddressInfoEXT,
) -> vk::DeviceAddress { ) -> vk::DeviceAddress {
self.fns.get_buffer_device_address_ext(self.handle, info) self.fp.get_buffer_device_address_ext(self.handle, info)
} }
pub fn name() -> &'static CStr { pub fn name() -> &'static CStr {
@ -33,7 +31,7 @@ impl BufferDeviceAddress {
} }
pub fn fp(&self) -> &vk::ExtBufferDeviceAddressFn { pub fn fp(&self) -> &vk::ExtBufferDeviceAddressFn {
&self.fns &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -6,29 +6,26 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct DebugMarker { pub struct DebugMarker {
debug_marker_fn: vk::ExtDebugMarkerFn, handle: vk::Device,
fp: vk::ExtDebugMarkerFn,
} }
impl DebugMarker { impl DebugMarker {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let debug_marker_fn = vk::ExtDebugMarkerFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::ExtDebugMarkerFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { debug_marker_fn } Self { handle, fp }
}
pub fn name() -> &'static CStr {
vk::ExtDebugMarkerFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>"]
pub unsafe fn debug_marker_set_object_name( pub unsafe fn debug_marker_set_object_name(
&self, &self,
device: vk::Device,
name_info: &vk::DebugMarkerObjectNameInfoEXT, name_info: &vk::DebugMarkerObjectNameInfoEXT,
) -> VkResult<()> { ) -> VkResult<()> {
self.debug_marker_fn self.fp
.debug_marker_set_object_name_ext(device, name_info) .debug_marker_set_object_name_ext(self.handle, name_info)
.result() .result()
} }
@ -38,14 +35,13 @@ impl DebugMarker {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
marker_info: &vk::DebugMarkerMarkerInfoEXT, marker_info: &vk::DebugMarkerMarkerInfoEXT,
) { ) {
self.debug_marker_fn self.fp
.cmd_debug_marker_begin_ext(command_buffer, marker_info); .cmd_debug_marker_begin_ext(command_buffer, marker_info);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerEndEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerEndEXT.html>"]
pub unsafe fn cmd_debug_marker_end(&self, command_buffer: vk::CommandBuffer) { pub unsafe fn cmd_debug_marker_end(&self, command_buffer: vk::CommandBuffer) {
self.debug_marker_fn self.fp.cmd_debug_marker_end_ext(command_buffer);
.cmd_debug_marker_end_ext(command_buffer);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerInsertEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerInsertEXT.html>"]
@ -54,11 +50,19 @@ impl DebugMarker {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
marker_info: &vk::DebugMarkerMarkerInfoEXT, marker_info: &vk::DebugMarkerMarkerInfoEXT,
) { ) {
self.debug_marker_fn self.fp
.cmd_debug_marker_insert_ext(command_buffer, marker_info); .cmd_debug_marker_insert_ext(command_buffer, marker_info);
} }
pub fn name() -> &'static CStr {
vk::ExtDebugMarkerFn::name()
}
pub fn fp(&self) -> &vk::ExtDebugMarkerFn { pub fn fp(&self) -> &vk::ExtDebugMarkerFn {
&self.debug_marker_fn &self.fp
}
pub fn device(&self) -> vk::Device {
self.handle
} }
} }

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct DebugReport { pub struct DebugReport {
handle: vk::Instance, handle: vk::Instance,
debug_report_fn: vk::ExtDebugReportFn, fp: vk::ExtDebugReportFn,
} }
impl DebugReport { impl DebugReport {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let debug_report_fn = vk::ExtDebugReportFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::ExtDebugReportFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
debug_report_fn,
}
}
pub fn name() -> &'static CStr {
vk::ExtDebugReportFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugReportCallbackEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugReportCallbackEXT.html>"]
@ -32,7 +26,7 @@ impl DebugReport {
debug: vk::DebugReportCallbackEXT, debug: vk::DebugReportCallbackEXT,
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) { ) {
self.debug_report_fn.destroy_debug_report_callback_ext( self.fp.destroy_debug_report_callback_ext(
self.handle, self.handle,
debug, debug,
allocation_callbacks.as_raw_ptr(), allocation_callbacks.as_raw_ptr(),
@ -46,7 +40,7 @@ impl DebugReport {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DebugReportCallbackEXT> { ) -> VkResult<vk::DebugReportCallbackEXT> {
let mut debug_cb = mem::zeroed(); let mut debug_cb = mem::zeroed();
self.debug_report_fn self.fp
.create_debug_report_callback_ext( .create_debug_report_callback_ext(
self.handle, self.handle,
create_info, create_info,
@ -56,8 +50,12 @@ impl DebugReport {
.result_with_success(debug_cb) .result_with_success(debug_cb)
} }
pub fn name() -> &'static CStr {
vk::ExtDebugReportFn::name()
}
pub fn fp(&self) -> &vk::ExtDebugReportFn { pub fn fp(&self) -> &vk::ExtDebugReportFn {
&self.debug_report_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -7,22 +7,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct DebugUtils { pub struct DebugUtils {
handle: vk::Instance, handle: vk::Instance,
debug_utils_fn: vk::ExtDebugUtilsFn, fp: vk::ExtDebugUtilsFn,
} }
impl DebugUtils { impl DebugUtils {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let debug_utils_fn = vk::ExtDebugUtilsFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::ExtDebugUtilsFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
debug_utils_fn,
}
}
pub fn name() -> &'static CStr {
vk::ExtDebugUtilsFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html>"]
@ -31,7 +25,7 @@ impl DebugUtils {
device: vk::Device, device: vk::Device,
name_info: &vk::DebugUtilsObjectNameInfoEXT, name_info: &vk::DebugUtilsObjectNameInfoEXT,
) -> VkResult<()> { ) -> VkResult<()> {
self.debug_utils_fn self.fp
.set_debug_utils_object_name_ext(device, name_info) .set_debug_utils_object_name_ext(device, name_info)
.result() .result()
} }
@ -42,7 +36,7 @@ impl DebugUtils {
device: vk::Device, device: vk::Device,
tag_info: &vk::DebugUtilsObjectTagInfoEXT, tag_info: &vk::DebugUtilsObjectTagInfoEXT,
) -> VkResult<()> { ) -> VkResult<()> {
self.debug_utils_fn self.fp
.set_debug_utils_object_tag_ext(device, tag_info) .set_debug_utils_object_tag_ext(device, tag_info)
.result() .result()
} }
@ -53,14 +47,13 @@ impl DebugUtils {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
label: &vk::DebugUtilsLabelEXT, label: &vk::DebugUtilsLabelEXT,
) { ) {
self.debug_utils_fn self.fp
.cmd_begin_debug_utils_label_ext(command_buffer, label); .cmd_begin_debug_utils_label_ext(command_buffer, label);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndDebugUtilsLabelEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndDebugUtilsLabelEXT.html>"]
pub unsafe fn cmd_end_debug_utils_label(&self, command_buffer: vk::CommandBuffer) { pub unsafe fn cmd_end_debug_utils_label(&self, command_buffer: vk::CommandBuffer) {
self.debug_utils_fn self.fp.cmd_end_debug_utils_label_ext(command_buffer);
.cmd_end_debug_utils_label_ext(command_buffer);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdInsertDebugUtilsLabelEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdInsertDebugUtilsLabelEXT.html>"]
@ -69,7 +62,7 @@ impl DebugUtils {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
label: &vk::DebugUtilsLabelEXT, label: &vk::DebugUtilsLabelEXT,
) { ) {
self.debug_utils_fn self.fp
.cmd_insert_debug_utils_label_ext(command_buffer, label); .cmd_insert_debug_utils_label_ext(command_buffer, label);
} }
@ -79,13 +72,12 @@ impl DebugUtils {
queue: vk::Queue, queue: vk::Queue,
label: &vk::DebugUtilsLabelEXT, label: &vk::DebugUtilsLabelEXT,
) { ) {
self.debug_utils_fn self.fp.queue_begin_debug_utils_label_ext(queue, label);
.queue_begin_debug_utils_label_ext(queue, label);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueEndDebugUtilsLabelEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueEndDebugUtilsLabelEXT.html>"]
pub unsafe fn queue_end_debug_utils_label(&self, queue: vk::Queue) { pub unsafe fn queue_end_debug_utils_label(&self, queue: vk::Queue) {
self.debug_utils_fn.queue_end_debug_utils_label_ext(queue); self.fp.queue_end_debug_utils_label_ext(queue);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueInsertDebugUtilsLabelEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueInsertDebugUtilsLabelEXT.html>"]
@ -94,8 +86,7 @@ impl DebugUtils {
queue: vk::Queue, queue: vk::Queue,
label: &vk::DebugUtilsLabelEXT, label: &vk::DebugUtilsLabelEXT,
) { ) {
self.debug_utils_fn self.fp.queue_insert_debug_utils_label_ext(queue, label);
.queue_insert_debug_utils_label_ext(queue, label);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDebugUtilsMessengerEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDebugUtilsMessengerEXT.html>"]
@ -105,7 +96,7 @@ impl DebugUtils {
allocator: Option<&vk::AllocationCallbacks>, allocator: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DebugUtilsMessengerEXT> { ) -> VkResult<vk::DebugUtilsMessengerEXT> {
let mut messenger = mem::zeroed(); let mut messenger = mem::zeroed();
self.debug_utils_fn self.fp
.create_debug_utils_messenger_ext( .create_debug_utils_messenger_ext(
self.handle, self.handle,
create_info, create_info,
@ -121,11 +112,8 @@ impl DebugUtils {
messenger: vk::DebugUtilsMessengerEXT, messenger: vk::DebugUtilsMessengerEXT,
allocator: Option<&vk::AllocationCallbacks>, allocator: Option<&vk::AllocationCallbacks>,
) { ) {
self.debug_utils_fn.destroy_debug_utils_messenger_ext( self.fp
self.handle, .destroy_debug_utils_messenger_ext(self.handle, messenger, allocator.as_raw_ptr());
messenger,
allocator.as_raw_ptr(),
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSubmitDebugUtilsMessageEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSubmitDebugUtilsMessageEXT.html>"]
@ -135,7 +123,7 @@ impl DebugUtils {
message_types: vk::DebugUtilsMessageTypeFlagsEXT, message_types: vk::DebugUtilsMessageTypeFlagsEXT,
callback_data: &vk::DebugUtilsMessengerCallbackDataEXT, callback_data: &vk::DebugUtilsMessengerCallbackDataEXT,
) { ) {
self.debug_utils_fn.submit_debug_utils_message_ext( self.fp.submit_debug_utils_message_ext(
self.handle, self.handle,
message_severity, message_severity,
message_types, message_types,
@ -143,8 +131,12 @@ impl DebugUtils {
); );
} }
pub fn name() -> &'static CStr {
vk::ExtDebugUtilsFn::name()
}
pub fn fp(&self) -> &vk::ExtDebugUtilsFn { pub fn fp(&self) -> &vk::ExtDebugUtilsFn {
&self.debug_utils_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -6,23 +6,15 @@ use std::ptr;
#[derive(Clone)] #[derive(Clone)]
pub struct ExtendedDynamicState { pub struct ExtendedDynamicState {
handle: vk::Instance, fp: vk::ExtExtendedDynamicStateFn,
extended_dynamic_state_fn: vk::ExtExtendedDynamicStateFn,
} }
impl ExtendedDynamicState { impl ExtendedDynamicState {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let extended_dynamic_state_fn = vk::ExtExtendedDynamicStateFn::load(|name| unsafe { let fp = vk::ExtExtendedDynamicStateFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
}); });
Self { Self { fp }
handle: instance.handle(),
extended_dynamic_state_fn,
}
}
pub fn name() -> &'static CStr {
vk::ExtExtendedDynamicStateFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetCullModeEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetCullModeEXT.html>"]
@ -31,8 +23,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
cull_mode: vk::CullModeFlags, cull_mode: vk::CullModeFlags,
) { ) {
self.extended_dynamic_state_fn self.fp.cmd_set_cull_mode_ext(command_buffer, cull_mode)
.cmd_set_cull_mode_ext(command_buffer, cull_mode)
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetFrontFaceEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetFrontFaceEXT.html>"]
@ -41,8 +32,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
front_face: vk::FrontFace, front_face: vk::FrontFace,
) { ) {
self.extended_dynamic_state_fn self.fp.cmd_set_front_face_ext(command_buffer, front_face)
.cmd_set_front_face_ext(command_buffer, front_face)
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetPrimitiveTopologyEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetPrimitiveTopologyEXT.html>"]
@ -51,7 +41,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
primitive_topology: vk::PrimitiveTopology, primitive_topology: vk::PrimitiveTopology,
) { ) {
self.extended_dynamic_state_fn self.fp
.cmd_set_primitive_topology_ext(command_buffer, primitive_topology) .cmd_set_primitive_topology_ext(command_buffer, primitive_topology)
} }
@ -61,12 +51,11 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
viewports: &[vk::Viewport], viewports: &[vk::Viewport],
) { ) {
self.extended_dynamic_state_fn self.fp.cmd_set_viewport_with_count_ext(
.cmd_set_viewport_with_count_ext( command_buffer,
command_buffer, viewports.len() as u32,
viewports.len() as u32, viewports.as_ptr(),
viewports.as_ptr(), )
)
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetScissorWithCountEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetScissorWithCountEXT.html>"]
@ -75,12 +64,11 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
scissors: &[vk::Rect2D], scissors: &[vk::Rect2D],
) { ) {
self.extended_dynamic_state_fn self.fp.cmd_set_scissor_with_count_ext(
.cmd_set_scissor_with_count_ext( command_buffer,
command_buffer, scissors.len() as u32,
scissors.len() as u32, scissors.as_ptr(),
scissors.as_ptr(), )
)
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBindVertexBuffers2EXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBindVertexBuffers2EXT.html>"]
@ -106,7 +94,7 @@ impl ExtendedDynamicState {
} else { } else {
ptr::null() ptr::null()
}; };
self.extended_dynamic_state_fn.cmd_bind_vertex_buffers2_ext( self.fp.cmd_bind_vertex_buffers2_ext(
command_buffer, command_buffer,
first_binding, first_binding,
buffers.len() as u32, buffers.len() as u32,
@ -123,7 +111,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
depth_test_enable: bool, depth_test_enable: bool,
) { ) {
self.extended_dynamic_state_fn self.fp
.cmd_set_depth_test_enable_ext(command_buffer, depth_test_enable.into()) .cmd_set_depth_test_enable_ext(command_buffer, depth_test_enable.into())
} }
@ -133,7 +121,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
depth_write_enable: bool, depth_write_enable: bool,
) { ) {
self.extended_dynamic_state_fn self.fp
.cmd_set_depth_write_enable_ext(command_buffer, depth_write_enable.into()) .cmd_set_depth_write_enable_ext(command_buffer, depth_write_enable.into())
} }
@ -143,7 +131,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
depth_compare_op: vk::CompareOp, depth_compare_op: vk::CompareOp,
) { ) {
self.extended_dynamic_state_fn self.fp
.cmd_set_depth_compare_op_ext(command_buffer, depth_compare_op) .cmd_set_depth_compare_op_ext(command_buffer, depth_compare_op)
} }
@ -153,7 +141,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
depth_bounds_test_enable: bool, depth_bounds_test_enable: bool,
) { ) {
self.extended_dynamic_state_fn self.fp
.cmd_set_depth_bounds_test_enable_ext(command_buffer, depth_bounds_test_enable.into()) .cmd_set_depth_bounds_test_enable_ext(command_buffer, depth_bounds_test_enable.into())
} }
@ -163,7 +151,7 @@ impl ExtendedDynamicState {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
stencil_test_enable: bool, stencil_test_enable: bool,
) { ) {
self.extended_dynamic_state_fn self.fp
.cmd_set_stencil_test_enable_ext(command_buffer, stencil_test_enable.into()) .cmd_set_stencil_test_enable_ext(command_buffer, stencil_test_enable.into())
} }
@ -177,7 +165,7 @@ impl ExtendedDynamicState {
depth_fail_op: vk::StencilOp, depth_fail_op: vk::StencilOp,
compare_op: vk::CompareOp, compare_op: vk::CompareOp,
) { ) {
self.extended_dynamic_state_fn.cmd_set_stencil_op_ext( self.fp.cmd_set_stencil_op_ext(
command_buffer, command_buffer,
face_mask, face_mask,
fail_op, fail_op,
@ -187,11 +175,11 @@ impl ExtendedDynamicState {
) )
} }
pub fn fp(&self) -> &vk::ExtExtendedDynamicStateFn { pub fn name() -> &'static CStr {
&self.extended_dynamic_state_fn vk::ExtExtendedDynamicStateFn::name()
} }
pub fn instance(&self) -> vk::Instance { pub fn fp(&self) -> &vk::ExtExtendedDynamicStateFn {
self.handle &self.fp
} }
} }

View file

@ -7,22 +7,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct FullScreenExclusive { pub struct FullScreenExclusive {
handle: vk::Device, handle: vk::Device,
full_screen_exclusive_fn: vk::ExtFullScreenExclusiveFn, fp: vk::ExtFullScreenExclusiveFn,
} }
impl FullScreenExclusive { impl FullScreenExclusive {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let full_screen_exclusive_fn = vk::ExtFullScreenExclusiveFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::ExtFullScreenExclusiveFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
full_screen_exclusive_fn,
}
}
pub fn name() -> &'static CStr {
vk::ExtFullScreenExclusiveFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAcquireFullScreenExclusiveModeEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAcquireFullScreenExclusiveModeEXT.html>"]
@ -30,7 +24,7 @@ impl FullScreenExclusive {
&self, &self,
swapchain: vk::SwapchainKHR, swapchain: vk::SwapchainKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.full_screen_exclusive_fn self.fp
.acquire_full_screen_exclusive_mode_ext(self.handle, swapchain) .acquire_full_screen_exclusive_mode_ext(self.handle, swapchain)
.result() .result()
} }
@ -42,13 +36,12 @@ impl FullScreenExclusive {
surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR,
) -> VkResult<Vec<vk::PresentModeKHR>> { ) -> VkResult<Vec<vk::PresentModeKHR>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.full_screen_exclusive_fn self.fp.get_physical_device_surface_present_modes2_ext(
.get_physical_device_surface_present_modes2_ext( physical_device,
physical_device, surface_info,
surface_info, count,
count, data,
data, )
)
}) })
} }
@ -57,7 +50,7 @@ impl FullScreenExclusive {
&self, &self,
swapchain: vk::SwapchainKHR, swapchain: vk::SwapchainKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.full_screen_exclusive_fn self.fp
.release_full_screen_exclusive_mode_ext(self.handle, swapchain) .release_full_screen_exclusive_mode_ext(self.handle, swapchain)
.result() .result()
} }
@ -68,7 +61,7 @@ impl FullScreenExclusive {
surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR,
) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> { ) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> {
let mut present_modes = mem::zeroed(); let mut present_modes = mem::zeroed();
self.full_screen_exclusive_fn self.fp
.get_device_group_surface_present_modes2_ext( .get_device_group_surface_present_modes2_ext(
self.handle, self.handle,
surface_info, surface_info,
@ -77,8 +70,12 @@ impl FullScreenExclusive {
.result_with_success(present_modes) .result_with_success(present_modes)
} }
pub fn name() -> &'static CStr {
vk::ExtFullScreenExclusiveFn::name()
}
pub fn fp(&self) -> &vk::ExtFullScreenExclusiveFn { pub fn fp(&self) -> &vk::ExtFullScreenExclusiveFn {
&self.full_screen_exclusive_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct MetalSurface { pub struct MetalSurface {
handle: vk::Instance, handle: vk::Instance,
metal_surface_fn: vk::ExtMetalSurfaceFn, fp: vk::ExtMetalSurfaceFn,
} }
impl MetalSurface { impl MetalSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::ExtMetalSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::ExtMetalSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
metal_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::ExtMetalSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateMetalSurfaceEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateMetalSurfaceEXT.html>"]
@ -33,7 +27,7 @@ impl MetalSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.metal_surface_fn self.fp
.create_metal_surface_ext( .create_metal_surface_ext(
self.handle, self.handle,
create_info, create_info,
@ -43,8 +37,12 @@ impl MetalSurface {
.result_with_success(surface) .result_with_success(surface)
} }
pub fn name() -> &'static CStr {
vk::ExtMetalSurfaceFn::name()
}
pub fn fp(&self) -> &vk::ExtMetalSurfaceFn { pub fn fp(&self) -> &vk::ExtMetalSurfaceFn {
&self.metal_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -6,23 +6,15 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct ToolingInfo { pub struct ToolingInfo {
handle: vk::Instance, fp: vk::ExtToolingInfoFn,
tooling_info_fn: vk::ExtToolingInfoFn,
} }
impl ToolingInfo { impl ToolingInfo {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let tooling_info_fn = vk::ExtToolingInfoFn::load(|name| unsafe { let fp = vk::ExtToolingInfoFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
}); });
Self { Self { fp }
handle: instance.handle(),
tooling_info_fn,
}
}
pub fn name() -> &'static CStr {
vk::ExtToolingInfoFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceToolPropertiesEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceToolPropertiesEXT.html>"]
@ -31,16 +23,16 @@ impl ToolingInfo {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
) -> VkResult<Vec<vk::PhysicalDeviceToolPropertiesEXT>> { ) -> VkResult<Vec<vk::PhysicalDeviceToolPropertiesEXT>> {
read_into_defaulted_vector(|count, data| { read_into_defaulted_vector(|count, data| {
self.tooling_info_fn self.fp
.get_physical_device_tool_properties_ext(physical_device, count, data) .get_physical_device_tool_properties_ext(physical_device, count, data)
}) })
} }
pub fn fp(&self) -> &vk::ExtToolingInfoFn { pub fn name() -> &'static CStr {
&self.tooling_info_fn vk::ExtToolingInfoFn::name()
} }
pub fn instance(&self) -> vk::Instance { pub fn fp(&self) -> &vk::ExtToolingInfoFn {
self.handle &self.fp
} }
} }

View file

@ -8,18 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct AccelerationStructure { pub struct AccelerationStructure {
handle: vk::Device, handle: vk::Device,
acceleration_structure_fn: vk::KhrAccelerationStructureFn, fp: vk::KhrAccelerationStructureFn,
} }
impl AccelerationStructure { impl AccelerationStructure {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let acceleration_structure_fn = vk::KhrAccelerationStructureFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrAccelerationStructureFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
acceleration_structure_fn,
}
} }
pub unsafe fn get_properties( pub unsafe fn get_properties(
@ -41,7 +39,7 @@ impl AccelerationStructure {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::AccelerationStructureKHR> { ) -> VkResult<vk::AccelerationStructureKHR> {
let mut accel_struct = mem::zeroed(); let mut accel_struct = mem::zeroed();
self.acceleration_structure_fn self.fp
.create_acceleration_structure_khr( .create_acceleration_structure_khr(
self.handle, self.handle,
create_info, create_info,
@ -57,12 +55,11 @@ impl AccelerationStructure {
accel_struct: vk::AccelerationStructureKHR, accel_struct: vk::AccelerationStructureKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) { ) {
self.acceleration_structure_fn self.fp.destroy_acceleration_structure_khr(
.destroy_acceleration_structure_khr( self.handle,
self.handle, accel_struct,
accel_struct, allocation_callbacks.as_raw_ptr(),
allocation_callbacks.as_raw_ptr(), );
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructuresKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructuresKHR.html>"]
@ -83,13 +80,12 @@ impl AccelerationStructure {
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
self.acceleration_structure_fn self.fp.cmd_build_acceleration_structures_khr(
.cmd_build_acceleration_structures_khr( command_buffer,
command_buffer, infos.len() as _,
infos.len() as _, infos.as_ptr(),
infos.as_ptr(), build_range_infos.as_ptr(),
build_range_infos.as_ptr(), );
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructuresIndirectKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructuresIndirectKHR.html>"]
@ -114,15 +110,14 @@ impl AccelerationStructure {
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
self.acceleration_structure_fn self.fp.cmd_build_acceleration_structures_indirect_khr(
.cmd_build_acceleration_structures_indirect_khr( command_buffer,
command_buffer, infos.len() as _,
infos.len() as _, infos.as_ptr(),
infos.as_ptr(), indirect_device_addresses.as_ptr(),
indirect_device_addresses.as_ptr(), indirect_strides.as_ptr(),
indirect_strides.as_ptr(), max_primitive_counts.as_ptr(),
max_primitive_counts.as_ptr(), );
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBuildAccelerationStructuresKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBuildAccelerationStructuresKHR.html>"]
@ -143,7 +138,7 @@ impl AccelerationStructure {
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
self.acceleration_structure_fn self.fp
.build_acceleration_structures_khr( .build_acceleration_structures_khr(
self.handle, self.handle,
deferred_operation, deferred_operation,
@ -160,7 +155,7 @@ impl AccelerationStructure {
deferred_operation: vk::DeferredOperationKHR, deferred_operation: vk::DeferredOperationKHR,
info: &vk::CopyAccelerationStructureInfoKHR, info: &vk::CopyAccelerationStructureInfoKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.acceleration_structure_fn self.fp
.copy_acceleration_structure_khr(self.handle, deferred_operation, info as *const _) .copy_acceleration_structure_khr(self.handle, deferred_operation, info as *const _)
.result() .result()
} }
@ -171,7 +166,7 @@ impl AccelerationStructure {
deferred_operation: vk::DeferredOperationKHR, deferred_operation: vk::DeferredOperationKHR,
info: &vk::CopyAccelerationStructureToMemoryInfoKHR, info: &vk::CopyAccelerationStructureToMemoryInfoKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.acceleration_structure_fn self.fp
.copy_acceleration_structure_to_memory_khr( .copy_acceleration_structure_to_memory_khr(
self.handle, self.handle,
deferred_operation, deferred_operation,
@ -186,7 +181,7 @@ impl AccelerationStructure {
deferred_operation: vk::DeferredOperationKHR, deferred_operation: vk::DeferredOperationKHR,
info: &vk::CopyMemoryToAccelerationStructureInfoKHR, info: &vk::CopyMemoryToAccelerationStructureInfoKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.acceleration_structure_fn self.fp
.copy_memory_to_acceleration_structure_khr( .copy_memory_to_acceleration_structure_khr(
self.handle, self.handle,
deferred_operation, deferred_operation,
@ -203,7 +198,7 @@ impl AccelerationStructure {
data: &mut [u8], data: &mut [u8],
stride: usize, stride: usize,
) -> VkResult<()> { ) -> VkResult<()> {
self.acceleration_structure_fn self.fp
.write_acceleration_structures_properties_khr( .write_acceleration_structures_properties_khr(
self.handle, self.handle,
acceleration_structures.len() as _, acceleration_structures.len() as _,
@ -222,7 +217,7 @@ impl AccelerationStructure {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
info: &vk::CopyAccelerationStructureInfoKHR, info: &vk::CopyAccelerationStructureInfoKHR,
) { ) {
self.acceleration_structure_fn self.fp
.cmd_copy_acceleration_structure_khr(command_buffer, info); .cmd_copy_acceleration_structure_khr(command_buffer, info);
} }
@ -232,7 +227,7 @@ impl AccelerationStructure {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
info: &vk::CopyAccelerationStructureToMemoryInfoKHR, info: &vk::CopyAccelerationStructureToMemoryInfoKHR,
) { ) {
self.acceleration_structure_fn self.fp
.cmd_copy_acceleration_structure_to_memory_khr(command_buffer, info as *const _); .cmd_copy_acceleration_structure_to_memory_khr(command_buffer, info as *const _);
} }
@ -242,7 +237,7 @@ impl AccelerationStructure {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
info: &vk::CopyMemoryToAccelerationStructureInfoKHR, info: &vk::CopyMemoryToAccelerationStructureInfoKHR,
) { ) {
self.acceleration_structure_fn self.fp
.cmd_copy_memory_to_acceleration_structure_khr(command_buffer, info as *const _); .cmd_copy_memory_to_acceleration_structure_khr(command_buffer, info as *const _);
} }
@ -251,7 +246,7 @@ impl AccelerationStructure {
&self, &self,
info: &vk::AccelerationStructureDeviceAddressInfoKHR, info: &vk::AccelerationStructureDeviceAddressInfoKHR,
) -> vk::DeviceAddress { ) -> vk::DeviceAddress {
self.acceleration_structure_fn self.fp
.get_acceleration_structure_device_address_khr(self.handle, info as *const _) .get_acceleration_structure_device_address_khr(self.handle, info as *const _)
} }
@ -264,15 +259,14 @@ impl AccelerationStructure {
query_pool: vk::QueryPool, query_pool: vk::QueryPool,
first_query: u32, first_query: u32,
) { ) {
self.acceleration_structure_fn self.fp.cmd_write_acceleration_structures_properties_khr(
.cmd_write_acceleration_structures_properties_khr( command_buffer,
command_buffer, structures.len() as _,
structures.len() as _, structures.as_ptr(),
structures.as_ptr(), query_type,
query_type, query_pool,
query_pool, first_query,
first_query, );
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceAccelerationStructureCompatibilityKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceAccelerationStructureCompatibilityKHR.html>"]
@ -282,12 +276,11 @@ impl AccelerationStructure {
) -> vk::AccelerationStructureCompatibilityKHR { ) -> vk::AccelerationStructureCompatibilityKHR {
let mut compatibility = vk::AccelerationStructureCompatibilityKHR::default(); let mut compatibility = vk::AccelerationStructureCompatibilityKHR::default();
self.acceleration_structure_fn self.fp.get_device_acceleration_structure_compatibility_khr(
.get_device_acceleration_structure_compatibility_khr( self.handle,
self.handle, version,
version, &mut compatibility as *mut _,
&mut compatibility as *mut _, );
);
compatibility compatibility
} }
@ -303,14 +296,13 @@ impl AccelerationStructure {
let mut size_info = vk::AccelerationStructureBuildSizesInfoKHR::default(); let mut size_info = vk::AccelerationStructureBuildSizesInfoKHR::default();
self.acceleration_structure_fn self.fp.get_acceleration_structure_build_sizes_khr(
.get_acceleration_structure_build_sizes_khr( self.handle,
self.handle, build_type,
build_type, build_info as *const _,
build_info as *const _, max_primitive_counts.as_ptr(),
max_primitive_counts.as_ptr(), &mut size_info as *mut _,
&mut size_info as *mut _, );
);
size_info size_info
} }
@ -320,7 +312,7 @@ impl AccelerationStructure {
} }
pub fn fp(&self) -> &vk::KhrAccelerationStructureFn { pub fn fp(&self) -> &vk::KhrAccelerationStructureFn {
&self.acceleration_structure_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct AndroidSurface { pub struct AndroidSurface {
handle: vk::Instance, handle: vk::Instance,
android_surface_fn: vk::KhrAndroidSurfaceFn, fp: vk::KhrAndroidSurfaceFn,
} }
impl AndroidSurface { impl AndroidSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::KhrAndroidSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::KhrAndroidSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
android_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrAndroidSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAndroidSurfaceKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAndroidSurfaceKHR.html>"]
@ -33,7 +27,7 @@ impl AndroidSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.android_surface_fn self.fp
.create_android_surface_khr( .create_android_surface_khr(
self.handle, self.handle,
create_info, create_info,
@ -43,8 +37,12 @@ impl AndroidSurface {
.result_with_success(surface) .result_with_success(surface)
} }
pub fn name() -> &'static CStr {
vk::KhrAndroidSurfaceFn::name()
}
pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn { pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn {
&self.android_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -6,18 +6,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct BufferDeviceAddress { pub struct BufferDeviceAddress {
handle: vk::Device, handle: vk::Device,
fns: vk::KhrBufferDeviceAddressFn, fp: vk::KhrBufferDeviceAddressFn,
} }
impl BufferDeviceAddress { impl BufferDeviceAddress {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let fns = vk::KhrBufferDeviceAddressFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrBufferDeviceAddressFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
fns,
}
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressKHR.html>"]
@ -25,7 +23,7 @@ impl BufferDeviceAddress {
&self, &self,
info: &vk::BufferDeviceAddressInfoKHR, info: &vk::BufferDeviceAddressInfoKHR,
) -> vk::DeviceAddress { ) -> vk::DeviceAddress {
self.fns.get_buffer_device_address_khr(self.handle, info) self.fp.get_buffer_device_address_khr(self.handle, info)
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferOpaqueCaptureAddressKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferOpaqueCaptureAddressKHR.html>"]
@ -33,7 +31,7 @@ impl BufferDeviceAddress {
&self, &self,
info: &vk::BufferDeviceAddressInfoKHR, info: &vk::BufferDeviceAddressInfoKHR,
) -> u64 { ) -> u64 {
self.fns self.fp
.get_buffer_opaque_capture_address_khr(self.handle, info) .get_buffer_opaque_capture_address_khr(self.handle, info)
} }
@ -42,7 +40,7 @@ impl BufferDeviceAddress {
&self, &self,
info: &vk::DeviceMemoryOpaqueCaptureAddressInfoKHR, info: &vk::DeviceMemoryOpaqueCaptureAddressInfoKHR,
) -> u64 { ) -> u64 {
self.fns self.fp
.get_device_memory_opaque_capture_address_khr(self.handle, info) .get_device_memory_opaque_capture_address_khr(self.handle, info)
} }
@ -51,7 +49,7 @@ impl BufferDeviceAddress {
} }
pub fn fp(&self) -> &vk::KhrBufferDeviceAddressFn { pub fn fp(&self) -> &vk::KhrBufferDeviceAddressFn {
&self.fns &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct CreateRenderPass2 { pub struct CreateRenderPass2 {
handle: vk::Device, handle: vk::Device,
khr_create_renderpass2_fn: vk::KhrCreateRenderpass2Fn, fp: vk::KhrCreateRenderpass2Fn,
} }
impl CreateRenderPass2 { impl CreateRenderPass2 {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let khr_create_renderpass2_fn = vk::KhrCreateRenderpass2Fn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrCreateRenderpass2Fn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
khr_create_renderpass2_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrCreateRenderpass2Fn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateRenderPass2.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateRenderPass2.html>"]
@ -33,7 +27,7 @@ impl CreateRenderPass2 {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::RenderPass> { ) -> VkResult<vk::RenderPass> {
let mut renderpass = mem::zeroed(); let mut renderpass = mem::zeroed();
self.khr_create_renderpass2_fn self.fp
.create_render_pass2_khr( .create_render_pass2_khr(
self.handle, self.handle,
create_info, create_info,
@ -50,7 +44,7 @@ impl CreateRenderPass2 {
render_pass_begin_info: &vk::RenderPassBeginInfo, render_pass_begin_info: &vk::RenderPassBeginInfo,
subpass_begin_info: &vk::SubpassBeginInfo, subpass_begin_info: &vk::SubpassBeginInfo,
) { ) {
self.khr_create_renderpass2_fn.cmd_begin_render_pass2_khr( self.fp.cmd_begin_render_pass2_khr(
command_buffer, command_buffer,
render_pass_begin_info, render_pass_begin_info,
subpass_begin_info, subpass_begin_info,
@ -64,11 +58,8 @@ impl CreateRenderPass2 {
subpass_begin_info: &vk::SubpassBeginInfo, subpass_begin_info: &vk::SubpassBeginInfo,
subpass_end_info: &vk::SubpassEndInfo, subpass_end_info: &vk::SubpassEndInfo,
) { ) {
self.khr_create_renderpass2_fn.cmd_next_subpass2_khr( self.fp
command_buffer, .cmd_next_subpass2_khr(command_buffer, subpass_begin_info, subpass_end_info);
subpass_begin_info,
subpass_end_info,
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndRenderPass2.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndRenderPass2.html>"]
@ -77,12 +68,16 @@ impl CreateRenderPass2 {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
subpass_end_info: &vk::SubpassEndInfo, subpass_end_info: &vk::SubpassEndInfo,
) { ) {
self.khr_create_renderpass2_fn self.fp
.cmd_end_render_pass2_khr(command_buffer, subpass_end_info); .cmd_end_render_pass2_khr(command_buffer, subpass_end_info);
} }
pub fn name() -> &'static CStr {
vk::KhrCreateRenderpass2Fn::name()
}
pub fn fp(&self) -> &vk::KhrCreateRenderpass2Fn { pub fn fp(&self) -> &vk::KhrCreateRenderpass2Fn {
&self.khr_create_renderpass2_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -8,18 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct DeferredHostOperations { pub struct DeferredHostOperations {
handle: vk::Device, handle: vk::Device,
deferred_host_operations_fn: vk::KhrDeferredHostOperationsFn, fp: vk::KhrDeferredHostOperationsFn,
} }
impl DeferredHostOperations { impl DeferredHostOperations {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let deferred_host_operations_fn = vk::KhrDeferredHostOperationsFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrDeferredHostOperationsFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
deferred_host_operations_fn,
}
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDeferredOperationKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDeferredOperationKHR.html>"]
@ -28,7 +26,7 @@ impl DeferredHostOperations {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DeferredOperationKHR> { ) -> VkResult<vk::DeferredOperationKHR> {
let mut operation = mem::zeroed(); let mut operation = mem::zeroed();
self.deferred_host_operations_fn self.fp
.create_deferred_operation_khr( .create_deferred_operation_khr(
self.handle, self.handle,
allocation_callbacks.as_raw_ptr(), allocation_callbacks.as_raw_ptr(),
@ -42,7 +40,7 @@ impl DeferredHostOperations {
&self, &self,
operation: vk::DeferredOperationKHR, operation: vk::DeferredOperationKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.deferred_host_operations_fn self.fp
.deferred_operation_join_khr(self.handle, operation) .deferred_operation_join_khr(self.handle, operation)
.result() .result()
} }
@ -53,12 +51,11 @@ impl DeferredHostOperations {
operation: vk::DeferredOperationKHR, operation: vk::DeferredOperationKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) { ) {
self.deferred_host_operations_fn self.fp.destroy_deferred_operation_khr(
.destroy_deferred_operation_khr( self.handle,
self.handle, operation,
operation, allocation_callbacks.as_raw_ptr(),
allocation_callbacks.as_raw_ptr(), );
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeferredOperationMaxConcurrencyKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeferredOperationMaxConcurrencyKHR.html>"]
@ -66,7 +63,7 @@ impl DeferredHostOperations {
&self, &self,
operation: vk::DeferredOperationKHR, operation: vk::DeferredOperationKHR,
) -> u32 { ) -> u32 {
self.deferred_host_operations_fn self.fp
.get_deferred_operation_max_concurrency_khr(self.handle, operation) .get_deferred_operation_max_concurrency_khr(self.handle, operation)
} }
@ -75,7 +72,7 @@ impl DeferredHostOperations {
&self, &self,
operation: vk::DeferredOperationKHR, operation: vk::DeferredOperationKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.deferred_host_operations_fn self.fp
.get_deferred_operation_result_khr(self.handle, operation) .get_deferred_operation_result_khr(self.handle, operation)
.result() .result()
} }
@ -85,7 +82,7 @@ impl DeferredHostOperations {
} }
pub fn fp(&self) -> &vk::KhrDeferredHostOperationsFn { pub fn fp(&self) -> &vk::KhrDeferredHostOperationsFn {
&self.deferred_host_operations_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Display { pub struct Display {
handle: vk::Instance, handle: vk::Instance,
display_fn: vk::KhrDisplayFn, fp: vk::KhrDisplayFn,
} }
impl Display { impl Display {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let display_fn = vk::KhrDisplayFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::KhrDisplayFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
display_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrDisplayFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>"]
@ -32,7 +26,7 @@ impl Display {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
) -> VkResult<Vec<vk::DisplayPropertiesKHR>> { ) -> VkResult<Vec<vk::DisplayPropertiesKHR>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.display_fn self.fp
.get_physical_device_display_properties_khr(physical_device, count, data) .get_physical_device_display_properties_khr(physical_device, count, data)
}) })
} }
@ -43,7 +37,7 @@ impl Display {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> { ) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.display_fn self.fp
.get_physical_device_display_plane_properties_khr(physical_device, count, data) .get_physical_device_display_plane_properties_khr(physical_device, count, data)
}) })
} }
@ -55,7 +49,7 @@ impl Display {
plane_index: u32, plane_index: u32,
) -> VkResult<Vec<vk::DisplayKHR>> { ) -> VkResult<Vec<vk::DisplayKHR>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.display_fn.get_display_plane_supported_displays_khr( self.fp.get_display_plane_supported_displays_khr(
physical_device, physical_device,
plane_index, plane_index,
count, count,
@ -71,7 +65,7 @@ impl Display {
display: vk::DisplayKHR, display: vk::DisplayKHR,
) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> { ) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.display_fn self.fp
.get_display_mode_properties_khr(physical_device, display, count, data) .get_display_mode_properties_khr(physical_device, display, count, data)
}) })
} }
@ -85,7 +79,7 @@ impl Display {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DisplayModeKHR> { ) -> VkResult<vk::DisplayModeKHR> {
let mut display_mode = mem::MaybeUninit::zeroed(); let mut display_mode = mem::MaybeUninit::zeroed();
self.display_fn self.fp
.create_display_mode_khr( .create_display_mode_khr(
physical_device, physical_device,
display, display,
@ -104,7 +98,7 @@ impl Display {
plane_index: u32, plane_index: u32,
) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> { ) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> {
let mut display_plane_capabilities = mem::MaybeUninit::zeroed(); let mut display_plane_capabilities = mem::MaybeUninit::zeroed();
self.display_fn self.fp
.get_display_plane_capabilities_khr( .get_display_plane_capabilities_khr(
physical_device, physical_device,
mode, mode,
@ -121,7 +115,7 @@ impl Display {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::MaybeUninit::zeroed(); let mut surface = mem::MaybeUninit::zeroed();
self.display_fn self.fp
.create_display_plane_surface_khr( .create_display_plane_surface_khr(
self.handle, self.handle,
create_info, create_info,
@ -131,8 +125,12 @@ impl Display {
.result_with_success(surface.assume_init()) .result_with_success(surface.assume_init())
} }
pub fn name() -> &'static CStr {
vk::KhrDisplayFn::name()
}
pub fn fp(&self) -> &vk::KhrDisplayFn { pub fn fp(&self) -> &vk::KhrDisplayFn {
&self.display_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct DisplaySwapchain { pub struct DisplaySwapchain {
handle: vk::Device, handle: vk::Device,
swapchain_fn: vk::KhrDisplaySwapchainFn, fp: vk::KhrDisplaySwapchainFn,
} }
impl DisplaySwapchain { impl DisplaySwapchain {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let swapchain_fn = vk::KhrDisplaySwapchainFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrDisplaySwapchainFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
swapchain_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrDisplaySwapchainFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSharedSwapchainsKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSharedSwapchainsKHR.html>"]
@ -33,7 +27,7 @@ impl DisplaySwapchain {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<Vec<vk::SwapchainKHR>> { ) -> VkResult<Vec<vk::SwapchainKHR>> {
let mut swapchains = Vec::with_capacity(create_infos.len()); let mut swapchains = Vec::with_capacity(create_infos.len());
let err_code = self.swapchain_fn.create_shared_swapchains_khr( let err_code = self.fp.create_shared_swapchains_khr(
self.handle, self.handle,
create_infos.len() as u32, create_infos.len() as u32,
create_infos.as_ptr(), create_infos.as_ptr(),
@ -44,8 +38,12 @@ impl DisplaySwapchain {
err_code.result_with_success(swapchains) err_code.result_with_success(swapchains)
} }
pub fn name() -> &'static CStr {
vk::KhrDisplaySwapchainFn::name()
}
pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn { pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn {
&self.swapchain_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -5,23 +5,15 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct DrawIndirectCount { pub struct DrawIndirectCount {
handle: vk::Device, fp: vk::KhrDrawIndirectCountFn,
draw_indirect_count_fn: vk::KhrDrawIndirectCountFn,
} }
impl DrawIndirectCount { impl DrawIndirectCount {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let draw_indirect_count_fn = vk::KhrDrawIndirectCountFn::load(|name| unsafe { let fp = vk::KhrDrawIndirectCountFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
}); });
Self { Self { fp }
handle: device.handle(),
draw_indirect_count_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrDrawIndirectCountFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndexedIndirectCountKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndexedIndirectCountKHR.html>"]
@ -35,16 +27,15 @@ impl DrawIndirectCount {
max_draw_count: u32, max_draw_count: u32,
stride: u32, stride: u32,
) { ) {
self.draw_indirect_count_fn self.fp.cmd_draw_indexed_indirect_count_khr(
.cmd_draw_indexed_indirect_count_khr( command_buffer,
command_buffer, buffer,
buffer, offset,
offset, count_buffer,
count_buffer, count_buffer_offset,
count_buffer_offset, max_draw_count,
max_draw_count, stride,
stride, );
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndirectCountKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndirectCountKHR.html>"]
@ -58,15 +49,22 @@ impl DrawIndirectCount {
max_draw_count: u32, max_draw_count: u32,
stride: u32, stride: u32,
) { ) {
self.draw_indirect_count_fn self.fp.cmd_draw_indexed_indirect_count_khr(
.cmd_draw_indexed_indirect_count_khr( command_buffer,
command_buffer, buffer,
buffer, offset,
offset, count_buffer,
count_buffer, count_buffer_offset,
count_buffer_offset, max_draw_count,
max_draw_count, stride,
stride, );
); }
pub fn name() -> &'static CStr {
vk::KhrDrawIndirectCountFn::name()
}
pub fn fp(&self) -> &vk::KhrDrawIndirectCountFn {
&self.fp
} }
} }

View file

@ -5,25 +5,15 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct DynamicRendering { pub struct DynamicRendering {
fns: vk::KhrDynamicRenderingFn, fp: vk::KhrDynamicRenderingFn,
} }
impl DynamicRendering { impl DynamicRendering {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let dynamic_rendering_fn = vk::KhrDynamicRenderingFn::load(|name| unsafe { let fp = vk::KhrDynamicRenderingFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
}); });
Self { Self { fp }
fns: dynamic_rendering_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrDynamicRenderingFn::name()
}
pub fn fp(&self) -> &vk::KhrDynamicRenderingFn {
&self.fns
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginRenderingKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginRenderingKHR.html>"]
@ -32,12 +22,20 @@ impl DynamicRendering {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
rendering_info: &vk::RenderingInfoKHR, rendering_info: &vk::RenderingInfoKHR,
) { ) {
self.fns self.fp
.cmd_begin_rendering_khr(command_buffer, rendering_info) .cmd_begin_rendering_khr(command_buffer, rendering_info)
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndRenderingKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndRenderingKHR.html>"]
pub unsafe fn cmd_end_rendering(&self, command_buffer: vk::CommandBuffer) { pub unsafe fn cmd_end_rendering(&self, command_buffer: vk::CommandBuffer) {
self.fns.cmd_end_rendering_khr(command_buffer) self.fp.cmd_end_rendering_khr(command_buffer)
}
pub fn name() -> &'static CStr {
vk::KhrDynamicRenderingFn::name()
}
pub fn fp(&self) -> &vk::KhrDynamicRenderingFn {
&self.fp
} }
} }

View file

@ -7,27 +7,21 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct ExternalFenceFd { pub struct ExternalFenceFd {
handle: vk::Device, handle: vk::Device,
external_fence_fd_fn: vk::KhrExternalFenceFdFn, fp: vk::KhrExternalFenceFdFn,
} }
impl ExternalFenceFd { impl ExternalFenceFd {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let external_fence_fd_fn = vk::KhrExternalFenceFdFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrExternalFenceFdFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
external_fence_fd_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrExternalFenceFdFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkImportFenceFdKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkImportFenceFdKHR.html>"]
pub unsafe fn import_fence_fd(&self, import_info: &vk::ImportFenceFdInfoKHR) -> VkResult<()> { pub unsafe fn import_fence_fd(&self, import_info: &vk::ImportFenceFdInfoKHR) -> VkResult<()> {
self.external_fence_fd_fn self.fp
.import_fence_fd_khr(self.handle, import_info) .import_fence_fd_khr(self.handle, import_info)
.result() .result()
} }
@ -35,14 +29,17 @@ impl ExternalFenceFd {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetFenceFdKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetFenceFdKHR.html>"]
pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR) -> VkResult<i32> { pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR) -> VkResult<i32> {
let mut fd = -1; let mut fd = -1;
self.fp
self.external_fence_fd_fn
.get_fence_fd_khr(self.handle, get_info, &mut fd) .get_fence_fd_khr(self.handle, get_info, &mut fd)
.result_with_success(fd) .result_with_success(fd)
} }
pub fn name() -> &'static CStr {
vk::KhrExternalFenceFdFn::name()
}
pub fn fp(&self) -> &vk::KhrExternalFenceFdFn { pub fn fp(&self) -> &vk::KhrExternalFenceFdFn {
&self.external_fence_fd_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -7,29 +7,22 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct ExternalMemoryFd { pub struct ExternalMemoryFd {
handle: vk::Device, handle: vk::Device,
external_memory_fd_fn: vk::KhrExternalMemoryFdFn, fp: vk::KhrExternalMemoryFdFn,
} }
impl ExternalMemoryFd { impl ExternalMemoryFd {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let external_memory_fd_fn = vk::KhrExternalMemoryFdFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrExternalMemoryFdFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
external_memory_fd_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrExternalMemoryFdFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdKHR.html>"]
pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> { pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> {
let mut fd = -1; let mut fd = -1;
self.fp
self.external_memory_fd_fn
.get_memory_fd_khr(self.handle, create_info, &mut fd) .get_memory_fd_khr(self.handle, create_info, &mut fd)
.result_with_success(fd) .result_with_success(fd)
} }
@ -41,13 +34,17 @@ impl ExternalMemoryFd {
fd: i32, fd: i32,
) -> VkResult<vk::MemoryFdPropertiesKHR> { ) -> VkResult<vk::MemoryFdPropertiesKHR> {
let mut memory_fd_properties = Default::default(); let mut memory_fd_properties = Default::default();
self.external_memory_fd_fn self.fp
.get_memory_fd_properties_khr(self.handle, handle_type, fd, &mut memory_fd_properties) .get_memory_fd_properties_khr(self.handle, handle_type, fd, &mut memory_fd_properties)
.result_with_success(memory_fd_properties) .result_with_success(memory_fd_properties)
} }
pub fn name() -> &'static CStr {
vk::KhrExternalMemoryFdFn::name()
}
pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn { pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn {
&self.external_memory_fd_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -7,22 +7,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct ExternalSemaphoreFd { pub struct ExternalSemaphoreFd {
handle: vk::Device, handle: vk::Device,
external_semaphore_fd_fn: vk::KhrExternalSemaphoreFdFn, fp: vk::KhrExternalSemaphoreFdFn,
} }
impl ExternalSemaphoreFd { impl ExternalSemaphoreFd {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let external_semaphore_fd_fn = vk::KhrExternalSemaphoreFdFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrExternalSemaphoreFdFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
external_semaphore_fd_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrExternalSemaphoreFdFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkImportSemaphoreFdKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkImportSemaphoreFdKHR.html>"]
@ -30,7 +24,7 @@ impl ExternalSemaphoreFd {
&self, &self,
import_info: &vk::ImportSemaphoreFdInfoKHR, import_info: &vk::ImportSemaphoreFdInfoKHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.external_semaphore_fd_fn self.fp
.import_semaphore_fd_khr(self.handle, import_info) .import_semaphore_fd_khr(self.handle, import_info)
.result() .result()
} }
@ -38,14 +32,17 @@ impl ExternalSemaphoreFd {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreFdKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreFdKHR.html>"]
pub unsafe fn get_semaphore_fd(&self, get_info: &vk::SemaphoreGetFdInfoKHR) -> VkResult<i32> { pub unsafe fn get_semaphore_fd(&self, get_info: &vk::SemaphoreGetFdInfoKHR) -> VkResult<i32> {
let mut fd = -1; let mut fd = -1;
self.fp
self.external_semaphore_fd_fn
.get_semaphore_fd_khr(self.handle, get_info, &mut fd) .get_semaphore_fd_khr(self.handle, get_info, &mut fd)
.result_with_success(fd) .result_with_success(fd)
} }
pub fn name() -> &'static CStr {
vk::KhrExternalSemaphoreFdFn::name()
}
pub fn fp(&self) -> &vk::KhrExternalSemaphoreFdFn { pub fn fp(&self) -> &vk::KhrExternalSemaphoreFdFn {
&self.external_semaphore_fd_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -7,22 +7,16 @@ use std::ptr;
#[derive(Clone)] #[derive(Clone)]
pub struct GetMemoryRequirements2 { pub struct GetMemoryRequirements2 {
handle: vk::Device, handle: vk::Device,
get_memory_requirements2_fn: vk::KhrGetMemoryRequirements2Fn, fp: vk::KhrGetMemoryRequirements2Fn,
} }
impl GetMemoryRequirements2 { impl GetMemoryRequirements2 {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let get_memory_requirements2_fn = vk::KhrGetMemoryRequirements2Fn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrGetMemoryRequirements2Fn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
get_memory_requirements2_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrGetMemoryRequirements2Fn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferMemoryRequirements2KHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferMemoryRequirements2KHR.html>"]
@ -31,7 +25,7 @@ impl GetMemoryRequirements2 {
info: &vk::BufferMemoryRequirementsInfo2KHR, info: &vk::BufferMemoryRequirementsInfo2KHR,
memory_requirements: &mut vk::MemoryRequirements2KHR, memory_requirements: &mut vk::MemoryRequirements2KHR,
) { ) {
self.get_memory_requirements2_fn self.fp
.get_buffer_memory_requirements2_khr(self.handle, info, memory_requirements); .get_buffer_memory_requirements2_khr(self.handle, info, memory_requirements);
} }
@ -41,7 +35,7 @@ impl GetMemoryRequirements2 {
info: &vk::ImageMemoryRequirementsInfo2KHR, info: &vk::ImageMemoryRequirementsInfo2KHR,
memory_requirements: &mut vk::MemoryRequirements2KHR, memory_requirements: &mut vk::MemoryRequirements2KHR,
) { ) {
self.get_memory_requirements2_fn self.fp
.get_image_memory_requirements2_khr(self.handle, info, memory_requirements); .get_image_memory_requirements2_khr(self.handle, info, memory_requirements);
} }
@ -51,13 +45,12 @@ impl GetMemoryRequirements2 {
info: &vk::ImageSparseMemoryRequirementsInfo2KHR, info: &vk::ImageSparseMemoryRequirementsInfo2KHR,
) -> usize { ) -> usize {
let mut count = 0; let mut count = 0;
self.get_memory_requirements2_fn self.fp.get_image_sparse_memory_requirements2_khr(
.get_image_sparse_memory_requirements2_khr( self.handle,
self.handle, info,
info, &mut count,
&mut count, ptr::null_mut(),
ptr::null_mut(), );
);
count as usize count as usize
} }
@ -71,17 +64,20 @@ impl GetMemoryRequirements2 {
out: &mut [vk::SparseImageMemoryRequirements2KHR], out: &mut [vk::SparseImageMemoryRequirements2KHR],
) { ) {
let mut count = out.len() as u32; let mut count = out.len() as u32;
self.get_memory_requirements2_fn self.fp.get_image_sparse_memory_requirements2_khr(
.get_image_sparse_memory_requirements2_khr( self.handle,
self.handle, info,
info, &mut count,
&mut count, out.as_mut_ptr(),
out.as_mut_ptr(), );
); }
pub fn name() -> &'static CStr {
vk::KhrGetMemoryRequirements2Fn::name()
} }
pub fn fp(&self) -> &vk::KhrGetMemoryRequirements2Fn { pub fn fp(&self) -> &vk::KhrGetMemoryRequirements2Fn {
&self.get_memory_requirements2_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -7,24 +7,15 @@ use std::ptr;
#[derive(Clone)] #[derive(Clone)]
pub struct GetPhysicalDeviceProperties2 { pub struct GetPhysicalDeviceProperties2 {
handle: vk::Instance, fp: vk::KhrGetPhysicalDeviceProperties2Fn,
get_physical_device_properties2_fn: vk::KhrGetPhysicalDeviceProperties2Fn,
} }
impl GetPhysicalDeviceProperties2 { impl GetPhysicalDeviceProperties2 {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let get_physical_device_properties2_fn = let fp = vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe {
vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) });
}); Self { fp }
Self {
handle: instance.handle(),
get_physical_device_properties2_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrGetPhysicalDeviceProperties2Fn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures2KHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures2KHR.html>"]
@ -33,7 +24,7 @@ impl GetPhysicalDeviceProperties2 {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
features: &mut vk::PhysicalDeviceFeatures2KHR, features: &mut vk::PhysicalDeviceFeatures2KHR,
) { ) {
self.get_physical_device_properties2_fn self.fp
.get_physical_device_features2_khr(physical_device, features); .get_physical_device_features2_khr(physical_device, features);
} }
@ -44,8 +35,11 @@ impl GetPhysicalDeviceProperties2 {
format: vk::Format, format: vk::Format,
format_properties: &mut vk::FormatProperties2KHR, format_properties: &mut vk::FormatProperties2KHR,
) { ) {
self.get_physical_device_properties2_fn self.fp.get_physical_device_format_properties2_khr(
.get_physical_device_format_properties2_khr(physical_device, format, format_properties); physical_device,
format,
format_properties,
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2KHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2KHR.html>"]
@ -55,7 +49,7 @@ impl GetPhysicalDeviceProperties2 {
image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR, image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR,
image_format_properties: &mut vk::ImageFormatProperties2KHR, image_format_properties: &mut vk::ImageFormatProperties2KHR,
) -> VkResult<()> { ) -> VkResult<()> {
self.get_physical_device_properties2_fn self.fp
.get_physical_device_image_format_properties2_khr( .get_physical_device_image_format_properties2_khr(
physical_device, physical_device,
image_format_info, image_format_info,
@ -70,7 +64,7 @@ impl GetPhysicalDeviceProperties2 {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR, memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR,
) { ) {
self.get_physical_device_properties2_fn self.fp
.get_physical_device_memory_properties2_khr(physical_device, memory_properties); .get_physical_device_memory_properties2_khr(physical_device, memory_properties);
} }
@ -80,7 +74,7 @@ impl GetPhysicalDeviceProperties2 {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
properties: &mut vk::PhysicalDeviceProperties2KHR, properties: &mut vk::PhysicalDeviceProperties2KHR,
) { ) {
self.get_physical_device_properties2_fn self.fp
.get_physical_device_properties2_khr(physical_device, properties); .get_physical_device_properties2_khr(physical_device, properties);
} }
@ -90,12 +84,11 @@ impl GetPhysicalDeviceProperties2 {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
) -> usize { ) -> usize {
let mut count = 0; let mut count = 0;
self.get_physical_device_properties2_fn self.fp.get_physical_device_queue_family_properties2_khr(
.get_physical_device_queue_family_properties2_khr( physical_device,
physical_device, &mut count,
&mut count, ptr::null_mut(),
ptr::null_mut(), );
);
count as usize count as usize
} }
@ -109,12 +102,11 @@ impl GetPhysicalDeviceProperties2 {
out: &mut [vk::QueueFamilyProperties2KHR], out: &mut [vk::QueueFamilyProperties2KHR],
) { ) {
let mut count = out.len() as u32; let mut count = out.len() as u32;
self.get_physical_device_properties2_fn self.fp.get_physical_device_queue_family_properties2_khr(
.get_physical_device_queue_family_properties2_khr( physical_device,
physical_device, &mut count,
&mut count, out.as_mut_ptr(),
out.as_mut_ptr(), );
);
} }
/// Retrieve the number of elements to pass to [`Self::get_physical_device_sparse_image_format_properties2()`] /// Retrieve the number of elements to pass to [`Self::get_physical_device_sparse_image_format_properties2()`]
@ -124,7 +116,7 @@ impl GetPhysicalDeviceProperties2 {
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR,
) -> usize { ) -> usize {
let mut count = 0; let mut count = 0;
self.get_physical_device_properties2_fn self.fp
.get_physical_device_sparse_image_format_properties2_khr( .get_physical_device_sparse_image_format_properties2_khr(
physical_device, physical_device,
format_info, format_info,
@ -145,7 +137,7 @@ impl GetPhysicalDeviceProperties2 {
out: &mut [vk::SparseImageFormatProperties2KHR], out: &mut [vk::SparseImageFormatProperties2KHR],
) { ) {
let mut count = out.len() as u32; let mut count = out.len() as u32;
self.get_physical_device_properties2_fn self.fp
.get_physical_device_sparse_image_format_properties2_khr( .get_physical_device_sparse_image_format_properties2_khr(
physical_device, physical_device,
format_info, format_info,
@ -154,11 +146,11 @@ impl GetPhysicalDeviceProperties2 {
); );
} }
pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn { pub fn name() -> &'static CStr {
&self.get_physical_device_properties2_fn vk::KhrGetPhysicalDeviceProperties2Fn::name()
} }
pub fn instance(&self) -> vk::Instance { pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn {
self.handle &self.fp
} }
} }

View file

@ -6,22 +6,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Maintenance1 { pub struct Maintenance1 {
handle: vk::Device, handle: vk::Device,
fns: vk::KhrMaintenance1Fn, fp: vk::KhrMaintenance1Fn,
} }
impl Maintenance1 { impl Maintenance1 {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let fns = vk::KhrMaintenance1Fn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrMaintenance1Fn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
fns,
}
}
pub fn name() -> &'static CStr {
vk::KhrMaintenance1Fn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkTrimCommandPoolKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkTrimCommandPoolKHR.html>"]
@ -30,12 +24,16 @@ impl Maintenance1 {
command_pool: vk::CommandPool, command_pool: vk::CommandPool,
flags: vk::CommandPoolTrimFlagsKHR, flags: vk::CommandPoolTrimFlagsKHR,
) { ) {
self.fns self.fp
.trim_command_pool_khr(self.handle, command_pool, flags); .trim_command_pool_khr(self.handle, command_pool, flags);
} }
pub fn name() -> &'static CStr {
vk::KhrMaintenance1Fn::name()
}
pub fn fp(&self) -> &vk::KhrMaintenance1Fn { pub fn fp(&self) -> &vk::KhrMaintenance1Fn {
&self.fns &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -6,22 +6,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Maintenance3 { pub struct Maintenance3 {
handle: vk::Device, handle: vk::Device,
fns: vk::KhrMaintenance3Fn, fp: vk::KhrMaintenance3Fn,
} }
impl Maintenance3 { impl Maintenance3 {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let fns = vk::KhrMaintenance3Fn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrMaintenance3Fn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
fns,
}
}
pub fn name() -> &'static CStr {
vk::KhrMaintenance3Fn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDescriptorSetLayoutSupportKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDescriptorSetLayoutSupportKHR.html>"]
@ -30,12 +24,16 @@ impl Maintenance3 {
create_info: &vk::DescriptorSetLayoutCreateInfo, create_info: &vk::DescriptorSetLayoutCreateInfo,
out: &mut vk::DescriptorSetLayoutSupportKHR, out: &mut vk::DescriptorSetLayoutSupportKHR,
) { ) {
self.fns self.fp
.get_descriptor_set_layout_support_khr(self.handle, create_info, out); .get_descriptor_set_layout_support_khr(self.handle, create_info, out);
} }
pub fn name() -> &'static CStr {
vk::KhrMaintenance3Fn::name()
}
pub fn fp(&self) -> &vk::KhrMaintenance3Fn { pub fn fp(&self) -> &vk::KhrMaintenance3Fn {
&self.fns &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -6,18 +6,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Maintenance4 { pub struct Maintenance4 {
handle: vk::Device, handle: vk::Device,
fns: vk::KhrMaintenance4Fn, fp: vk::KhrMaintenance4Fn,
} }
impl Maintenance4 { impl Maintenance4 {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let fns = vk::KhrMaintenance4Fn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrMaintenance4Fn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
fns,
}
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceBufferMemoryRequirementsKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceBufferMemoryRequirementsKHR.html>"]
@ -26,7 +24,7 @@ impl Maintenance4 {
create_info: &vk::DeviceBufferMemoryRequirementsKHR, create_info: &vk::DeviceBufferMemoryRequirementsKHR,
out: &mut vk::MemoryRequirements2, out: &mut vk::MemoryRequirements2,
) { ) {
self.fns self.fp
.get_device_buffer_memory_requirements_khr(self.handle, create_info, out) .get_device_buffer_memory_requirements_khr(self.handle, create_info, out)
} }
@ -36,7 +34,7 @@ impl Maintenance4 {
create_info: &vk::DeviceImageMemoryRequirementsKHR, create_info: &vk::DeviceImageMemoryRequirementsKHR,
out: &mut vk::MemoryRequirements2, out: &mut vk::MemoryRequirements2,
) { ) {
self.fns self.fp
.get_device_image_memory_requirements_khr(self.handle, create_info, out) .get_device_image_memory_requirements_khr(self.handle, create_info, out)
} }
@ -46,7 +44,7 @@ impl Maintenance4 {
create_info: &vk::DeviceImageMemoryRequirementsKHR, create_info: &vk::DeviceImageMemoryRequirementsKHR,
) -> usize { ) -> usize {
let mut count = 0; let mut count = 0;
self.fns.get_device_image_sparse_memory_requirements_khr( self.fp.get_device_image_sparse_memory_requirements_khr(
self.handle, self.handle,
create_info, create_info,
&mut count, &mut count,
@ -65,7 +63,7 @@ impl Maintenance4 {
out: &mut [vk::SparseImageMemoryRequirements2], out: &mut [vk::SparseImageMemoryRequirements2],
) { ) {
let mut count = out.len() as u32; let mut count = out.len() as u32;
self.fns.get_device_image_sparse_memory_requirements_khr( self.fp.get_device_image_sparse_memory_requirements_khr(
self.handle, self.handle,
create_info, create_info,
&mut count, &mut count,
@ -79,7 +77,7 @@ impl Maintenance4 {
} }
pub fn fp(&self) -> &vk::KhrMaintenance4Fn { pub fn fp(&self) -> &vk::KhrMaintenance4Fn {
&self.fns &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -7,23 +7,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct PipelineExecutableProperties { pub struct PipelineExecutableProperties {
handle: vk::Device, handle: vk::Device,
pipeline_executable_properties_fn: vk::KhrPipelineExecutablePropertiesFn, fp: vk::KhrPipelineExecutablePropertiesFn,
} }
impl PipelineExecutableProperties { impl PipelineExecutableProperties {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let pipeline_executable_properties_fn = let handle = device.handle();
vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe { let fp = vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
pipeline_executable_properties_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrPipelineExecutablePropertiesFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableInternalRepresentationsKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableInternalRepresentationsKHR.html>"]
@ -32,7 +25,7 @@ impl PipelineExecutableProperties {
executable_info: &vk::PipelineExecutableInfoKHR, executable_info: &vk::PipelineExecutableInfoKHR,
) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> { ) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> {
read_into_defaulted_vector(|count, data| { read_into_defaulted_vector(|count, data| {
self.pipeline_executable_properties_fn self.fp
.get_pipeline_executable_internal_representations_khr( .get_pipeline_executable_internal_representations_khr(
self.handle, self.handle,
executable_info, executable_info,
@ -45,11 +38,10 @@ impl PipelineExecutableProperties {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html>"]
pub unsafe fn get_pipeline_executable_properties( pub unsafe fn get_pipeline_executable_properties(
&self, &self,
pipeline_info: &vk::PipelineInfoKHR, pipeline_info: &vk::PipelineInfoKHR,
) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> { ) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> {
read_into_defaulted_vector(|count, data| { read_into_defaulted_vector(|count, data| {
self.pipeline_executable_properties_fn self.fp
.get_pipeline_executable_properties_khr(self.handle, pipeline_info, count, data) .get_pipeline_executable_properties_khr(self.handle, pipeline_info, count, data)
}) })
} }
@ -57,17 +49,24 @@ impl PipelineExecutableProperties {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html>"]
pub unsafe fn get_pipeline_executable_statistics( pub unsafe fn get_pipeline_executable_statistics(
&self, &self,
executable_info: &vk::PipelineExecutableInfoKHR, executable_info: &vk::PipelineExecutableInfoKHR,
) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> { ) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> {
read_into_defaulted_vector(|count, data| { read_into_defaulted_vector(|count, data| {
self.pipeline_executable_properties_fn self.fp.get_pipeline_executable_statistics_khr(
.get_pipeline_executable_statistics_khr(self.handle, executable_info, count, data) self.handle,
executable_info,
count,
data,
)
}) })
} }
pub fn name() -> &'static CStr {
vk::KhrPipelineExecutablePropertiesFn::name()
}
pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn { pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn {
&self.pipeline_executable_properties_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -7,16 +7,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct PresentWait { pub struct PresentWait {
handle: vk::Device, handle: vk::Device,
fns: vk::KhrPresentWaitFn, fp: vk::KhrPresentWaitFn,
} }
impl PresentWait { impl PresentWait {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let handle = device.handle(); let handle = device.handle();
let fns = vk::KhrPresentWaitFn::load(|name| unsafe { let fp = vk::KhrPresentWaitFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { handle, fns } Self { handle, fp }
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitForPresentKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitForPresentKHR.html>"]
@ -26,7 +26,7 @@ impl PresentWait {
present_id: u64, present_id: u64,
timeout: u64, timeout: u64,
) -> VkResult<()> { ) -> VkResult<()> {
self.fns self.fp
.wait_for_present_khr(self.handle, swapchain, present_id, timeout) .wait_for_present_khr(self.handle, swapchain, present_id, timeout)
.result() .result()
} }
@ -36,7 +36,7 @@ impl PresentWait {
} }
pub fn fp(&self) -> &vk::KhrPresentWaitFn { pub fn fp(&self) -> &vk::KhrPresentWaitFn {
&self.fns &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -6,23 +6,15 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct PushDescriptor { pub struct PushDescriptor {
handle: vk::Instance, fp: vk::KhrPushDescriptorFn,
push_descriptors_fn: vk::KhrPushDescriptorFn,
} }
impl PushDescriptor { impl PushDescriptor {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let push_descriptors_fn = vk::KhrPushDescriptorFn::load(|name| unsafe { let fp = vk::KhrPushDescriptorFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
}); });
Self { Self { fp }
handle: instance.handle(),
push_descriptors_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrPushDescriptorFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetKHR.html>"]
@ -34,7 +26,7 @@ impl PushDescriptor {
set: u32, set: u32,
descriptor_writes: &[vk::WriteDescriptorSet], descriptor_writes: &[vk::WriteDescriptorSet],
) { ) {
self.push_descriptors_fn.cmd_push_descriptor_set_khr( self.fp.cmd_push_descriptor_set_khr(
command_buffer, command_buffer,
pipeline_bind_point, pipeline_bind_point,
layout, layout,
@ -53,21 +45,20 @@ impl PushDescriptor {
set: u32, set: u32,
p_data: *const c_void, p_data: *const c_void,
) { ) {
self.push_descriptors_fn self.fp.cmd_push_descriptor_set_with_template_khr(
.cmd_push_descriptor_set_with_template_khr( command_buffer,
command_buffer, descriptor_update_template,
descriptor_update_template, layout,
layout, set,
set, p_data,
p_data, );
); }
pub fn name() -> &'static CStr {
vk::KhrPushDescriptorFn::name()
} }
pub fn fp(&self) -> &vk::KhrPushDescriptorFn { pub fn fp(&self) -> &vk::KhrPushDescriptorFn {
&self.push_descriptors_fn &self.fp
}
pub fn instance(&self) -> vk::Instance {
self.handle
} }
} }

View file

@ -8,18 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct RayTracingPipeline { pub struct RayTracingPipeline {
handle: vk::Device, handle: vk::Device,
ray_tracing_fn: vk::KhrRayTracingPipelineFn, fp: vk::KhrRayTracingPipelineFn,
} }
impl RayTracingPipeline { impl RayTracingPipeline {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let ray_tracing_fn = vk::KhrRayTracingPipelineFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrRayTracingPipelineFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
ray_tracing_fn,
}
} }
pub unsafe fn get_properties( pub unsafe fn get_properties(
@ -46,7 +44,7 @@ impl RayTracingPipeline {
height: u32, height: u32,
depth: u32, depth: u32,
) { ) {
self.ray_tracing_fn.cmd_trace_rays_khr( self.fp.cmd_trace_rays_khr(
command_buffer, command_buffer,
raygen_shader_binding_tables as *const _, raygen_shader_binding_tables as *const _,
miss_shader_binding_tables as *const _, miss_shader_binding_tables as *const _,
@ -67,7 +65,7 @@ impl RayTracingPipeline {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<Vec<vk::Pipeline>> { ) -> VkResult<Vec<vk::Pipeline>> {
let mut pipelines = vec![mem::zeroed(); create_info.len()]; let mut pipelines = vec![mem::zeroed(); create_info.len()];
self.ray_tracing_fn self.fp
.create_ray_tracing_pipelines_khr( .create_ray_tracing_pipelines_khr(
self.handle, self.handle,
deferred_operation, deferred_operation,
@ -89,16 +87,14 @@ impl RayTracingPipeline {
data_size: usize, data_size: usize,
) -> VkResult<Vec<u8>> { ) -> VkResult<Vec<u8>> {
let mut data = Vec::<u8>::with_capacity(data_size); let mut data = Vec::<u8>::with_capacity(data_size);
let err_code = self let err_code = self.fp.get_ray_tracing_shader_group_handles_khr(
.ray_tracing_fn self.handle,
.get_ray_tracing_shader_group_handles_khr( pipeline,
self.handle, first_group,
pipeline, group_count,
first_group, data_size,
group_count, data.as_mut_ptr() as *mut std::ffi::c_void,
data_size, );
data.as_mut_ptr() as *mut std::ffi::c_void,
);
data.set_len(data_size); data.set_len(data_size);
err_code.result_with_success(data) err_code.result_with_success(data)
} }
@ -113,7 +109,7 @@ impl RayTracingPipeline {
) -> VkResult<Vec<u8>> { ) -> VkResult<Vec<u8>> {
let mut data: Vec<u8> = Vec::with_capacity(data_size); let mut data: Vec<u8> = Vec::with_capacity(data_size);
self.ray_tracing_fn self.fp
.get_ray_tracing_capture_replay_shader_group_handles_khr( .get_ray_tracing_capture_replay_shader_group_handles_khr(
self.handle, self.handle,
pipeline, pipeline,
@ -135,7 +131,7 @@ impl RayTracingPipeline {
callable_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], callable_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR],
indirect_device_address: vk::DeviceAddress, indirect_device_address: vk::DeviceAddress,
) { ) {
self.ray_tracing_fn.cmd_trace_rays_indirect_khr( self.fp.cmd_trace_rays_indirect_khr(
command_buffer, command_buffer,
raygen_shader_binding_table.as_ptr(), raygen_shader_binding_table.as_ptr(),
miss_shader_binding_table.as_ptr(), miss_shader_binding_table.as_ptr(),
@ -152,8 +148,12 @@ impl RayTracingPipeline {
group: u32, group: u32,
group_shader: vk::ShaderGroupShaderKHR, group_shader: vk::ShaderGroupShaderKHR,
) -> vk::DeviceSize { ) -> vk::DeviceSize {
self.ray_tracing_fn self.fp.get_ray_tracing_shader_group_stack_size_khr(
.get_ray_tracing_shader_group_stack_size_khr(self.handle, pipeline, group, group_shader) self.handle,
pipeline,
group,
group_shader,
)
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetRayTracingPipelineStackSizeKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetRayTracingPipelineStackSizeKHR.html>"]
@ -162,7 +162,7 @@ impl RayTracingPipeline {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
pipeline_stack_size: u32, pipeline_stack_size: u32,
) { ) {
self.ray_tracing_fn self.fp
.cmd_set_ray_tracing_pipeline_stack_size_khr(command_buffer, pipeline_stack_size); .cmd_set_ray_tracing_pipeline_stack_size_khr(command_buffer, pipeline_stack_size);
} }
@ -171,7 +171,7 @@ impl RayTracingPipeline {
} }
pub fn fp(&self) -> &vk::KhrRayTracingPipelineFn { pub fn fp(&self) -> &vk::KhrRayTracingPipelineFn {
&self.ray_tracing_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Surface { pub struct Surface {
handle: vk::Instance, handle: vk::Instance,
surface_fn: vk::KhrSurfaceFn, fp: vk::KhrSurfaceFn,
} }
impl Surface { impl Surface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::KhrSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::KhrSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html>"]
@ -34,7 +28,7 @@ impl Surface {
surface: vk::SurfaceKHR, surface: vk::SurfaceKHR,
) -> VkResult<bool> { ) -> VkResult<bool> {
let mut b = 0; let mut b = 0;
self.surface_fn self.fp
.get_physical_device_surface_support_khr( .get_physical_device_surface_support_khr(
physical_device, physical_device,
queue_family_index, queue_family_index,
@ -51,13 +45,12 @@ impl Surface {
surface: vk::SurfaceKHR, surface: vk::SurfaceKHR,
) -> VkResult<Vec<vk::PresentModeKHR>> { ) -> VkResult<Vec<vk::PresentModeKHR>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.surface_fn self.fp.get_physical_device_surface_present_modes_khr(
.get_physical_device_surface_present_modes_khr( physical_device,
physical_device, surface,
surface, count,
count, data,
data, )
)
}) })
} }
@ -68,7 +61,7 @@ impl Surface {
surface: vk::SurfaceKHR, surface: vk::SurfaceKHR,
) -> VkResult<vk::SurfaceCapabilitiesKHR> { ) -> VkResult<vk::SurfaceCapabilitiesKHR> {
let mut surface_capabilities = mem::zeroed(); let mut surface_capabilities = mem::zeroed();
self.surface_fn self.fp
.get_physical_device_surface_capabilities_khr( .get_physical_device_surface_capabilities_khr(
physical_device, physical_device,
surface, surface,
@ -84,12 +77,8 @@ impl Surface {
surface: vk::SurfaceKHR, surface: vk::SurfaceKHR,
) -> VkResult<Vec<vk::SurfaceFormatKHR>> { ) -> VkResult<Vec<vk::SurfaceFormatKHR>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.surface_fn.get_physical_device_surface_formats_khr( self.fp
physical_device, .get_physical_device_surface_formats_khr(physical_device, surface, count, data)
surface,
count,
data,
)
}) })
} }
@ -99,15 +88,16 @@ impl Surface {
surface: vk::SurfaceKHR, surface: vk::SurfaceKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) { ) {
self.surface_fn.destroy_surface_khr( self.fp
self.handle, .destroy_surface_khr(self.handle, surface, allocation_callbacks.as_raw_ptr());
surface, }
allocation_callbacks.as_raw_ptr(),
); pub fn name() -> &'static CStr {
vk::KhrSurfaceFn::name()
} }
pub fn fp(&self) -> &vk::KhrSurfaceFn { pub fn fp(&self) -> &vk::KhrSurfaceFn {
&self.surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Swapchain { pub struct Swapchain {
handle: vk::Device, handle: vk::Device,
swapchain_fn: vk::KhrSwapchainFn, fp: vk::KhrSwapchainFn,
} }
impl Swapchain { impl Swapchain {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let swapchain_fn = vk::KhrSwapchainFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrSwapchainFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
swapchain_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrSwapchainFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySwapchainKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySwapchainKHR.html>"]
@ -32,11 +26,8 @@ impl Swapchain {
swapchain: vk::SwapchainKHR, swapchain: vk::SwapchainKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) { ) {
self.swapchain_fn.destroy_swapchain_khr( self.fp
self.handle, .destroy_swapchain_khr(self.handle, swapchain, allocation_callbacks.as_raw_ptr());
swapchain,
allocation_callbacks.as_raw_ptr(),
);
} }
/// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface.
@ -49,7 +40,7 @@ impl Swapchain {
fence: vk::Fence, fence: vk::Fence,
) -> VkResult<(u32, bool)> { ) -> VkResult<(u32, bool)> {
let mut index = 0; let mut index = 0;
let err_code = self.swapchain_fn.acquire_next_image_khr( let err_code = self.fp.acquire_next_image_khr(
self.handle, self.handle,
swapchain, swapchain,
timeout, timeout,
@ -71,7 +62,7 @@ impl Swapchain {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SwapchainKHR> { ) -> VkResult<vk::SwapchainKHR> {
let mut swapchain = mem::zeroed(); let mut swapchain = mem::zeroed();
self.swapchain_fn self.fp
.create_swapchain_khr( .create_swapchain_khr(
self.handle, self.handle,
create_info, create_info,
@ -86,9 +77,9 @@ impl Swapchain {
pub unsafe fn queue_present( pub unsafe fn queue_present(
&self, &self,
queue: vk::Queue, queue: vk::Queue,
create_info: &vk::PresentInfoKHR, present_info: &vk::PresentInfoKHR,
) -> VkResult<bool> { ) -> VkResult<bool> {
let err_code = self.swapchain_fn.queue_present_khr(queue, create_info); let err_code = self.fp.queue_present_khr(queue, present_info);
match err_code { match err_code {
vk::Result::SUCCESS => Ok(false), vk::Result::SUCCESS => Ok(false),
vk::Result::SUBOPTIMAL_KHR => Ok(true), vk::Result::SUBOPTIMAL_KHR => Ok(true),
@ -102,13 +93,17 @@ impl Swapchain {
swapchain: vk::SwapchainKHR, swapchain: vk::SwapchainKHR,
) -> VkResult<Vec<vk::Image>> { ) -> VkResult<Vec<vk::Image>> {
read_into_uninitialized_vector(|count, data| { read_into_uninitialized_vector(|count, data| {
self.swapchain_fn self.fp
.get_swapchain_images_khr(self.handle, swapchain, count, data) .get_swapchain_images_khr(self.handle, swapchain, count, data)
}) })
} }
pub fn name() -> &'static CStr {
vk::KhrSwapchainFn::name()
}
pub fn fp(&self) -> &vk::KhrSwapchainFn { pub fn fp(&self) -> &vk::KhrSwapchainFn {
&self.swapchain_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -6,31 +6,15 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Synchronization2 { pub struct Synchronization2 {
handle: vk::Device, fp: vk::KhrSynchronization2Fn,
synchronization2_fn: vk::KhrSynchronization2Fn,
} }
impl Synchronization2 { impl Synchronization2 {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let synchronization2_fn = vk::KhrSynchronization2Fn::load(|name| unsafe { let fp = vk::KhrSynchronization2Fn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
}); });
Self { Self { fp }
handle: device.handle(),
synchronization2_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrSynchronization2Fn::name()
}
pub fn fp(&self) -> &vk::KhrSynchronization2Fn {
&self.synchronization2_fn
}
pub fn device(&self) -> vk::Device {
self.handle
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPipelineBarrier2KHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPipelineBarrier2KHR.html>"]
@ -39,7 +23,7 @@ impl Synchronization2 {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
dependency_info: &vk::DependencyInfoKHR, dependency_info: &vk::DependencyInfoKHR,
) { ) {
self.synchronization2_fn self.fp
.cmd_pipeline_barrier2_khr(command_buffer, dependency_info) .cmd_pipeline_barrier2_khr(command_buffer, dependency_info)
} }
@ -50,7 +34,7 @@ impl Synchronization2 {
event: vk::Event, event: vk::Event,
stage_mask: vk::PipelineStageFlags2KHR, stage_mask: vk::PipelineStageFlags2KHR,
) { ) {
self.synchronization2_fn self.fp
.cmd_reset_event2_khr(command_buffer, event, stage_mask) .cmd_reset_event2_khr(command_buffer, event, stage_mask)
} }
@ -61,7 +45,7 @@ impl Synchronization2 {
event: vk::Event, event: vk::Event,
dependency_info: &vk::DependencyInfoKHR, dependency_info: &vk::DependencyInfoKHR,
) { ) {
self.synchronization2_fn self.fp
.cmd_set_event2_khr(command_buffer, event, dependency_info) .cmd_set_event2_khr(command_buffer, event, dependency_info)
} }
@ -73,7 +57,7 @@ impl Synchronization2 {
dependency_infos: &[vk::DependencyInfoKHR], dependency_infos: &[vk::DependencyInfoKHR],
) { ) {
assert_eq!(events.len(), dependency_infos.len()); assert_eq!(events.len(), dependency_infos.len());
self.synchronization2_fn.cmd_wait_events2_khr( self.fp.cmd_wait_events2_khr(
command_buffer, command_buffer,
events.len() as u32, events.len() as u32,
events.as_ptr(), events.as_ptr(),
@ -89,7 +73,7 @@ impl Synchronization2 {
query_pool: vk::QueryPool, query_pool: vk::QueryPool,
query: u32, query: u32,
) { ) {
self.synchronization2_fn self.fp
.cmd_write_timestamp2_khr(command_buffer, stage, query_pool, query) .cmd_write_timestamp2_khr(command_buffer, stage, query_pool, query)
} }
@ -100,8 +84,16 @@ impl Synchronization2 {
submits: &[vk::SubmitInfo2KHR], submits: &[vk::SubmitInfo2KHR],
fence: vk::Fence, fence: vk::Fence,
) -> VkResult<()> { ) -> VkResult<()> {
self.synchronization2_fn self.fp
.queue_submit2_khr(queue, submits.len() as u32, submits.as_ptr(), fence) .queue_submit2_khr(queue, submits.len() as u32, submits.as_ptr(), fence)
.result() .result()
} }
pub fn name() -> &'static CStr {
vk::KhrSynchronization2Fn::name()
}
pub fn fp(&self) -> &vk::KhrSynchronization2Fn {
&self.fp
}
} }

View file

@ -7,28 +7,22 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct TimelineSemaphore { pub struct TimelineSemaphore {
handle: vk::Device, handle: vk::Device,
timeline_semaphore_fn: vk::KhrTimelineSemaphoreFn, fp: vk::KhrTimelineSemaphoreFn,
} }
impl TimelineSemaphore { impl TimelineSemaphore {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let timeline_semaphore_fn = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::KhrTimelineSemaphoreFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
timeline_semaphore_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrTimelineSemaphoreFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreCounterValue.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreCounterValue.html>"]
pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult<u64> { pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult<u64> {
let mut value = 0; let mut value = 0;
self.timeline_semaphore_fn self.fp
.get_semaphore_counter_value_khr(self.handle, semaphore, &mut value) .get_semaphore_counter_value_khr(self.handle, semaphore, &mut value)
.result_with_success(value) .result_with_success(value)
} }
@ -39,20 +33,24 @@ impl TimelineSemaphore {
wait_info: &vk::SemaphoreWaitInfo, wait_info: &vk::SemaphoreWaitInfo,
timeout: u64, timeout: u64,
) -> VkResult<()> { ) -> VkResult<()> {
self.timeline_semaphore_fn self.fp
.wait_semaphores_khr(self.handle, wait_info, timeout) .wait_semaphores_khr(self.handle, wait_info, timeout)
.result() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"]
pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> { pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> {
self.timeline_semaphore_fn self.fp
.signal_semaphore_khr(self.handle, signal_info) .signal_semaphore_khr(self.handle, signal_info)
.result() .result()
} }
pub fn name() -> &'static CStr {
vk::KhrTimelineSemaphoreFn::name()
}
pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn { pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn {
&self.timeline_semaphore_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct WaylandSurface { pub struct WaylandSurface {
handle: vk::Instance, handle: vk::Instance,
wayland_surface_fn: vk::KhrWaylandSurfaceFn, fp: vk::KhrWaylandSurfaceFn,
} }
impl WaylandSurface { impl WaylandSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::KhrWaylandSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::KhrWaylandSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
wayland_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrWaylandSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWaylandSurfaceKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWaylandSurfaceKHR.html>"]
@ -33,7 +27,7 @@ impl WaylandSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.wayland_surface_fn self.fp
.create_wayland_surface_khr( .create_wayland_surface_khr(
self.handle, self.handle,
create_info, create_info,
@ -51,7 +45,7 @@ impl WaylandSurface {
wl_display: &mut vk::wl_display, wl_display: &mut vk::wl_display,
) -> bool { ) -> bool {
let b = self let b = self
.wayland_surface_fn .fp
.get_physical_device_wayland_presentation_support_khr( .get_physical_device_wayland_presentation_support_khr(
physical_device, physical_device,
queue_family_index, queue_family_index,
@ -61,8 +55,12 @@ impl WaylandSurface {
b > 0 b > 0
} }
pub fn name() -> &'static CStr {
vk::KhrWaylandSurfaceFn::name()
}
pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn { pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn {
&self.wayland_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct Win32Surface { pub struct Win32Surface {
handle: vk::Instance, handle: vk::Instance,
win32_surface_fn: vk::KhrWin32SurfaceFn, fp: vk::KhrWin32SurfaceFn,
} }
impl Win32Surface { impl Win32Surface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::KhrWin32SurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
win32_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrWin32SurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWin32SurfaceKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWin32SurfaceKHR.html>"]
@ -33,7 +27,7 @@ impl Win32Surface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.win32_surface_fn self.fp
.create_win32_surface_khr( .create_win32_surface_khr(
self.handle, self.handle,
create_info, create_info,
@ -49,18 +43,20 @@ impl Win32Surface {
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
queue_family_index: u32, queue_family_index: u32,
) -> bool { ) -> bool {
let b = self let b = self.fp.get_physical_device_win32_presentation_support_khr(
.win32_surface_fn physical_device,
.get_physical_device_win32_presentation_support_khr( queue_family_index,
physical_device, );
queue_family_index,
);
b > 0 b > 0
} }
pub fn name() -> &'static CStr {
vk::KhrWin32SurfaceFn::name()
}
pub fn fp(&self) -> &vk::KhrWin32SurfaceFn { pub fn fp(&self) -> &vk::KhrWin32SurfaceFn {
&self.win32_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct XcbSurface { pub struct XcbSurface {
handle: vk::Instance, handle: vk::Instance,
xcb_surface_fn: vk::KhrXcbSurfaceFn, fp: vk::KhrXcbSurfaceFn,
} }
impl XcbSurface { impl XcbSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::KhrXcbSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
xcb_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrXcbSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXcbSurfaceKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXcbSurfaceKHR.html>"]
@ -33,7 +27,7 @@ impl XcbSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.xcb_surface_fn self.fp
.create_xcb_surface_khr( .create_xcb_surface_khr(
self.handle, self.handle,
create_info, create_info,
@ -51,20 +45,22 @@ impl XcbSurface {
connection: &mut vk::xcb_connection_t, connection: &mut vk::xcb_connection_t,
visual_id: vk::xcb_visualid_t, visual_id: vk::xcb_visualid_t,
) -> bool { ) -> bool {
let b = self let b = self.fp.get_physical_device_xcb_presentation_support_khr(
.xcb_surface_fn physical_device,
.get_physical_device_xcb_presentation_support_khr( queue_family_index,
physical_device, connection,
queue_family_index, visual_id,
connection, );
visual_id,
);
b > 0 b > 0
} }
pub fn name() -> &'static CStr {
vk::KhrXcbSurfaceFn::name()
}
pub fn fp(&self) -> &vk::KhrXcbSurfaceFn { pub fn fp(&self) -> &vk::KhrXcbSurfaceFn {
&self.xcb_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct XlibSurface { pub struct XlibSurface {
handle: vk::Instance, handle: vk::Instance,
xlib_surface_fn: vk::KhrXlibSurfaceFn, fp: vk::KhrXlibSurfaceFn,
} }
impl XlibSurface { impl XlibSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::KhrXlibSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::KhrXlibSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
xlib_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrXlibSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXlibSurfaceKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXlibSurfaceKHR.html>"]
@ -33,7 +27,7 @@ impl XlibSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.xlib_surface_fn self.fp
.create_xlib_surface_khr( .create_xlib_surface_khr(
self.handle, self.handle,
create_info, create_info,
@ -51,20 +45,22 @@ impl XlibSurface {
display: &mut vk::Display, display: &mut vk::Display,
visual_id: vk::VisualID, visual_id: vk::VisualID,
) -> bool { ) -> bool {
let b = self let b = self.fp.get_physical_device_xlib_presentation_support_khr(
.xlib_surface_fn physical_device,
.get_physical_device_xlib_presentation_support_khr( queue_family_index,
physical_device, display,
queue_family_index, visual_id,
display, );
visual_id,
);
b > 0 b > 0
} }
pub fn name() -> &'static CStr {
vk::KhrXlibSurfaceFn::name()
}
pub fn fp(&self) -> &vk::KhrXlibSurfaceFn { pub fn fp(&self) -> &vk::KhrXlibSurfaceFn {
&self.xlib_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct IOSSurface { pub struct IOSSurface {
handle: vk::Instance, handle: vk::Instance,
ios_surface_fn: vk::MvkIosSurfaceFn, fp: vk::MvkIosSurfaceFn,
} }
impl IOSSurface { impl IOSSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::MvkIosSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::MvkIosSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
ios_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::MvkIosSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateIOSSurfaceMVK.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateIOSSurfaceMVK.html>"]
@ -33,7 +27,7 @@ impl IOSSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.ios_surface_fn self.fp
.create_ios_surface_mvk( .create_ios_surface_mvk(
self.handle, self.handle,
create_info, create_info,
@ -43,8 +37,12 @@ impl IOSSurface {
.result_with_success(surface) .result_with_success(surface)
} }
pub fn name() -> &'static CStr {
vk::MvkIosSurfaceFn::name()
}
pub fn fp(&self) -> &vk::MvkIosSurfaceFn { pub fn fp(&self) -> &vk::MvkIosSurfaceFn {
&self.ios_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct MacOSSurface { pub struct MacOSSurface {
handle: vk::Instance, handle: vk::Instance,
macos_surface_fn: vk::MvkMacosSurfaceFn, fp: vk::MvkMacosSurfaceFn,
} }
impl MacOSSurface { impl MacOSSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::MvkMacosSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::MvkMacosSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
macos_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::MvkMacosSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateMacOSSurfaceMVK.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateMacOSSurfaceMVK.html>"]
@ -33,7 +27,7 @@ impl MacOSSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.macos_surface_fn self.fp
.create_mac_os_surface_mvk( .create_mac_os_surface_mvk(
self.handle, self.handle,
create_info, create_info,
@ -43,8 +37,12 @@ impl MacOSSurface {
.result_with_success(surface) .result_with_success(surface)
} }
pub fn name() -> &'static CStr {
vk::MvkMacosSurfaceFn::name()
}
pub fn fp(&self) -> &vk::MvkMacosSurfaceFn { pub fn fp(&self) -> &vk::MvkMacosSurfaceFn {
&self.macos_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -8,22 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct ViSurface { pub struct ViSurface {
handle: vk::Instance, handle: vk::Instance,
vi_surface_fn: vk::NnViSurfaceFn, fp: vk::NnViSurfaceFn,
} }
impl ViSurface { impl ViSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Self { pub fn new(entry: &Entry, instance: &Instance) -> Self {
let surface_fn = vk::NnViSurfaceFn::load(|name| unsafe { let handle = instance.handle();
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) let fp = vk::NnViSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: instance.handle(),
vi_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::NnViSurfaceFn::name()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateViSurfaceNN.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateViSurfaceNN.html>"]
@ -33,7 +27,7 @@ impl ViSurface {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> { ) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed(); let mut surface = mem::zeroed();
self.vi_surface_fn self.fp
.create_vi_surface_nn( .create_vi_surface_nn(
self.handle, self.handle,
create_info, create_info,
@ -43,8 +37,12 @@ impl ViSurface {
.result_with_success(surface) .result_with_success(surface)
} }
pub fn name() -> &'static CStr {
vk::NnViSurfaceFn::name()
}
pub fn fp(&self) -> &vk::NnViSurfaceFn { pub fn fp(&self) -> &vk::NnViSurfaceFn {
&self.vi_surface_fn &self.fp
} }
pub fn instance(&self) -> vk::Instance { pub fn instance(&self) -> vk::Instance {

View file

@ -6,18 +6,15 @@ use std::os::raw::c_void;
#[derive(Clone)] #[derive(Clone)]
pub struct DeviceDiagnosticCheckpoints { pub struct DeviceDiagnosticCheckpoints {
device_diagnostic_checkpoints_fn: vk::NvDeviceDiagnosticCheckpointsFn, fp: vk::NvDeviceDiagnosticCheckpointsFn,
} }
impl DeviceDiagnosticCheckpoints { impl DeviceDiagnosticCheckpoints {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let device_diagnostic_checkpoints_fn = let fp = vk::NvDeviceDiagnosticCheckpointsFn::load(|name| unsafe {
vk::NvDeviceDiagnosticCheckpointsFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) });
}); Self { fp }
Self {
device_diagnostic_checkpoints_fn,
}
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetCheckpointNV.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetCheckpointNV.html>"]
@ -26,23 +23,25 @@ impl DeviceDiagnosticCheckpoints {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
p_checkpoint_marker: *const c_void, p_checkpoint_marker: *const c_void,
) { ) {
self.device_diagnostic_checkpoints_fn self.fp
.cmd_set_checkpoint_nv(command_buffer, p_checkpoint_marker); .cmd_set_checkpoint_nv(command_buffer, p_checkpoint_marker);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetQueueCheckpointDataNV.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetQueueCheckpointDataNV.html>"]
pub unsafe fn get_queue_checkpoint_data(&self, queue: vk::Queue) -> Vec<vk::CheckpointDataNV> { pub unsafe fn get_queue_checkpoint_data(&self, queue: vk::Queue) -> Vec<vk::CheckpointDataNV> {
let mut checkpoint_data_count: u32 = 0; let mut checkpoint_data_count: u32 = 0;
self.device_diagnostic_checkpoints_fn self.fp.get_queue_checkpoint_data_nv(
.get_queue_checkpoint_data_nv(queue, &mut checkpoint_data_count, std::ptr::null_mut()); queue,
&mut checkpoint_data_count,
std::ptr::null_mut(),
);
let mut checkpoint_data: Vec<vk::CheckpointDataNV> = let mut checkpoint_data: Vec<vk::CheckpointDataNV> =
vec![vk::CheckpointDataNV::default(); checkpoint_data_count as _]; vec![vk::CheckpointDataNV::default(); checkpoint_data_count as _];
self.device_diagnostic_checkpoints_fn self.fp.get_queue_checkpoint_data_nv(
.get_queue_checkpoint_data_nv( queue,
queue, &mut checkpoint_data_count,
&mut checkpoint_data_count, checkpoint_data.as_mut_ptr(),
checkpoint_data.as_mut_ptr(), );
);
checkpoint_data checkpoint_data
} }
@ -51,6 +50,6 @@ impl DeviceDiagnosticCheckpoints {
} }
pub fn fp(&self) -> &vk::NvDeviceDiagnosticCheckpointsFn { pub fn fp(&self) -> &vk::NvDeviceDiagnosticCheckpointsFn {
&self.device_diagnostic_checkpoints_fn &self.fp
} }
} }

View file

@ -5,15 +5,15 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct MeshShader { pub struct MeshShader {
mesh_shader_fn: vk::NvMeshShaderFn, fp: vk::NvMeshShaderFn,
} }
impl MeshShader { impl MeshShader {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let mesh_shader_fn = vk::NvMeshShaderFn::load(|name| unsafe { let fp = vk::NvMeshShaderFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
}); });
Self { mesh_shader_fn } Self { fp }
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksNV.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksNV.html>"]
@ -23,7 +23,7 @@ impl MeshShader {
task_count: u32, task_count: u32,
first_task: u32, first_task: u32,
) { ) {
self.mesh_shader_fn self.fp
.cmd_draw_mesh_tasks_nv(command_buffer, task_count, first_task); .cmd_draw_mesh_tasks_nv(command_buffer, task_count, first_task);
} }
@ -36,13 +36,8 @@ impl MeshShader {
draw_count: u32, draw_count: u32,
stride: u32, stride: u32,
) { ) {
self.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_nv( self.fp
command_buffer, .cmd_draw_mesh_tasks_indirect_nv(command_buffer, buffer, offset, draw_count, stride);
buffer,
offset,
draw_count,
stride,
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksIndirectCountNV.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksIndirectCountNV.html>"]
@ -56,7 +51,7 @@ impl MeshShader {
max_draw_count: u32, max_draw_count: u32,
stride: u32, stride: u32,
) { ) {
self.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_count_nv( self.fp.cmd_draw_mesh_tasks_indirect_count_nv(
command_buffer, command_buffer,
buffer, buffer,
offset, offset,
@ -72,6 +67,6 @@ impl MeshShader {
} }
pub fn fp(&self) -> &vk::NvMeshShaderFn { pub fn fp(&self) -> &vk::NvMeshShaderFn {
&self.mesh_shader_fn &self.fp
} }
} }

View file

@ -8,18 +8,16 @@ use std::mem;
#[derive(Clone)] #[derive(Clone)]
pub struct RayTracing { pub struct RayTracing {
handle: vk::Device, handle: vk::Device,
ray_tracing_fn: vk::NvRayTracingFn, fp: vk::NvRayTracingFn,
} }
impl RayTracing { impl RayTracing {
pub fn new(instance: &Instance, device: &Device) -> Self { pub fn new(instance: &Instance, device: &Device) -> Self {
let ray_tracing_fn = vk::NvRayTracingFn::load(|name| unsafe { let handle = device.handle();
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) let fp = vk::NvRayTracingFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
}); });
Self { Self { handle, fp }
handle: device.handle(),
ray_tracing_fn,
}
} }
pub unsafe fn get_properties( pub unsafe fn get_properties(
@ -41,7 +39,7 @@ impl RayTracing {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::AccelerationStructureNV> { ) -> VkResult<vk::AccelerationStructureNV> {
let mut accel_struct = mem::zeroed(); let mut accel_struct = mem::zeroed();
self.ray_tracing_fn self.fp
.create_acceleration_structure_nv( .create_acceleration_structure_nv(
self.handle, self.handle,
create_info, create_info,
@ -57,7 +55,7 @@ impl RayTracing {
accel_struct: vk::AccelerationStructureNV, accel_struct: vk::AccelerationStructureNV,
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) { ) {
self.ray_tracing_fn.destroy_acceleration_structure_nv( self.fp.destroy_acceleration_structure_nv(
self.handle, self.handle,
accel_struct, accel_struct,
allocation_callbacks.as_raw_ptr(), allocation_callbacks.as_raw_ptr(),
@ -70,12 +68,11 @@ impl RayTracing {
info: &vk::AccelerationStructureMemoryRequirementsInfoNV, info: &vk::AccelerationStructureMemoryRequirementsInfoNV,
) -> vk::MemoryRequirements2KHR { ) -> vk::MemoryRequirements2KHR {
let mut requirements = mem::zeroed(); let mut requirements = mem::zeroed();
self.ray_tracing_fn self.fp.get_acceleration_structure_memory_requirements_nv(
.get_acceleration_structure_memory_requirements_nv( self.handle,
self.handle, info,
info, &mut requirements,
&mut requirements, );
);
requirements requirements
} }
@ -84,7 +81,7 @@ impl RayTracing {
&self, &self,
bind_info: &[vk::BindAccelerationStructureMemoryInfoNV], bind_info: &[vk::BindAccelerationStructureMemoryInfoNV],
) -> VkResult<()> { ) -> VkResult<()> {
self.ray_tracing_fn self.fp
.bind_acceleration_structure_memory_nv( .bind_acceleration_structure_memory_nv(
self.handle, self.handle,
bind_info.len() as u32, bind_info.len() as u32,
@ -106,7 +103,7 @@ impl RayTracing {
scratch: vk::Buffer, scratch: vk::Buffer,
scratch_offset: vk::DeviceSize, scratch_offset: vk::DeviceSize,
) { ) {
self.ray_tracing_fn.cmd_build_acceleration_structure_nv( self.fp.cmd_build_acceleration_structure_nv(
command_buffer, command_buffer,
info, info,
instance_data, instance_data,
@ -127,7 +124,7 @@ impl RayTracing {
src: vk::AccelerationStructureNV, src: vk::AccelerationStructureNV,
mode: vk::CopyAccelerationStructureModeNV, mode: vk::CopyAccelerationStructureModeNV,
) { ) {
self.ray_tracing_fn self.fp
.cmd_copy_acceleration_structure_nv(command_buffer, dst, src, mode); .cmd_copy_acceleration_structure_nv(command_buffer, dst, src, mode);
} }
@ -150,7 +147,7 @@ impl RayTracing {
height: u32, height: u32,
depth: u32, depth: u32,
) { ) {
self.ray_tracing_fn.cmd_trace_rays_nv( self.fp.cmd_trace_rays_nv(
command_buffer, command_buffer,
raygen_shader_binding_table_buffer, raygen_shader_binding_table_buffer,
raygen_shader_binding_offset, raygen_shader_binding_offset,
@ -177,7 +174,7 @@ impl RayTracing {
allocation_callbacks: Option<&vk::AllocationCallbacks>, allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<Vec<vk::Pipeline>> { ) -> VkResult<Vec<vk::Pipeline>> {
let mut pipelines = vec![mem::zeroed(); create_info.len()]; let mut pipelines = vec![mem::zeroed(); create_info.len()];
self.ray_tracing_fn self.fp
.create_ray_tracing_pipelines_nv( .create_ray_tracing_pipelines_nv(
self.handle, self.handle,
pipeline_cache, pipeline_cache,
@ -197,7 +194,7 @@ impl RayTracing {
group_count: u32, group_count: u32,
data: &mut [u8], data: &mut [u8],
) -> VkResult<()> { ) -> VkResult<()> {
self.ray_tracing_fn self.fp
.get_ray_tracing_shader_group_handles_nv( .get_ray_tracing_shader_group_handles_nv(
self.handle, self.handle,
pipeline, pipeline,
@ -216,7 +213,7 @@ impl RayTracing {
) -> VkResult<u64> { ) -> VkResult<u64> {
let mut handle: u64 = 0; let mut handle: u64 = 0;
let handle_ptr: *mut u64 = &mut handle; let handle_ptr: *mut u64 = &mut handle;
self.ray_tracing_fn self.fp
.get_acceleration_structure_handle_nv( .get_acceleration_structure_handle_nv(
self.handle, self.handle,
accel_struct, accel_struct,
@ -235,20 +232,19 @@ impl RayTracing {
query_pool: vk::QueryPool, query_pool: vk::QueryPool,
first_query: u32, first_query: u32,
) { ) {
self.ray_tracing_fn self.fp.cmd_write_acceleration_structures_properties_nv(
.cmd_write_acceleration_structures_properties_nv( command_buffer,
command_buffer, structures.len() as u32,
structures.len() as u32, structures.as_ptr(),
structures.as_ptr(), query_type,
query_type, query_pool,
query_pool, first_query,
first_query, );
);
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCompileDeferredNV.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCompileDeferredNV.html>"]
pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> { pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
self.ray_tracing_fn self.fp
.compile_deferred_nv(self.handle, pipeline, shader) .compile_deferred_nv(self.handle, pipeline, shader)
.result() .result()
} }
@ -258,7 +254,7 @@ impl RayTracing {
} }
pub fn fp(&self) -> &vk::NvRayTracingFn { pub fn fp(&self) -> &vk::NvRayTracingFn {
&self.ray_tracing_fn &self.fp
} }
pub fn device(&self) -> vk::Device { pub fn device(&self) -> vk::Device {