extensions/ext: Add VK_EXT_private_data (#570)
This commit is contained in:
parent
bb02b20339
commit
d4d9276636
3 changed files with 103 additions and 0 deletions
|
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
|
||||
- Added `VK_EXT_private_data` device extension (#570)
|
||||
- Added conversions from `Extent2D` to `Extent3D` and `Rect2D` (#557)
|
||||
|
||||
## [0.35.1] - 2022-01-18
|
||||
|
|
|
@ -9,6 +9,7 @@ pub use self::extended_dynamic_state::ExtendedDynamicState;
|
|||
pub use self::full_screen_exclusive::FullScreenExclusive;
|
||||
pub use self::metal_surface::MetalSurface;
|
||||
pub use self::physical_device_drm::PhysicalDeviceDrm;
|
||||
pub use self::private_data::PrivateData;
|
||||
pub use self::tooling_info::ToolingInfo;
|
||||
|
||||
mod buffer_device_address;
|
||||
|
@ -22,4 +23,5 @@ mod extended_dynamic_state;
|
|||
mod full_screen_exclusive;
|
||||
mod metal_surface;
|
||||
mod physical_device_drm;
|
||||
mod private_data;
|
||||
mod tooling_info;
|
||||
|
|
100
ash/src/extensions/ext/private_data.rs
Normal file
100
ash/src/extensions/ext/private_data.rs
Normal file
|
@ -0,0 +1,100 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::RawPtr;
|
||||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_private_data.html>
|
||||
#[derive(Clone)]
|
||||
pub struct PrivateData {
|
||||
handle: vk::Device,
|
||||
fp: vk::ExtPrivateDataFn,
|
||||
}
|
||||
|
||||
impl PrivateData {
|
||||
pub fn new(instance: &Instance, device: &Device) -> Self {
|
||||
let handle = device.handle();
|
||||
let fp = vk::ExtPrivateDataFn::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/vkCreatePrivateDataSlotEXT.html>
|
||||
pub unsafe fn create_private_data_slot(
|
||||
&self,
|
||||
create_info: &vk::PrivateDataSlotCreateInfoEXT,
|
||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||
) -> VkResult<vk::PrivateDataSlotEXT> {
|
||||
let mut private_data_slot = mem::zeroed();
|
||||
self.fp
|
||||
.create_private_data_slot_ext(
|
||||
self.handle,
|
||||
create_info,
|
||||
allocation_callbacks.as_raw_ptr(),
|
||||
&mut private_data_slot,
|
||||
)
|
||||
.result_with_success(private_data_slot)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyPrivateDataSlotEXT.html>
|
||||
pub unsafe fn destroy_private_data_slot(
|
||||
&self,
|
||||
private_data_slot: vk::PrivateDataSlotEXT,
|
||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||
) {
|
||||
self.fp.destroy_private_data_slot_ext(
|
||||
self.handle,
|
||||
private_data_slot,
|
||||
allocation_callbacks.as_raw_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSetPrivateDataEXT.html>
|
||||
pub unsafe fn set_private_data<T: vk::Handle>(
|
||||
&self,
|
||||
object: T,
|
||||
private_data_slot: vk::PrivateDataSlotEXT,
|
||||
data: u64,
|
||||
) -> VkResult<()> {
|
||||
self.fp
|
||||
.set_private_data_ext(
|
||||
self.handle,
|
||||
T::TYPE,
|
||||
object.as_raw(),
|
||||
private_data_slot,
|
||||
data,
|
||||
)
|
||||
.result()
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPrivateDataEXT.html>
|
||||
pub unsafe fn get_private_data<T: vk::Handle>(
|
||||
&self,
|
||||
object: T,
|
||||
private_data_slot: vk::PrivateDataSlotEXT,
|
||||
) -> u64 {
|
||||
let mut data = mem::zeroed();
|
||||
self.fp.get_private_data_ext(
|
||||
self.handle,
|
||||
T::TYPE,
|
||||
object.as_raw(),
|
||||
private_data_slot,
|
||||
&mut data,
|
||||
);
|
||||
data
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr {
|
||||
vk::ExtPrivateDataFn::name()
|
||||
}
|
||||
|
||||
pub fn fp(&self) -> &vk::ExtPrivateDataFn {
|
||||
&self.fp
|
||||
}
|
||||
|
||||
pub fn device(&self) -> vk::Device {
|
||||
self.handle
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue