use utils::c_bindings::*;
use utils::vk_traits::*;
use utils::vk_ptr::*;
use utils::vk_convert::*;
use std::os::raw::c_char;
use std::ops::Drop;
use std::ptr;
use std::mem;
use std::cmp;
use std::slice;
use vulkan::*;
use vulkan::vk::*;
#[doc(hidden)]
pub type RawVkDescriptorPool = u64;
#[derive(Debug, Clone, Copy)]
pub struct VkDescriptorPool {
_handle: RawVkDescriptorPool,
_fn_table: *mut VkFunctionTable
}
impl VkRawType<VkDescriptorPool> for RawVkDescriptorPool {
fn vk_to_wrapped(src: &RawVkDescriptorPool) -> VkDescriptorPool {
VkDescriptorPool {
_handle: *src,
_fn_table: ptr::null_mut()
}
}
}
impl VkWrappedType<RawVkDescriptorPool> for VkDescriptorPool {
fn vk_to_raw(src: &VkDescriptorPool, dst: &mut RawVkDescriptorPool) {
*dst = src._handle
}
}
impl Default for VkDescriptorPool {
fn default() -> VkDescriptorPool {
VkDescriptorPool {
_handle: 0,
_fn_table: ptr::null_mut()
}
}
}
impl PartialEq for VkDescriptorPool {
fn eq(&self, other: &VkDescriptorPool) -> bool {
self._handle == other._handle
}
}
impl VkSetup for VkDescriptorPool {
fn vk_setup(&mut self, fn_table: *mut VkFunctionTable) {
self._fn_table = fn_table;
}
}
impl VkDescriptorPool {
pub fn vk_handle(&self) -> u64 {
self._handle
}
pub fn is_null(&self) -> bool {
self._handle == 0
}
pub fn null() -> Self {
Self {
_handle: 0,
_fn_table: ptr::null_mut()
}
}
pub fn destroy(&self) {
unsafe {
((&*self._fn_table).vkDestroyDescriptorPool)((*self._fn_table).device, self._handle, ptr::null());
}
}
pub fn reset(&self, flags: VkDescriptorPoolResetFlags) -> LavaResult<()> {
unsafe {
let raw_flags = vk_to_raw_value(&flags);
let vk_result = ((&*self._fn_table).vkResetDescriptorPool)((*self._fn_table).device, self._handle, raw_flags);
if vk_result == 0 { Ok(()) } else { Err((RawVkResult::vk_to_wrapped(&vk_result), ())) }
}
}
pub fn free_descriptor_sets(&self, descriptor_sets: Vec<VkDescriptorSet>) -> LavaResult<()> {
unsafe {
let raw_descriptor_set_count = descriptor_sets.len() as u32;
let raw_descriptor_sets = new_ptr_vk_array(&descriptor_sets);
let vk_result = ((&*self._fn_table).vkFreeDescriptorSets)((*self._fn_table).device, self._handle, raw_descriptor_set_count, raw_descriptor_sets);
free_ptr(raw_descriptor_sets);
if vk_result == 0 { Ok(()) } else { Err((RawVkResult::vk_to_wrapped(&vk_result), ())) }
}
}
}