extensions/android: Add VK_ANDROID_external_memory_android_hardware_buffer (#769)
This commit is contained in:
parent
369fe05e79
commit
6b56444e79
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Update Vulkan-Headers to 1.3.254 (#760)
|
||||
- Added `VK_NV_memory_decompression` device extension (#761)
|
||||
- Added `VK_GOOGLE_display_timing` device extension (#765)
|
||||
- Added `VK_ANDROID_external_memory_android_hardware_buffer` device extension (#769)
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_ANDROID_external_memory_android_hardware_buffer.html>
|
||||
#[derive(Clone)]
|
||||
pub struct ExternalMemoryAndroidHardwareBuffer {
|
||||
handle: vk::Device,
|
||||
fp: vk::AndroidExternalMemoryAndroidHardwareBufferFn,
|
||||
}
|
||||
|
||||
impl ExternalMemoryAndroidHardwareBuffer {
|
||||
pub fn new(instance: &Instance, device: &Device) -> Self {
|
||||
let handle = device.handle();
|
||||
let fp = vk::AndroidExternalMemoryAndroidHardwareBufferFn::load(|name| unsafe {
|
||||
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
|
||||
});
|
||||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAndroidHardwareBufferPropertiesANDROID.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_android_hardware_buffer_properties(
|
||||
&self,
|
||||
buffer: *const vk::AHardwareBuffer,
|
||||
properties: &mut vk::AndroidHardwareBufferPropertiesANDROID,
|
||||
) -> VkResult<()> {
|
||||
(self.fp.get_android_hardware_buffer_properties_android)(self.handle, buffer, properties)
|
||||
.result()
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryAndroidHardwareBufferANDROID.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_memory_android_hardware_buffer(
|
||||
&self,
|
||||
info: &vk::MemoryGetAndroidHardwareBufferInfoANDROID,
|
||||
) -> VkResult<*mut vk::AHardwareBuffer> {
|
||||
let mut buffer = std::ptr::null_mut();
|
||||
(self.fp.get_memory_android_hardware_buffer_android)(self.handle, info, &mut buffer)
|
||||
.result_with_success(buffer)
|
||||
}
|
||||
|
||||
pub const NAME: &'static CStr = vk::AndroidExternalMemoryAndroidHardwareBufferFn::NAME;
|
||||
|
||||
#[inline]
|
||||
pub fn fp(&self) -> &vk::AndroidExternalMemoryAndroidHardwareBufferFn {
|
||||
&self.fp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn device(&self) -> vk::Device {
|
||||
self.handle
|
||||
}
|
||||
}
|
3
ash/src/extensions/android/mod.rs
Normal file
3
ash/src/extensions/android/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub use self::external_memory_android_hardware_buffer::ExternalMemoryAndroidHardwareBuffer;
|
||||
|
||||
mod external_memory_android_hardware_buffer;
|
|
@ -1,3 +1,4 @@
|
|||
pub mod android;
|
||||
pub mod ext;
|
||||
pub mod google;
|
||||
pub mod khr;
|
||||
|
|
Loading…
Reference in a new issue