Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions/google: Add VK_GOOGLE_display_timing #765

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
56 changes: 56 additions & 0 deletions ash/src/extensions/google/display_timing.rs
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_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
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}
MarijnS95 marked this conversation as resolved.
Show resolved Hide resolved
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