bedrock/
vkfn_wrapper.rs

1use ffi_helper::opt_pointer;
2
3use crate::*;
4use core::mem::MaybeUninit;
5
6#[inline]
7pub unsafe fn get_physical_device_features(
8    physical_device: VkPhysicalDevice,
9    sink: &mut MaybeUninit<PhysicalDeviceFeatures>,
10) {
11    unsafe { crate::vkfn::get_physical_device_features(physical_device, sink.as_mut_ptr()) }
12}
13
14#[inline]
15pub unsafe fn get_physical_device_properties(
16    physical_device: VkPhysicalDevice,
17    sink: &mut MaybeUninit<PhysicalDeviceProperties>,
18) {
19    unsafe { crate::vkfn::get_physical_device_properties(physical_device, sink.as_mut_ptr()) }
20}
21
22#[inline]
23pub unsafe fn get_physical_device_memory_properties(
24    physical_device: VkPhysicalDevice,
25    sink: &mut MaybeUninit<PhysicalDeviceMemoryProperties>,
26) {
27    unsafe { crate::vkfn::get_physical_device_memory_properties(physical_device, sink.as_mut_ptr()) }
28}
29
30#[cfg(feature = "VK_KHR_xlib_surface")]
31#[inline]
32pub unsafe fn get_physical_device_xlib_presentation_support(
33    physical_device: VkPhysicalDevice,
34    queue_family_index: u32,
35    dpy: *mut x11::xlib::Display,
36    visual_id: x11::xlib::VisualID,
37) -> bool {
38    unsafe {
39        crate::vkfn::get_physical_device_xlib_presentation_support_khr(
40            physical_device,
41            queue_family_index,
42            dpy,
43            visual_id,
44        ) == VK_TRUE
45    }
46}
47
48#[cfg(feature = "VK_KHR_xcb_surface")]
49pub unsafe fn get_physical_device_xcb_presentation_support(
50    physical_device: VkPhysicalDevice,
51    queue_family_index: u32,
52    connection: *mut xcb::ffi::xcb_connection_t,
53    visual_id: xcb::x::Visualid,
54) -> bool {
55    unsafe {
56        crate::vkfn::get_physical_device_xcb_presentation_support_khr(
57            physical_device,
58            queue_family_index,
59            connection,
60            visual_id,
61        ) == VK_TRUE
62    }
63}
64
65#[cfg(feature = "VK_KHR_wayland_surface")]
66#[inline]
67pub unsafe fn get_physical_device_wayland_presentation_support(
68    physical_device: VkPhysicalDevice,
69    queue_family_index: u32,
70    display: *mut core::ffi::c_void,
71) -> bool {
72    unsafe {
73        crate::vkfn::get_physical_device_wayland_presentation_support_khr(physical_device, queue_family_index, display)
74            == VK_TRUE
75    }
76}
77
78#[cfg(feature = "VK_KHR_win32_surface")]
79pub unsafe fn get_physical_device_win32_presentation_support(
80    physical_device: VkPhysicalDevice,
81    queue_family_index: u32,
82) -> bool {
83    unsafe {
84        crate::vkfn::get_physical_device_win32_presentation_support_khr(physical_device, queue_family_index) == VK_TRUE
85    }
86}
87
88#[cfg(feature = "VK_KHR_surface")]
89#[inline]
90pub unsafe fn get_physical_device_surface_support(
91    physical_device: VkPhysicalDevice,
92    queue_family_index: u32,
93    surface: VkSurfaceKHR,
94) -> crate::Result<bool> {
95    let mut sink = MaybeUninit::uninit();
96    unsafe {
97        crate::vkfn::get_physical_device_surface_support_khr(
98            physical_device,
99            queue_family_index,
100            surface,
101            sink.as_mut_ptr(),
102        )
103        .into_result()?;
104    }
105
106    Ok(unsafe { sink.assume_init() == VK_TRUE })
107}
108
109#[cfg(feature = "VK_KHR_surface")]
110#[inline]
111pub unsafe fn get_physical_device_surface_capabilities(
112    physical_device: VkPhysicalDevice,
113    surface: VkSurfaceKHR,
114    sink: &mut MaybeUninit<SurfaceCapabilities>,
115) -> crate::Result<()> {
116    unsafe {
117        crate::vkfn::get_physical_device_surface_capabilities_khr(physical_device, surface, sink.as_mut_ptr())
118            .into_result()
119            .map(drop)
120    }
121}
122
123#[cfg(feature = "VK_KHR_surface")]
124#[inline]
125pub unsafe fn get_physical_device_surface_format_count(
126    physical_device: VkPhysicalDevice,
127    surface: VkSurfaceKHR,
128) -> crate::Result<u32> {
129    let mut v = MaybeUninit::uninit();
130    unsafe {
131        crate::vkfn::get_physical_device_surface_formats_khr(
132            physical_device,
133            surface,
134            v.as_mut_ptr(),
135            core::ptr::null_mut(),
136        )
137        .into_result()?;
138    }
139
140    Ok(unsafe { v.assume_init() })
141}
142
143#[cfg(feature = "VK_KHR_surface")]
144#[inline]
145pub unsafe fn get_physical_device_surface_formats(
146    physical_device: VkPhysicalDevice,
147    surface: VkSurfaceKHR,
148    sink: &mut [MaybeUninit<SurfaceFormat>],
149) -> crate::Result<(u32, VkResult)> {
150    let mut v = sink.len() as _;
151    let r = unsafe {
152        crate::vkfn::get_physical_device_surface_formats_khr(physical_device, surface, &mut v, sink.as_mut_ptr() as _)
153            .into_result()?
154    };
155
156    Ok((v, r))
157}
158
159#[cfg(feature = "VK_KHR_surface")]
160#[inline]
161pub unsafe fn get_physical_device_surface_present_mode_count(
162    physical_device: VkPhysicalDevice,
163    surface: VkSurfaceKHR,
164) -> crate::Result<u32> {
165    let mut v = MaybeUninit::uninit();
166    unsafe {
167        crate::vkfn::get_physical_device_surface_present_modes_khr(
168            physical_device,
169            surface,
170            v.as_mut_ptr(),
171            core::ptr::null_mut(),
172        )
173        .into_result()?;
174    }
175
176    Ok(unsafe { v.assume_init() })
177}
178
179#[cfg(feature = "VK_KHR_surface")]
180#[inline]
181pub unsafe fn get_physical_device_surface_present_modes(
182    physical_device: VkPhysicalDevice,
183    surface: VkSurfaceKHR,
184    sink: &mut [MaybeUninit<PresentMode>],
185) -> crate::Result<(u32, VkResult)> {
186    let mut v = sink.len() as _;
187    let r = unsafe {
188        crate::vkfn::get_physical_device_surface_present_modes_khr(
189            physical_device,
190            surface,
191            &mut v,
192            sink.as_mut_ptr() as _,
193        )
194        .into_result()?
195    };
196
197    Ok((v, r))
198}
199
200#[cfg(feature = "VK_KHR_display")]
201#[inline]
202pub unsafe fn get_physical_device_display_property_count(physical_device: VkPhysicalDevice) -> crate::Result<u32> {
203    let mut count = MaybeUninit::uninit();
204    unsafe {
205        crate::vkfn::get_physical_device_display_properties_khr(
206            physical_device,
207            count.as_mut_ptr(),
208            core::ptr::null_mut(),
209        )
210        .into_result()?;
211    }
212
213    Ok(unsafe { count.assume_init() })
214}
215
216#[cfg(feature = "VK_KHR_display")]
217#[inline]
218pub unsafe fn get_physical_device_display_properties(
219    physical_device: VkPhysicalDevice,
220    sink: &mut [MaybeUninit<DisplayProperties>],
221) -> crate::Result<(u32, VkResult)> {
222    let mut v = sink.len() as _;
223    let r = unsafe {
224        crate::vkfn::get_physical_device_display_properties_khr(physical_device, &mut v, sink.as_mut_ptr() as _)
225            .into_result()?
226    };
227
228    Ok((v, r))
229}
230
231#[cfg(feature = "VK_KHR_display")]
232#[inline]
233pub unsafe fn get_physical_device_display_plane_property_count(
234    physical_device: VkPhysicalDevice,
235) -> crate::Result<u32> {
236    let mut count = MaybeUninit::uninit();
237    unsafe {
238        crate::vkfn::get_physical_device_display_plane_properties_khr(
239            physical_device,
240            count.as_mut_ptr(),
241            core::ptr::null_mut(),
242        )
243        .into_result()?;
244    }
245
246    Ok(unsafe { count.assume_init() })
247}
248
249#[cfg(feature = "VK_KHR_display")]
250#[inline]
251pub unsafe fn get_physical_device_display_plane_properties(
252    physical_device: VkPhysicalDevice,
253    sink: &mut [MaybeUninit<DisplayPlaneProperties>],
254) -> crate::Result<(u32, VkResult)> {
255    let mut v = sink.len() as _;
256    let r = unsafe {
257        crate::vkfn::get_physical_device_display_plane_properties_khr(physical_device, &mut v, sink.as_mut_ptr() as _)
258            .into_result()?
259    };
260
261    Ok((v, r))
262}
263
264#[cfg(feature = "VK_KHR_display")]
265#[inline]
266pub unsafe fn get_display_mode_property_count(
267    physical_device: VkPhysicalDevice,
268    display: VkDisplayKHR,
269) -> crate::Result<u32> {
270    let mut count = MaybeUninit::uninit();
271    unsafe {
272        crate::vkfn::get_display_mode_properties_khr(
273            physical_device,
274            display,
275            count.as_mut_ptr(),
276            core::ptr::null_mut(),
277        )
278        .into_result()?;
279    }
280
281    Ok(unsafe { count.assume_init() })
282}
283
284#[cfg(feature = "VK_KHR_display")]
285#[inline]
286pub unsafe fn get_display_mode_properties(
287    physical_device: VkPhysicalDevice,
288    display: VkDisplayKHR,
289    sink: &mut [MaybeUninit<DisplayModeProperties>],
290) -> crate::Result<(u32, VkResult)> {
291    let mut v = sink.len() as _;
292    let r = unsafe {
293        crate::vkfn::get_display_mode_properties_khr(physical_device, display, &mut v, sink.as_mut_ptr() as _)
294            .into_result()?
295    };
296
297    Ok((v, r))
298}
299
300#[cfg(feature = "VK_KHR_display")]
301#[inline]
302pub unsafe fn get_display_plane_capabilities(
303    physical_device: VkPhysicalDevice,
304    mode: VkDisplayModeKHR,
305    plane_index: u32,
306    sink: &mut MaybeUninit<VkDisplayPlaneCapabilitiesKHR>,
307) -> crate::Result<()> {
308    unsafe {
309        crate::vkfn::get_display_plane_capabilities_khr(physical_device, mode, plane_index, sink.as_mut_ptr())
310            .into_result()
311            .map(drop)
312    }
313}
314
315#[cfg(feature = "VK_KHR_display")]
316#[inline]
317pub unsafe fn get_display_plane_supported_display_count(
318    physical_device: VkPhysicalDevice,
319    plane_index: u32,
320) -> crate::Result<u32> {
321    let mut count = MaybeUninit::uninit();
322    unsafe {
323        crate::vkfn::get_display_plane_supported_displays_khr(
324            physical_device,
325            plane_index,
326            count.as_mut_ptr(),
327            core::ptr::null_mut(),
328        )
329        .into_result()?;
330    }
331
332    Ok(unsafe { count.assume_init() })
333}
334
335#[cfg(feature = "VK_KHR_display")]
336#[inline]
337pub unsafe fn get_display_plane_supported_displays(
338    physical_device: VkPhysicalDevice,
339    plane_index: u32,
340    sink: &mut [MaybeUninit<VkDisplayKHR>],
341) -> crate::Result<(u32, VkResult)> {
342    let mut v = sink.len() as _;
343    let r = unsafe {
344        crate::vkfn::get_display_plane_supported_displays_khr(
345            physical_device,
346            plane_index,
347            &mut v,
348            sink.as_mut_ptr() as _,
349        )
350        .into_result()?
351    };
352
353    Ok((v, r))
354}
355
356#[cfg(feature = "VK_KHR_surface")]
357#[inline]
358pub unsafe fn destroy_surface(
359    instance: VkInstance,
360    surface: VkSurfaceKHR,
361    allocation_callbacks: Option<&VkAllocationCallbacks>,
362) {
363    unsafe { crate::vkfn::destroy_surface_khr(instance, surface, opt_pointer(allocation_callbacks)) }
364}
365
366#[cfg(feature = "VK_KHR_swapchain")]
367#[inline]
368pub unsafe fn create_swapchain(
369    device: VkDevice,
370    create_info: &SwapchainCreateInfo,
371    allocation_callbacks: Option<&VkAllocationCallbacks>,
372) -> crate::Result<VkSwapchainKHR> {
373    let mut h = MaybeUninit::uninit();
374    unsafe {
375        crate::vkfn::create_swapchain_khr(
376            device,
377            create_info as *const _ as _,
378            opt_pointer(allocation_callbacks),
379            h.as_mut_ptr(),
380        )
381        .into_result()?;
382    }
383
384    Ok(unsafe { h.assume_init() })
385}
386
387#[cfg(feature = "VK_KHR_swapchain")]
388#[inline]
389pub unsafe fn destroy_swapchain(
390    device: VkDevice,
391    swapchain: VkSwapchainKHR,
392    allocation_callbacks: Option<&VkAllocationCallbacks>,
393) {
394    unsafe { crate::vkfn::destroy_swapchain_khr(device, swapchain, opt_pointer(allocation_callbacks)) }
395}
396
397#[cfg(feature = "VK_KHR_swapchain")]
398#[inline]
399pub unsafe fn get_swapchain_image_count(device: VkDevice, swapchain: VkSwapchainKHR) -> crate::Result<u32> {
400    let mut v = MaybeUninit::uninit();
401    unsafe {
402        crate::vkfn::get_swapchain_images_khr(device, swapchain, v.as_mut_ptr(), core::ptr::null_mut())
403            .into_result()?;
404    }
405
406    Ok(unsafe { v.assume_init() })
407}
408
409#[cfg(feature = "VK_KHR_swapchain")]
410#[inline]
411pub unsafe fn get_swapchain_images(
412    device: VkDevice,
413    swapchain: VkSwapchainKHR,
414    sink: &mut [MaybeUninit<VkImage>],
415) -> crate::Result<(u32, VkResult)> {
416    let mut v = sink.len() as _;
417    let r = unsafe {
418        crate::vkfn::get_swapchain_images_khr(device, swapchain, &mut v, sink.as_mut_ptr() as _).into_result()?
419    };
420
421    Ok((v, r))
422}
423
424#[cfg(feature = "VK_KHR_swapchain")]
425#[inline]
426pub unsafe fn acquire_next_image(
427    device: VkDevice,
428    mut swapchain: VkHandleRefMut<VkSwapchainKHR>,
429    timeout: u64,
430    mut semaphore: Option<VkHandleRefMut<VkSemaphore>>,
431    mut fence: Option<VkHandleRefMut<VkFence>>,
432) -> crate::Result<u32> {
433    let mut v = MaybeUninit::uninit();
434    unsafe {
435        crate::vkfn::acquire_next_image_khr(
436            device,
437            swapchain.native_ptr_mut(),
438            timeout,
439            semaphore
440                .as_mut()
441                .map_or(VkSemaphore::NULL, VkHandleRefMut::native_ptr_mut),
442            fence.as_mut().map_or(VkFence::NULL, VkHandleRefMut::native_ptr_mut),
443            v.as_mut_ptr(),
444        )
445        .into_result()?;
446    }
447
448    Ok(unsafe { v.assume_init() })
449}
450
451#[inline]
452pub unsafe fn get_device_queue(device: VkDevice, family_index: u32, index: u32) -> VkQueue {
453    let mut h = MaybeUninit::uninit();
454    unsafe {
455        crate::vkfn::get_device_queue(device, family_index, index, h.as_mut_ptr());
456    }
457
458    unsafe { h.assume_init() }
459}
460
461#[inline]
462pub unsafe fn queue_wait_idle(queue: VkQueue) -> crate::Result<()> {
463    unsafe { crate::vkfn::queue_wait_idle(queue).into_result().map(drop) }
464}
465
466#[inline]
467pub unsafe fn device_wait_idle(device: VkDevice) -> crate::Result<()> {
468    unsafe { crate::vkfn::device_wait_idle(device).into_result().map(drop) }
469}
470
471#[inline]
472pub unsafe fn get_instance_proc_addr_pfn<F: crate::PFN>(
473    instance: &(impl VkHandle<Handle = VkInstance> + ?Sized),
474) -> Option<F> {
475    unsafe { crate::vkfn::get_instance_proc_addr(instance.native_ptr(), F::NAME_CSTR.as_ptr()) }
476        .map(|x| unsafe { F::from_void_fn(x) })
477}
478
479#[inline]
480pub unsafe fn get_device_proc_addr_pfn<F: crate::PFN>(
481    device: &(impl VkHandle<Handle = VkDevice> + ?Sized),
482) -> Option<F> {
483    unsafe { crate::vkfn::get_device_proc_addr(device.native_ptr(), F::NAME_CSTR.as_ptr()) }
484        .map(|x| unsafe { F::from_void_fn(x) })
485}
486
487#[inline]
488pub unsafe fn queue_submit(
489    mut queue: VkHandleRefMut<VkQueue>,
490    submit_info: &[SubmitInfo],
491    mut fence: Option<VkHandleRefMut<VkFence>>,
492) -> crate::Result<()> {
493    unsafe {
494        crate::vkfn::queue_submit(
495            queue.native_ptr_mut(),
496            submit_info.len() as _,
497            submit_info.as_ptr() as _,
498            fence.as_mut().map_or(VkFence::NULL, VkHandleRefMut::native_ptr_mut),
499        )
500        .into_result()
501        .map(drop)
502    }
503}
504
505#[cfg(feature = "Allow1_3APIs")]
506#[inline]
507pub unsafe fn queue_submit2(
508    mut queue: VkHandleRefMut<VkQueue>,
509    submit_info: &[SubmitInfo2],
510    mut fence: Option<VkHandleRefMut<VkFence>>,
511) -> crate::Result<()> {
512    unsafe {
513        crate::vkfn::queue_submit2(
514            queue.native_ptr_mut(),
515            submit_info.len() as _,
516            submit_info.as_ptr() as _,
517            fence.as_mut().map_or(VkFence::NULL, VkHandleRefMut::native_ptr_mut),
518        )
519        .into_result()
520        .map(drop)
521    }
522}
523
524#[cfg(feature = "VK_KHR_swapchain")]
525#[inline]
526pub unsafe fn queue_present(queue: VkQueue, present_info: &PresentInfo) -> crate::Result<VkResult> {
527    unsafe { crate::vkfn::queue_present_khr(queue, present_info as *const _ as _).into_result() }
528}
529
530#[inline]
531pub unsafe fn queue_bind_sparse(
532    mut queue: VkHandleRefMut<VkQueue>,
533    infos: &[VkBindSparseInfo],
534    mut fence: Option<VkHandleRefMut<VkFence>>,
535) -> crate::Result<()> {
536    unsafe {
537        crate::vkfn::queue_bind_sparse(
538            queue.native_ptr_mut(),
539            infos.len() as _,
540            infos.as_ptr(),
541            fence.as_mut().map_or(VkFence::NULL, VkHandleRefMut::native_ptr_mut),
542        )
543        .into_result()
544        .map(drop)
545    }
546}
547
548#[inline]
549pub unsafe fn create_command_pool(
550    device: VkDevice,
551    create_info: &CommandPoolCreateInfo,
552    allocation_callbacks: Option<&VkAllocationCallbacks>,
553) -> crate::Result<VkCommandPool> {
554    let mut h = MaybeUninit::uninit();
555    unsafe {
556        crate::vkfn::create_command_pool(
557            device,
558            create_info as *const _ as _,
559            opt_pointer(allocation_callbacks),
560            h.as_mut_ptr(),
561        )
562        .into_result()?;
563    }
564
565    Ok(unsafe { h.assume_init() })
566}
567
568#[inline]
569pub unsafe fn destroy_command_pool(
570    device: VkDevice,
571    command_pool: VkCommandPool,
572    allocation_callbacks: Option<&VkAllocationCallbacks>,
573) {
574    unsafe { crate::vkfn::destroy_command_pool(device, command_pool, opt_pointer(allocation_callbacks)) }
575}
576
577#[inline]
578pub unsafe fn allocate_command_buffers(
579    device: VkDevice,
580    allocation_info: &CommandBufferAllocateInfo,
581    sink: &mut [MaybeUninit<VkCommandBuffer>],
582) -> crate::Result<()> {
583    unsafe {
584        crate::vkfn::allocate_command_buffers(device, allocation_info as *const _ as _, sink.as_mut_ptr() as _)
585            .into_result()
586            .map(drop)
587    }
588}
589
590#[inline]
591pub unsafe fn free_command_buffers(device: VkDevice, command_pool: VkCommandPool, buffers: &[VkCommandBuffer]) {
592    unsafe { crate::vkfn::free_command_buffers(device, command_pool, buffers.len() as _, buffers.as_ptr()) }
593}
594
595#[inline]
596pub unsafe fn reset_command_pool(
597    device: VkDevice,
598    command_pool: VkCommandPool,
599    flags: CommandPoolResetFlags,
600) -> crate::Result<()> {
601    unsafe {
602        crate::vkfn::reset_command_pool(device, command_pool, flags.bits())
603            .into_result()
604            .map(drop)
605    }
606}
607
608#[inline]
609pub unsafe fn begin_command_buffer(
610    command_buffer: VkCommandBuffer,
611    begin_info: &CommandBufferBeginInfo,
612) -> crate::Result<()> {
613    unsafe {
614        crate::vkfn::begin_command_buffer(command_buffer, begin_info as *const _ as _)
615            .into_result()
616            .map(drop)
617    }
618}
619
620#[inline]
621pub unsafe fn end_command_buffer(command_buffer: VkCommandBuffer) -> crate::Result<()> {
622    unsafe { crate::vkfn::end_command_buffer(command_buffer).into_result().map(drop) }
623}
624
625#[inline]
626pub unsafe fn create_fence(
627    device: VkDevice,
628    info: &FenceCreateInfo,
629    allocation_callbacks: Option<&VkAllocationCallbacks>,
630) -> crate::Result<VkFence> {
631    let mut h = MaybeUninit::uninit();
632    unsafe {
633        crate::vkfn::create_fence(
634            device,
635            info as *const _ as _,
636            opt_pointer(allocation_callbacks),
637            h.as_mut_ptr(),
638        )
639        .into_result()?;
640    }
641
642    Ok(unsafe { h.assume_init() })
643}
644
645#[inline]
646pub unsafe fn destroy_fence(device: VkDevice, fence: VkFence, allocation_callbacks: Option<&VkAllocationCallbacks>) {
647    unsafe { crate::vkfn::destroy_fence(device, fence, opt_pointer(allocation_callbacks)) }
648}
649
650#[inline]
651pub unsafe fn wait_for_fences(
652    device: VkDevice,
653    fences: &[VkFence],
654    wait_all: bool,
655    timeout: u64,
656) -> crate::Result<VkResult> {
657    unsafe {
658        crate::vkfn::wait_for_fences(device, fences.len() as _, fences.as_ptr(), wait_all as _, timeout).into_result()
659    }
660}
661
662#[inline]
663pub unsafe fn reset_fences(device: VkDevice, fences: &[VkHandleRefMut<VkFence>]) -> crate::Result<()> {
664    unsafe {
665        crate::vkfn::reset_fences(device, fences.len() as _, fences.as_ptr() as _)
666            .into_result()
667            .map(drop)
668    }
669}
670
671#[inline]
672pub unsafe fn get_fence_status(device: VkDevice, fence: VkFence) -> crate::Result<VkResult> {
673    unsafe { crate::vkfn::get_fence_status(device, fence).into_result() }
674}
675
676#[inline]
677pub unsafe fn create_semaphore(
678    device: VkDevice,
679    create_info: &SemaphoreCreateInfo,
680    allocation_callbacks: Option<&VkAllocationCallbacks>,
681) -> crate::Result<VkSemaphore> {
682    let mut h = MaybeUninit::uninit();
683    unsafe {
684        crate::vkfn::create_semaphore(
685            device,
686            create_info as *const _ as _,
687            opt_pointer(allocation_callbacks),
688            h.as_mut_ptr(),
689        )
690        .into_result()?;
691    }
692
693    Ok(unsafe { h.assume_init() })
694}
695
696#[inline]
697pub unsafe fn destroy_semaphore(
698    device: VkDevice,
699    semaphore: VkSemaphore,
700    allocation_callbacks: Option<&VkAllocationCallbacks>,
701) {
702    unsafe { crate::vkfn::destroy_semaphore(device, semaphore, opt_pointer(allocation_callbacks)) }
703}
704
705#[inline]
706pub unsafe fn create_buffer(
707    device: VkDevice,
708    create_info: &BufferCreateInfo,
709    allocation_callbacks: Option<&VkAllocationCallbacks>,
710) -> crate::Result<VkBuffer> {
711    let mut h = MaybeUninit::uninit();
712    unsafe {
713        crate::vkfn::create_buffer(
714            device,
715            create_info as *const _ as _,
716            opt_pointer(allocation_callbacks),
717            h.as_mut_ptr(),
718        )
719        .into_result()?;
720    }
721
722    Ok(unsafe { h.assume_init() })
723}
724
725#[inline]
726pub unsafe fn destroy_buffer(device: VkDevice, buffer: VkBuffer, allocation_callbacks: Option<&VkAllocationCallbacks>) {
727    unsafe { crate::vkfn::destroy_buffer(device, buffer, opt_pointer(allocation_callbacks)) }
728}
729
730#[inline]
731pub unsafe fn get_buffer_memory_requirements(device: VkDevice, buffer: VkBuffer) -> VkMemoryRequirements {
732    let mut sink = MaybeUninit::uninit();
733    unsafe {
734        crate::vkfn::get_buffer_memory_requirements(device, buffer, sink.as_mut_ptr());
735
736        sink.assume_init()
737    }
738}
739
740#[cfg(feature = "Allow1_1APIs")]
741#[inline]
742pub unsafe fn get_buffer_memory_requirements2(
743    device: VkDevice,
744    info: &BufferMemoryRequirementsInfo2<'_, impl VkHandle<Handle = VkBuffer>>,
745    sink: &mut MaybeUninit<VkMemoryRequirements2>,
746) {
747    unsafe { crate::vkfn::get_buffer_memory_requirements2(device, info.as_ref() as *const _, sink.as_mut_ptr()) }
748}
749
750#[inline]
751pub unsafe fn bind_buffer_memory(
752    device: VkDevice,
753    buffer: VkBuffer,
754    memory: VkDeviceMemory,
755    offset: DeviceSize,
756) -> crate::Result<()> {
757    unsafe {
758        crate::vkfn::bind_buffer_memory(device, buffer, memory, offset)
759            .into_result()
760            .map(drop)
761    }
762}
763
764#[cfg(feature = "Allow1_1APIs")]
765#[inline]
766pub unsafe fn bind_buffer_memory2(device: VkDevice, bind_infos: &[BindBufferMemoryInfo]) -> crate::Result<()> {
767    unsafe {
768        crate::vkfn::bind_buffer_memory2(device, bind_infos.len() as _, bind_infos.as_ptr() as _)
769            .into_result()
770            .map(drop)
771    }
772}
773
774#[inline]
775pub unsafe fn create_image(
776    device: VkDevice,
777    create_info: &ImageCreateInfo,
778    allocation_callbacks: Option<&VkAllocationCallbacks>,
779) -> crate::Result<VkImage> {
780    let mut h = MaybeUninit::uninit();
781    unsafe {
782        crate::vkfn::create_image(
783            device,
784            create_info as *const _ as _,
785            opt_pointer(allocation_callbacks),
786            h.as_mut_ptr(),
787        )
788        .into_result()?;
789    }
790
791    Ok(unsafe { h.assume_init() })
792}
793
794#[inline]
795pub unsafe fn destroy_image(device: VkDevice, image: VkImage, allocation_callbacks: Option<&VkAllocationCallbacks>) {
796    unsafe { crate::vkfn::destroy_image(device, image, opt_pointer(allocation_callbacks)) }
797}
798
799#[inline]
800pub unsafe fn get_image_memory_requirements(device: VkDevice, image: VkImage) -> VkMemoryRequirements {
801    let mut sink = MaybeUninit::uninit();
802    unsafe {
803        crate::vkfn::get_image_memory_requirements(device, image, sink.as_mut_ptr());
804
805        sink.assume_init()
806    }
807}
808
809#[cfg(feature = "Allow1_1APIs")]
810#[inline]
811pub unsafe fn get_image_memory_requirements2(
812    device: VkDevice,
813    info: &ImageMemoryRequirementsInfo2<'_, impl VkHandle<Handle = VkImage>>,
814    sink: &mut MaybeUninit<VkMemoryRequirements2>,
815) {
816    unsafe { crate::vkfn::get_image_memory_requirements2(device, info.as_ref() as *const _, sink.as_mut_ptr()) }
817}
818
819#[inline]
820pub unsafe fn bind_image_memory(
821    device: VkDevice,
822    image: VkImage,
823    memory: VkDeviceMemory,
824    offset: DeviceSize,
825) -> crate::Result<()> {
826    unsafe {
827        crate::vkfn::bind_image_memory(device, image, memory, offset)
828            .into_result()
829            .map(drop)
830    }
831}
832
833#[cfg(feature = "Allow1_1APIs")]
834#[inline]
835pub unsafe fn bind_image_memory2(device: VkDevice, bind_infos: &[BindImageMemoryInfo]) -> crate::Result<()> {
836    unsafe {
837        crate::vkfn::bind_image_memory2(device, bind_infos.len() as _, bind_infos.as_ptr() as _)
838            .into_result()
839            .map(drop)
840    }
841}
842
843#[inline]
844pub unsafe fn create_sampler(
845    device: VkDevice,
846    create_info: &SamplerCreateInfo,
847    allocation_callbacks: Option<&VkAllocationCallbacks>,
848) -> crate::Result<VkSampler> {
849    let mut h = MaybeUninit::uninit();
850    unsafe {
851        crate::vkfn::create_sampler(
852            device,
853            create_info as *const _ as _,
854            opt_pointer(allocation_callbacks),
855            h.as_mut_ptr(),
856        )
857        .into_result()?;
858    }
859
860    Ok(unsafe { h.assume_init() })
861}
862
863#[inline]
864pub unsafe fn destroy_sampler(
865    device: VkDevice,
866    sampler: VkSampler,
867    allocation_callbacks: Option<&VkAllocationCallbacks>,
868) {
869    unsafe { crate::vkfn::destroy_sampler(device, sampler, opt_pointer(allocation_callbacks)) }
870}
871
872#[inline]
873pub unsafe fn allocate_memory(
874    device: VkDevice,
875    allocate_info: &MemoryAllocateInfo,
876    allocation_callbacks: Option<&VkAllocationCallbacks>,
877) -> crate::Result<VkDeviceMemory> {
878    let mut h = MaybeUninit::uninit();
879    unsafe {
880        crate::vkfn::allocate_memory(
881            device,
882            allocate_info as *const _ as _,
883            opt_pointer(allocation_callbacks),
884            h.as_mut_ptr(),
885        )
886        .into_result()?;
887    }
888
889    Ok(unsafe { h.assume_init() })
890}
891
892#[inline]
893pub unsafe fn free_memory(
894    device: VkDevice,
895    memory: VkDeviceMemory,
896    allocation_callbacks: Option<&VkAllocationCallbacks>,
897) {
898    unsafe { crate::vkfn::free_memory(device, memory, opt_pointer(allocation_callbacks)) }
899}
900
901#[inline]
902pub unsafe fn map_memory(
903    device: VkDevice,
904    memory: VkDeviceMemory,
905    offset: DeviceSize,
906    size: DeviceSize,
907    flags: VkMemoryMapFlags,
908) -> crate::Result<*mut core::ffi::c_void> {
909    let mut p = MaybeUninit::uninit();
910    unsafe {
911        crate::vkfn::map_memory(device, memory, offset, size, flags, p.as_mut_ptr()).into_result()?;
912    }
913
914    Ok(unsafe { p.assume_init() })
915}
916
917#[inline]
918pub unsafe fn unmap_memory(device: VkDevice, memory: VkDeviceMemory) {
919    unsafe { crate::vkfn::unmap_memory(device, memory) }
920}
921
922#[inline]
923pub unsafe fn invalidate_mapped_memory_ranges(
924    device: VkDevice,
925    memory_ranges: &[MappedMemoryRange],
926) -> crate::Result<()> {
927    unsafe {
928        crate::vkfn::invalidate_mapped_memory_ranges(device, memory_ranges.len() as _, memory_ranges.as_ptr() as _)
929            .into_result()
930            .map(drop)
931    }
932}
933
934#[inline]
935pub unsafe fn flush_mapped_memory_ranges(device: VkDevice, memory_ranges: &[MappedMemoryRange]) -> crate::Result<()> {
936    unsafe {
937        crate::vkfn::flush_mapped_memory_ranges(device, memory_ranges.len() as _, memory_ranges.as_ptr() as _)
938            .into_result()
939            .map(drop)
940    }
941}
942
943#[inline]
944pub unsafe fn create_image_view(
945    device: VkDevice,
946    create_info: &ImageViewCreateInfo,
947    allocation_callbacks: Option<&VkAllocationCallbacks>,
948) -> crate::Result<VkImageView> {
949    let mut h = MaybeUninit::uninit();
950    unsafe {
951        crate::vkfn::create_image_view(
952            device,
953            create_info as *const _ as _,
954            opt_pointer(allocation_callbacks),
955            h.as_mut_ptr(),
956        )
957        .into_result()?;
958    }
959
960    Ok(unsafe { h.assume_init() })
961}
962
963#[inline]
964pub unsafe fn destroy_image_view(
965    device: VkDevice,
966    image_view: VkImageView,
967    allocation_callbacks: Option<&VkAllocationCallbacks>,
968) {
969    unsafe { crate::vkfn::destroy_image_view(device, image_view, opt_pointer(allocation_callbacks)) }
970}
971
972#[inline]
973pub unsafe fn create_buffer_view(
974    device: VkDevice,
975    create_info: &BufferViewCreateInfo,
976    allocation_callbacks: Option<&VkAllocationCallbacks>,
977) -> crate::Result<VkBufferView> {
978    let mut h = MaybeUninit::uninit();
979    unsafe {
980        crate::vkfn::create_buffer_view(
981            device,
982            create_info as *const _ as _,
983            opt_pointer(allocation_callbacks),
984            h.as_mut_ptr(),
985        )
986        .into_result()?;
987    }
988
989    Ok(unsafe { h.assume_init() })
990}
991
992#[inline]
993pub unsafe fn destroy_buffer_view(
994    device: VkDevice,
995    buffer_view: VkBufferView,
996    allocation_callbacks: Option<&VkAllocationCallbacks>,
997) {
998    unsafe { crate::vkfn::destroy_buffer_view(device, buffer_view, opt_pointer(allocation_callbacks)) }
999}
1000
1001#[inline]
1002pub unsafe fn create_framebuffer(
1003    device: VkDevice,
1004    create_info: &FramebufferCreateInfo,
1005    allocation_callbacks: Option<&VkAllocationCallbacks>,
1006) -> crate::Result<VkFramebuffer> {
1007    let mut h = MaybeUninit::uninit();
1008    unsafe {
1009        crate::vkfn::create_framebuffer(
1010            device,
1011            create_info as *const _ as _,
1012            opt_pointer(allocation_callbacks),
1013            h.as_mut_ptr(),
1014        )
1015        .into_result()?;
1016    }
1017
1018    Ok(unsafe { h.assume_init() })
1019}
1020
1021#[inline]
1022pub unsafe fn destroy_framebuffer(
1023    device: VkDevice,
1024    framebuffer: VkFramebuffer,
1025    allocation_callbacks: Option<&VkAllocationCallbacks>,
1026) {
1027    unsafe { crate::vkfn::destroy_framebuffer(device, framebuffer, opt_pointer(allocation_callbacks)) }
1028}
1029
1030#[inline]
1031pub unsafe fn destroy_render_pass(
1032    device: VkDevice,
1033    render_pass: VkRenderPass,
1034    allocation_callbacks: Option<&VkAllocationCallbacks>,
1035) {
1036    unsafe { crate::vkfn::destroy_render_pass(device, render_pass, opt_pointer(allocation_callbacks)) }
1037}
1038
1039#[inline]
1040pub unsafe fn create_graphics_pipelines_unchecked(
1041    device: VkDevice,
1042    pipeline_cache: Option<VkPipelineCache>,
1043    create_infos: &[GraphicsPipelineCreateInfo],
1044    allocation_callbacks: Option<&VkAllocationCallbacks>,
1045    results: &mut [MaybeUninit<VkPipeline>],
1046) -> crate::Result<()> {
1047    debug_assert!(results.len() >= create_infos.len());
1048
1049    unsafe {
1050        crate::vkfn::create_graphics_pipelines(
1051            device,
1052            pipeline_cache.unwrap_or(VkPipelineCache::NULL),
1053            create_infos.len() as _,
1054            create_infos.as_ptr() as _,
1055            opt_pointer(allocation_callbacks),
1056            results.as_mut_ptr() as _,
1057        )
1058        .into_result()
1059        .map(drop)
1060    }
1061}
1062
1063#[inline]
1064pub unsafe fn create_graphics_pipeline_array<const N: usize>(
1065    device: VkDevice,
1066    pipeline_cache: Option<VkPipelineCache>,
1067    create_infos: &[GraphicsPipelineCreateInfo; N],
1068    allocation_callbacks: Option<&VkAllocationCallbacks>,
1069) -> crate::Result<[VkPipeline; N]> {
1070    let mut results = [const { unsafe { MaybeUninit::zeroed().assume_init() } }; N];
1071    unsafe {
1072        create_graphics_pipelines_unchecked(
1073            device,
1074            pipeline_cache,
1075            create_infos,
1076            allocation_callbacks,
1077            core::mem::transmute(&mut results[..]),
1078        )?;
1079    }
1080
1081    Ok(results)
1082}
1083
1084#[inline]
1085pub unsafe fn destroy_pipeline(
1086    device: VkDevice,
1087    pipeline: VkPipeline,
1088    allocation_callbacks: Option<&VkAllocationCallbacks>,
1089) {
1090    unsafe { crate::vkfn::destroy_pipeline(device, pipeline, opt_pointer(allocation_callbacks)) }
1091}
1092
1093#[inline]
1094pub unsafe fn create_pipeline_layout(
1095    device: VkDevice,
1096    create_info: &PipelineLayoutCreateInfo,
1097    allocation_callbacks: Option<&VkAllocationCallbacks>,
1098) -> crate::Result<VkPipelineLayout> {
1099    let mut h = MaybeUninit::uninit();
1100    unsafe {
1101        crate::vkfn::create_pipeline_layout(
1102            device,
1103            create_info as *const _ as _,
1104            opt_pointer(allocation_callbacks),
1105            h.as_mut_ptr(),
1106        )
1107        .into_result()?;
1108    }
1109
1110    Ok(unsafe { h.assume_init() })
1111}
1112
1113#[inline]
1114pub unsafe fn destroy_pipeline_layout(
1115    device: VkDevice,
1116    pipeline_layout: VkPipelineLayout,
1117    allocation_callbacks: Option<&VkAllocationCallbacks>,
1118) {
1119    unsafe {
1120        crate::vkfn::destroy_pipeline_layout(device, pipeline_layout, opt_pointer(allocation_callbacks));
1121    }
1122}
1123
1124#[inline]
1125pub unsafe fn get_pipeline_cache_data_byte_length(
1126    device: VkDevice,
1127    pipeline_cache: VkPipelineCache,
1128) -> crate::Result<usize> {
1129    let mut len = MaybeUninit::uninit();
1130    unsafe {
1131        crate::vkfn::get_pipeline_cache_data(device, pipeline_cache, len.as_mut_ptr(), core::ptr::null_mut())
1132            .into_result()?;
1133    }
1134
1135    Ok(unsafe { len.assume_init() })
1136}
1137
1138#[inline]
1139pub unsafe fn get_pipeline_cache_data(
1140    device: VkDevice,
1141    pipeline_cache: VkPipelineCache,
1142    sink: &mut [MaybeUninit<u8>],
1143) -> crate::Result<(usize, VkResult)> {
1144    let mut len = sink.len();
1145    let r = unsafe {
1146        crate::vkfn::get_pipeline_cache_data(device, pipeline_cache, &mut len, sink.as_mut_ptr() as _).into_result()?
1147    };
1148
1149    Ok((len, r))
1150}
1151
1152#[cfg(feature = "Allow1_2APIs")]
1153#[inline]
1154pub unsafe fn get_semaphore_counter_value(device: VkDevice, semaphore: VkSemaphore) -> crate::Result<u64> {
1155    let mut value = MaybeUninit::uninit();
1156    unsafe {
1157        crate::vkfn::get_semaphore_counter_value(device, semaphore, value.as_mut_ptr()).into_result()?;
1158    }
1159
1160    Ok(unsafe { value.assume_init() })
1161}
1162
1163#[cfg(feature = "Allow1_2APIs")]
1164#[inline]
1165pub unsafe fn signal_semaphore(device: VkDevice, signal_info: &SemaphoreSignalInfo) -> crate::Result<()> {
1166    unsafe {
1167        crate::vkfn::signal_semaphore(device, signal_info as *const _ as _)
1168            .into_result()
1169            .map(drop)
1170    }
1171}
1172
1173#[cfg(feature = "Allow1_2APIs")]
1174#[inline]
1175pub unsafe fn wait_semaphores(
1176    device: VkDevice,
1177    wait_info: &SemaphoreWaitInfo,
1178    timeout: u64,
1179) -> crate::Result<VkResult> {
1180    unsafe { crate::vkfn::wait_semaphores(device, wait_info as *const _ as _, timeout).into_result() }
1181}