lava/vulkan/vk/
vk_command_pool.rs

1// Generated by `scripts/generate.js`
2
3use utils::c_bindings::*;
4use utils::vk_traits::*;
5use utils::vk_ptr::*;
6use utils::vk_convert::*;
7use std::os::raw::c_char;
8use std::ops::Drop;
9use std::ptr;
10use std::mem;
11use std::cmp;
12use std::slice;
13use vulkan::*;
14use vulkan::vk::*;
15
16#[doc(hidden)]
17pub type RawVkCommandPool = u64;
18
19/// Wrapper for [VkCommandPool](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkCommandPool.html).
20#[derive(Debug, Clone, Copy)]
21pub struct VkCommandPool {
22    _handle: RawVkCommandPool,
23    _fn_table: *mut VkFunctionTable
24}
25
26impl VkRawType<VkCommandPool> for RawVkCommandPool {
27    fn vk_to_wrapped(src: &RawVkCommandPool) -> VkCommandPool {
28        VkCommandPool {
29            _handle: *src,
30            _fn_table: ptr::null_mut()
31        }
32    }
33}
34
35impl VkWrappedType<RawVkCommandPool> for VkCommandPool {
36    fn vk_to_raw(src: &VkCommandPool, dst: &mut RawVkCommandPool) {
37        *dst = src._handle
38    }
39}
40
41impl Default for VkCommandPool {
42    fn default() -> VkCommandPool {
43        VkCommandPool {
44            _handle: 0,
45            _fn_table: ptr::null_mut()
46        }
47    }
48}
49
50impl PartialEq for VkCommandPool {
51    fn eq(&self, other: &VkCommandPool) -> bool {
52        self._handle == other._handle
53    }
54}
55
56impl VkSetup for VkCommandPool {
57    fn vk_setup(&mut self, fn_table: *mut VkFunctionTable) {
58        self._fn_table = fn_table;
59    }
60}
61
62impl VkCommandPool {
63    
64    /// Returns the internal Vulkan handle for the object.
65    pub fn vk_handle(&self) -> u64 {
66        self._handle
67    }
68    
69    /// Indicates if the Vulkan internal handle for this object is 0.
70    pub fn is_null(&self) -> bool {
71        self._handle == 0
72    }
73    
74    /// Creates an object with a null Vulkan internal handle.
75    ///
76    /// Calling a method with a null handle will most likely result in a crash.
77    pub fn null() -> Self {
78        Self {
79            _handle: 0,
80            _fn_table: ptr::null_mut()
81        }
82    }
83    
84    /// Wrapper for [vkDestroyCommandPool](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyCommandPool.html).
85    pub fn destroy(&self) {
86        unsafe {
87            ((&*self._fn_table).vkDestroyCommandPool)((*self._fn_table).device, self._handle, ptr::null());
88        }
89    }
90    
91    /// Wrapper for [vkResetCommandPool](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetCommandPool.html).
92    pub fn reset(&self, flags: VkCommandPoolResetFlags) -> LavaResult<()> {
93        unsafe {
94            let raw_flags = vk_to_raw_value(&flags);
95            let vk_result = ((&*self._fn_table).vkResetCommandPool)((*self._fn_table).device, self._handle, raw_flags);
96            if vk_result == 0 { Ok(()) } else { Err((RawVkResult::vk_to_wrapped(&vk_result), ())) }
97        }
98    }
99    
100    /// Wrapper for [vkFreeCommandBuffers](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkFreeCommandBuffers.html).
101    pub fn free_command_buffers(&self, command_buffers: Vec<VkCommandBuffer>) {
102        unsafe {
103            let raw_command_buffer_count = command_buffers.len() as u32;
104            let raw_command_buffers = new_ptr_vk_array(&command_buffers);
105            ((&*self._fn_table).vkFreeCommandBuffers)((*self._fn_table).device, self._handle, raw_command_buffer_count, raw_command_buffers);
106            free_ptr(raw_command_buffers);
107        }
108    }
109    
110    /// Wrapper for [vkTrimCommandPool](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkTrimCommandPool.html).
111    pub fn trim(&self, flags: VkCommandPoolTrimFlags) {
112        unsafe {
113            let raw_flags = vk_to_raw_value(&flags);
114            ((&*self._fn_table).vkTrimCommandPool)((*self._fn_table).device, self._handle, raw_flags);
115        }
116    }
117}