Skip to content

Commit

Permalink
Add VK_EXT_full_screen_exclusive extension (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rua committed Mar 20, 2021
1 parent 3094084 commit bbbcd03
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
100 changes: 100 additions & 0 deletions ash/src/extensions/ext/full_screen_exclusive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
use std::ptr;

#[derive(Clone)]
pub struct FullScreenExclusive {
handle: vk::Device,
full_screen_exclusive_fn: vk::ExtFullScreenExclusiveFn,
}

impl FullScreenExclusive {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> FullScreenExclusive {
let full_screen_exclusive_fn = vk::ExtFullScreenExclusiveFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
FullScreenExclusive {
handle: device.handle(),
full_screen_exclusive_fn,
}
}

pub fn name() -> &'static CStr {
vk::ExtFullScreenExclusiveFn::name()
}

#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAcquireFullScreenExclusiveModeEXT.html>"]
pub unsafe fn acquire_full_screen_exclusive_mode(
&self,
swapchain: vk::SwapchainKHR,
) -> VkResult<()> {
self.full_screen_exclusive_fn
.acquire_full_screen_exclusive_mode_ext(self.handle, swapchain)
.result()
}

#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModes2EXT.html>"]
pub unsafe fn get_physical_device_surface_present_modes2(
&self,
physical_device: vk::PhysicalDevice,
surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR,
) -> VkResult<Vec<vk::PresentModeKHR>> {
let mut count = mem::zeroed();
self.full_screen_exclusive_fn
.get_physical_device_surface_present_modes2_ext(
physical_device,
surface_info,
&mut count,
ptr::null_mut(),
)
.result()?;
let mut present_modes = Vec::<vk::PresentModeKHR>::with_capacity(count as usize);
let err_code = self
.full_screen_exclusive_fn
.get_physical_device_surface_present_modes2_ext(
physical_device,
surface_info,
&mut count,
present_modes.as_mut_ptr(),
);
present_modes.set_len(count as usize);
err_code.result_with_success(present_modes)
}

#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkReleaseFullScreenExclusiveModeEXT.html>"]
pub unsafe fn release_full_screen_exclusive_mode(
&self,
swapchain: vk::SwapchainKHR,
) -> VkResult<()> {
self.full_screen_exclusive_fn
.release_full_screen_exclusive_mode_ext(self.handle, swapchain)
.result()
}

#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceGroupSurfacePresentModes2EXT.html>"]
pub unsafe fn get_device_group_surface_present_modes2(
&self,
surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR,
) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> {
let mut present_modes = mem::zeroed();
self.full_screen_exclusive_fn
.get_device_group_surface_present_modes2_ext(
self.handle,
surface_info,
&mut present_modes,
)
.result_with_success(present_modes)
}

pub fn fp(&self) -> &vk::ExtFullScreenExclusiveFn {
&self.full_screen_exclusive_fn
}

pub fn device(&self) -> vk::Device {
self.handle
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub use self::debug_marker::DebugMarker;
#[allow(deprecated)]
pub use self::debug_report::DebugReport;
pub use self::debug_utils::DebugUtils;
pub use self::full_screen_exclusive::FullScreenExclusive;
pub use self::metal_surface::MetalSurface;
pub use self::tooling_info::ToolingInfo;

Expand All @@ -13,5 +14,6 @@ mod debug_marker;
#[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")]
mod debug_report;
mod debug_utils;
mod full_screen_exclusive;
mod metal_surface;
mod tooling_info;

0 comments on commit bbbcd03

Please sign in to comment.