-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensions/android: Add VK_ANDROID_external_memory_android_hardware_b…
…uffer (#769)
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
ash/src/extensions/android/external_memory_android_hardware_buffer.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub use self::external_memory_android_hardware_buffer::ExternalMemoryAndroidHardwareBuffer; | ||
|
||
mod external_memory_android_hardware_buffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod android; | ||
pub mod ext; | ||
pub mod google; | ||
pub mod khr; | ||
|