Skip to content

Commit

Permalink
extensions/google: Add VK_GOOGLE_display_timing (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencercw committed Jul 5, 2023
1 parent a0f8b9c commit 09bb480
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow building `Entry`/`Instance`/`Device` from handle+fns (see their `from_parts_1_x()` associated functions) (#748)
- Update Vulkan-Headers to 1.3.254 (#760)
- Added `VK_NV_memory_decompression` device extension (#761)
- Added `VK_GOOGLE_display_timing` device extension (#765)

### Changed

Expand Down
51 changes: 51 additions & 0 deletions ash/src/extensions/google/display_timing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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_GOOGLE_display_timing.html>
#[derive(Clone)]
pub struct DisplayTiming {
handle: vk::Device,
fp: vk::GoogleDisplayTimingFn,
}

impl DisplayTiming {
pub fn new(instance: &Instance, device: &Device) -> Self {
let handle = device.handle();
let fp = vk::GoogleDisplayTimingFn::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/vkGetPastPresentationTimingGOOGLE.html>
#[inline]
pub unsafe fn get_past_presentation_timing(
&self,
swapchain: vk::SwapchainKHR,
) -> VkResult<Vec<vk::PastPresentationTimingGOOGLE>> {
read_into_uninitialized_vector(|count, data| {
(self.fp.get_past_presentation_timing_google)(self.handle, swapchain, count, data)
})
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRefreshCycleDurationGOOGLE.html>
#[inline]
pub unsafe fn get_refresh_cycle_duration(
&self,
swapchain: vk::SwapchainKHR,
) -> VkResult<vk::RefreshCycleDurationGOOGLE> {
let mut properties = mem::zeroed();
(self.fp.get_refresh_cycle_duration_google)(self.handle, swapchain, &mut properties)
.result_with_success(properties)
}

pub const NAME: &'static CStr = vk::GoogleDisplayTimingFn::NAME;

#[inline]
pub fn fp(&self) -> &vk::GoogleDisplayTimingFn {
&self.fp
}
}
3 changes: 3 additions & 0 deletions ash/src/extensions/google/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub use self::display_timing::DisplayTiming;

mod display_timing;
1 change: 1 addition & 0 deletions ash/src/extensions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod ext;
pub mod google;
pub mod khr;
pub mod mvk;
pub mod nn;
Expand Down

0 comments on commit 09bb480

Please sign in to comment.