extensions/ext: Add VK_EXT_headless_surface instance extension
This commit is contained in:
parent
8d7abfb6f1
commit
d180a3b655
|
@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- Added `VK_EXT_headless_surface` instance extension (#589)
|
||||
|
||||
## [0.36.0] - 2022-02-21
|
||||
|
||||
### Changed
|
||||
|
|
52
ash/src/extensions/ext/headless_surface.rs
Normal file
52
ash/src/extensions/ext/headless_surface.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::RawPtr;
|
||||
use crate::{Entry, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_headless_surface.html>
|
||||
#[derive(Clone)]
|
||||
pub struct HeadlessSurface {
|
||||
handle: vk::Instance,
|
||||
fp: vk::ExtHeadlessSurfaceFn,
|
||||
}
|
||||
|
||||
impl HeadlessSurface {
|
||||
pub fn new(entry: &Entry, instance: &Instance) -> Self {
|
||||
let handle = instance.handle();
|
||||
let fp = vk::ExtHeadlessSurfaceFn::load(|name| unsafe {
|
||||
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
|
||||
});
|
||||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateHeadlessSurfaceEXT.html>
|
||||
pub unsafe fn create_headless_surface(
|
||||
&self,
|
||||
create_info: &vk::HeadlessSurfaceCreateInfoEXT,
|
||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||
) -> VkResult<vk::SurfaceKHR> {
|
||||
let mut surface = mem::zeroed();
|
||||
self.fp
|
||||
.create_headless_surface_ext(
|
||||
self.handle,
|
||||
create_info,
|
||||
allocation_callbacks.as_raw_ptr(),
|
||||
&mut surface,
|
||||
)
|
||||
.result_with_success(surface)
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr {
|
||||
vk::ExtHeadlessSurfaceFn::name()
|
||||
}
|
||||
|
||||
pub fn fp(&self) -> &vk::ExtHeadlessSurfaceFn {
|
||||
&self.fp
|
||||
}
|
||||
|
||||
pub fn instance(&self) -> vk::Instance {
|
||||
self.handle
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ pub use self::debug_utils::DebugUtils;
|
|||
pub use self::extended_dynamic_state::ExtendedDynamicState;
|
||||
pub use self::extended_dynamic_state2::ExtendedDynamicState2;
|
||||
pub use self::full_screen_exclusive::FullScreenExclusive;
|
||||
pub use self::headless_surface::HeadlessSurface;
|
||||
pub use self::metal_surface::MetalSurface;
|
||||
pub use self::physical_device_drm::PhysicalDeviceDrm;
|
||||
pub use self::private_data::PrivateData;
|
||||
|
@ -23,6 +24,7 @@ mod debug_utils;
|
|||
mod extended_dynamic_state;
|
||||
mod extended_dynamic_state2;
|
||||
mod full_screen_exclusive;
|
||||
mod headless_surface;
|
||||
mod metal_surface;
|
||||
mod physical_device_drm;
|
||||
mod private_data;
|
||||
|
|
Loading…
Reference in a new issue