lava/vulkan/vk/
vk_command_pool.rs1use 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#[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 pub fn vk_handle(&self) -> u64 {
66 self._handle
67 }
68
69 pub fn is_null(&self) -> bool {
71 self._handle == 0
72 }
73
74 pub fn null() -> Self {
78 Self {
79 _handle: 0,
80 _fn_table: ptr::null_mut()
81 }
82 }
83
84 pub fn destroy(&self) {
86 unsafe {
87 ((&*self._fn_table).vkDestroyCommandPool)((*self._fn_table).device, self._handle, ptr::null());
88 }
89 }
90
91 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 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 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}