#![allow(unused_imports)]
use crate::{vk::Result as VkResult, vk::*, *};
use core::ffi::{CStr, c_char, c_int, c_void};
use core::mem::transmute;
use core::ptr;
pub const EXTENSION_NAME: &CStr = c"VK_FUCHSIA_external_memory";
pub(super) mod defs {
#![allow(non_camel_case_types, unused_imports)]
use crate::{vk::*, *};
use core::ffi::{CStr, c_char, c_int, c_void};
use core::fmt;
use core::marker::PhantomData;
use core::ptr;
#[repr(C)]
#[derive(Copy, Clone)]
#[must_use]
pub struct ImportMemoryZirconHandleInfoFUCHSIA<'a> {
pub s_type: StructureType,
pub p_next: *const c_void,
pub handle_type: ExternalMemoryHandleTypeFlagBits,
pub handle: zx_handle_t,
pub _marker: PhantomData<&'a ()>,
}
#[cfg(feature = "debug")]
impl fmt::Debug for ImportMemoryZirconHandleInfoFUCHSIA<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ImportMemoryZirconHandleInfoFUCHSIA")
.field("s_type", &self.s_type)
.field("p_next", &self.p_next)
.field("handle_type", &self.handle_type)
.field("handle", &self.handle)
.finish()
}
}
unsafe impl<'a> TaggedStructure<'a> for ImportMemoryZirconHandleInfoFUCHSIA<'a> {
const STRUCTURE_TYPE: StructureType =
StructureType::IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA;
}
unsafe impl Extends<MemoryAllocateInfo<'_>> for ImportMemoryZirconHandleInfoFUCHSIA<'_> {}
impl Default for ImportMemoryZirconHandleInfoFUCHSIA<'_> {
fn default() -> Self {
Self {
s_type: Self::STRUCTURE_TYPE,
p_next: ptr::null(),
handle_type: Default::default(),
handle: Default::default(),
_marker: PhantomData,
}
}
}
impl<'a> ImportMemoryZirconHandleInfoFUCHSIA<'a> {
#[inline]
pub fn handle_type(mut self, handle_type: ExternalMemoryHandleTypeFlagBits) -> Self {
self.handle_type = handle_type;
self
}
#[inline]
pub fn handle(mut self, handle: zx_handle_t) -> Self {
self.handle = handle;
self
}
}
#[repr(C)]
#[derive(Copy, Clone)]
#[must_use]
pub struct MemoryZirconHandlePropertiesFUCHSIA<'a> {
pub s_type: StructureType,
pub p_next: *mut c_void,
pub memory_type_bits: u32,
pub _marker: PhantomData<&'a ()>,
}
#[cfg(feature = "debug")]
impl fmt::Debug for MemoryZirconHandlePropertiesFUCHSIA<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MemoryZirconHandlePropertiesFUCHSIA")
.field("s_type", &self.s_type)
.field("p_next", &self.p_next)
.field("memory_type_bits", &self.memory_type_bits)
.finish()
}
}
unsafe impl<'a> TaggedStructure<'a> for MemoryZirconHandlePropertiesFUCHSIA<'a> {
const STRUCTURE_TYPE: StructureType =
StructureType::MEMORY_ZIRCON_HANDLE_PROPERTIES_FUCHSIA;
}
impl Default for MemoryZirconHandlePropertiesFUCHSIA<'_> {
fn default() -> Self {
Self {
s_type: Self::STRUCTURE_TYPE,
p_next: ptr::null_mut(),
memory_type_bits: Default::default(),
_marker: PhantomData,
}
}
}
impl<'a> MemoryZirconHandlePropertiesFUCHSIA<'a> {
#[inline]
pub fn memory_type_bits(mut self, memory_type_bits: u32) -> Self {
self.memory_type_bits = memory_type_bits;
self
}
}
#[repr(C)]
#[derive(Copy, Clone)]
#[must_use]
pub struct MemoryGetZirconHandleInfoFUCHSIA<'a> {
pub s_type: StructureType,
pub p_next: *const c_void,
pub memory: DeviceMemory,
pub handle_type: ExternalMemoryHandleTypeFlagBits,
pub _marker: PhantomData<&'a ()>,
}
#[cfg(feature = "debug")]
impl fmt::Debug for MemoryGetZirconHandleInfoFUCHSIA<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MemoryGetZirconHandleInfoFUCHSIA")
.field("s_type", &self.s_type)
.field("p_next", &self.p_next)
.field("memory", &self.memory)
.field("handle_type", &self.handle_type)
.finish()
}
}
unsafe impl<'a> TaggedStructure<'a> for MemoryGetZirconHandleInfoFUCHSIA<'a> {
const STRUCTURE_TYPE: StructureType = StructureType::MEMORY_GET_ZIRCON_HANDLE_INFO_FUCHSIA;
}
impl Default for MemoryGetZirconHandleInfoFUCHSIA<'_> {
fn default() -> Self {
Self {
s_type: Self::STRUCTURE_TYPE,
p_next: ptr::null(),
memory: Default::default(),
handle_type: Default::default(),
_marker: PhantomData,
}
}
}
impl<'a> MemoryGetZirconHandleInfoFUCHSIA<'a> {
#[inline]
pub fn memory(mut self, memory: DeviceMemory) -> Self {
self.memory = memory;
self
}
#[inline]
pub fn handle_type(mut self, handle_type: ExternalMemoryHandleTypeFlagBits) -> Self {
self.handle_type = handle_type;
self
}
}
pub type PFN_vkGetMemoryZirconHandleFUCHSIA = unsafe extern "system" fn(
device: Device,
p_get_zircon_handle_info: *const MemoryGetZirconHandleInfoFUCHSIA<'_>,
p_zircon_handle: *mut zx_handle_t,
) -> vk::Result;
pub type PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA = unsafe extern "system" fn(
device: Device,
handle_type: ExternalMemoryHandleTypeFlagBits,
zircon_handle: zx_handle_t,
p_memory_zircon_handle_properties: *mut MemoryZirconHandlePropertiesFUCHSIA<'_>,
)
-> vk::Result;
}
#[cfg(feature = "ffi")]
pub(super) mod ffi {
#![allow(non_camel_case_types)]
use super::defs::*;
pub type VkImportMemoryZirconHandleInfoFUCHSIA = ImportMemoryZirconHandleInfoFUCHSIA<'static>;
pub type VkMemoryZirconHandlePropertiesFUCHSIA = MemoryZirconHandlePropertiesFUCHSIA<'static>;
pub type VkMemoryGetZirconHandleInfoFUCHSIA = MemoryGetZirconHandleInfoFUCHSIA<'static>;
impl ImportMemoryZirconHandleInfoFUCHSIA<'_> {
#[inline]
pub unsafe fn drop_lifetime_for_ffi(&self) -> &VkImportMemoryZirconHandleInfoFUCHSIA {
unsafe { core::mem::transmute(self) }
}
}
impl MemoryZirconHandlePropertiesFUCHSIA<'_> {
#[inline]
pub unsafe fn drop_lifetime_for_ffi(&self) -> &VkMemoryZirconHandlePropertiesFUCHSIA {
unsafe { core::mem::transmute(self) }
}
}
impl MemoryGetZirconHandleInfoFUCHSIA<'_> {
#[inline]
pub unsafe fn drop_lifetime_for_ffi(&self) -> &VkMemoryGetZirconHandleInfoFUCHSIA {
unsafe { core::mem::transmute(self) }
}
}
}
pub struct DeviceFn {
get_memory_zircon_handle: PFN_vkGetMemoryZirconHandleFUCHSIA,
get_memory_zircon_handle_properties: PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA,
}
impl LoadDeviceFn for DeviceFn {
unsafe fn load_with(
load: impl Fn(&CStr) -> Option<PFN_vkVoidFunction>,
) -> core::result::Result<Self, MissingEntryPointError> {
unsafe {
Ok(Self {
get_memory_zircon_handle: transmute(
load(c"vkGetMemoryZirconHandleFUCHSIA").ok_or(MissingEntryPointError)?,
),
get_memory_zircon_handle_properties: transmute(
load(c"vkGetMemoryZirconHandlePropertiesFUCHSIA")
.ok_or(MissingEntryPointError)?,
),
})
}
}
}
impl DeviceFn {
#[inline]
pub unsafe fn get_memory_zircon_handle(
&self,
device: Device,
get_zircon_handle_info: &MemoryGetZirconHandleInfoFUCHSIA<'_>,
) -> crate::Result<zx_handle_t> {
unsafe {
let mut zircon_handle = core::mem::MaybeUninit::uninit();
let result = (self.get_memory_zircon_handle)(
device,
get_zircon_handle_info,
zircon_handle.as_mut_ptr(),
);
match result {
VkResult::SUCCESS => Ok(zircon_handle.assume_init()),
err => Err(err),
}
}
}
#[inline]
pub unsafe fn get_memory_zircon_handle_properties(
&self,
device: Device,
handle_type: ExternalMemoryHandleTypeFlagBits,
zircon_handle: zx_handle_t,
memory_zircon_handle_properties: &mut MemoryZirconHandlePropertiesFUCHSIA<'_>,
) -> crate::Result<()> {
unsafe {
let result = (self.get_memory_zircon_handle_properties)(
device,
handle_type,
zircon_handle,
memory_zircon_handle_properties,
);
match result {
VkResult::SUCCESS => Ok(()),
err => Err(err),
}
}
}
}