use crate::prelude::*; use crate::vk; use crate::RawPtr; use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; #[derive(Clone)] pub struct DeferredHostOperations { handle: vk::Device, deferred_host_operations_fn: vk::KhrDeferredHostOperationsFn, } impl DeferredHostOperations { pub fn new(instance: &Instance, device: &Device) -> Self { let deferred_host_operations_fn = vk::KhrDeferredHostOperationsFn::load(|name| unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }); Self { handle: device.handle(), deferred_host_operations_fn, } } #[doc = ""] pub unsafe fn create_deferred_operation( &self, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult { let mut operation = mem::zeroed(); self.deferred_host_operations_fn .create_deferred_operation_khr( self.handle, allocation_callbacks.as_raw_ptr(), &mut operation, ) .result_with_success(operation) } #[doc = ""] pub unsafe fn deferred_operation_join( &self, operation: vk::DeferredOperationKHR, ) -> VkResult<()> { self.deferred_host_operations_fn .deferred_operation_join_khr(self.handle, operation) .result() } #[doc = ""] pub unsafe fn destroy_deferred_operation( &self, operation: vk::DeferredOperationKHR, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) { self.deferred_host_operations_fn .destroy_deferred_operation_khr( self.handle, operation, allocation_callbacks.as_raw_ptr(), ); } #[doc = ""] pub unsafe fn get_deferred_operation_max_concurrency( &self, operation: vk::DeferredOperationKHR, ) -> u32 { self.deferred_host_operations_fn .get_deferred_operation_max_concurrency_khr(self.handle, operation) } #[doc = ""] pub unsafe fn get_deferred_operation_result( &self, operation: vk::DeferredOperationKHR, ) -> VkResult<()> { self.deferred_host_operations_fn .get_deferred_operation_result_khr(self.handle, operation) .result() } pub fn name() -> &'static CStr { vk::KhrDeferredHostOperationsFn::name() } pub fn fp(&self) -> &vk::KhrDeferredHostOperationsFn { &self.deferred_host_operations_fn } pub fn device(&self) -> vk::Device { self.handle } }