-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensions/google: Add VK_GOOGLE_display_timing (#765)
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub use self::display_timing::DisplayTiming; | ||
|
||
mod display_timing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|