| 1 |
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_NV_cuda_kernel_launch.html> |
| 2 |
|
| 3 |
use crate::prelude::*; |
| 4 |
use crate::vk; |
| 5 |
use crate::RawPtr; |
| 6 |
use alloc::vec::Vec; |
| 7 |
use core::mem; |
| 8 |
|
| 9 |
impl crate::nv::cuda_kernel_launch::Device { |
| 10 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateCudaModuleNV.html> |
| 11 |
#[inline] |
| 12 |
pub unsafe fn create_cuda_module( |
| 13 |
&self, |
| 14 |
create_info: &vk::CudaModuleCreateInfoNV<'_>, |
| 15 |
allocator: Option<&vk::AllocationCallbacks<'_>>, |
| 16 |
) -> VkResult<vk::CudaModuleNV> { |
| 17 |
let mut module = mem::MaybeUninit::uninit(); |
| 18 |
(self.fp.create_cuda_module_nv)( |
| 19 |
self.handle, |
| 20 |
create_info, |
| 21 |
allocator.as_raw_ptr(), |
| 22 |
module.as_mut_ptr(), |
| 23 |
) |
| 24 |
.assume_init_on_success(module) |
| 25 |
} |
| 26 |
|
| 27 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetCudaModuleCacheNV.html> |
| 28 |
#[inline] |
| 29 |
pub unsafe fn get_cuda_module_cache(&self, module: vk::CudaModuleNV) -> VkResult<Vec<u8>> { |
| 30 |
read_into_uninitialized_vector(|cache_size, cache_data: *mut u8| { |
| 31 |
(self.fp.get_cuda_module_cache_nv)(self.handle, module, cache_size, cache_data.cast()) |
| 32 |
}) |
| 33 |
} |
| 34 |
|
| 35 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateCudaFunctionNV.html> |
| 36 |
#[inline] |
| 37 |
pub unsafe fn create_cuda_function( |
| 38 |
&self, |
| 39 |
create_info: &vk::CudaFunctionCreateInfoNV<'_>, |
| 40 |
allocator: Option<&vk::AllocationCallbacks<'_>>, |
| 41 |
) -> VkResult<vk::CudaFunctionNV> { |
| 42 |
let mut function = mem::MaybeUninit::uninit(); |
| 43 |
(self.fp.create_cuda_function_nv)( |
| 44 |
self.handle, |
| 45 |
create_info, |
| 46 |
allocator.as_raw_ptr(), |
| 47 |
function.as_mut_ptr(), |
| 48 |
) |
| 49 |
.assume_init_on_success(function) |
| 50 |
} |
| 51 |
|
| 52 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyCudaModuleNV.html> |
| 53 |
#[inline] |
| 54 |
pub unsafe fn destroy_cuda_module( |
| 55 |
&self, |
| 56 |
module: vk::CudaModuleNV, |
| 57 |
allocator: Option<&vk::AllocationCallbacks<'_>>, |
| 58 |
) { |
| 59 |
(self.fp.destroy_cuda_module_nv)(self.handle, module, allocator.as_raw_ptr()) |
| 60 |
} |
| 61 |
|
| 62 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyCudaFunctionNV.html> |
| 63 |
#[inline] |
| 64 |
pub unsafe fn destroy_cuda_function( |
| 65 |
&self, |
| 66 |
function: vk::CudaFunctionNV, |
| 67 |
allocator: Option<&vk::AllocationCallbacks<'_>>, |
| 68 |
) { |
| 69 |
(self.fp.destroy_cuda_function_nv)(self.handle, function, allocator.as_raw_ptr()) |
| 70 |
} |
| 71 |
|
| 72 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdCudaLaunchKernelNV.html> |
| 73 |
#[inline] |
| 74 |
pub unsafe fn cmd_cuda_launch_kernel( |
| 75 |
&self, |
| 76 |
command_buffer: vk::CommandBuffer, |
| 77 |
launch_info: &vk::CudaLaunchInfoNV<'_>, |
| 78 |
) { |
| 79 |
(self.fp.cmd_cuda_launch_kernel_nv)(command_buffer, launch_info) |
| 80 |
} |
| 81 |
} |