-
Notifications
You must be signed in to change notification settings - Fork 223
Add VK_KHR_display extension support
#247
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,203 @@ | ||
| use crate::prelude::*; | ||
| use crate::version::{EntryV1_0, InstanceV1_0}; | ||
| use crate::vk; | ||
| use crate::RawPtr; | ||
| use std::ffi::CStr; | ||
| use std::mem; | ||
| use std::ptr; | ||
|
|
||
| #[derive(Clone)] | ||
| pub struct Display { | ||
| handle: vk::Instance, | ||
| display_fn: vk::KhrDisplayFn, | ||
| } | ||
|
|
||
| impl Display { | ||
| pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Display { | ||
| let display_fn = vk::KhrDisplayFn::load(|name| unsafe { | ||
| mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) | ||
| }); | ||
| Display { | ||
| handle: instance.handle(), | ||
| display_fn, | ||
| } | ||
| } | ||
|
|
||
| pub fn name() -> &'static CStr { | ||
| vk::KhrDisplayFn::name() | ||
| } | ||
|
|
||
| #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>"] | ||
| pub unsafe fn get_physical_device_display_properties( | ||
| &self, | ||
| physical_device: vk::PhysicalDevice, | ||
| ) -> VkResult<Vec<vk::DisplayPropertiesKHR>> { | ||
| let mut count = 0; | ||
| self.display_fn.get_physical_device_display_properties_khr( | ||
ehegnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| physical_device, | ||
| &mut count, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ptr::null_mut(), | ||
| ); | ||
| let mut v = Vec::with_capacity(count as usize); | ||
| let err_code = self.display_fn.get_physical_device_display_properties_khr( | ||
| physical_device, | ||
| &mut count, | ||
ehegnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| v.as_mut_ptr(), | ||
| ); | ||
| v.set_len(count as usize); | ||
| match err_code { | ||
| vk::Result::SUCCESS => Ok(v), | ||
| _ => Err(err_code), | ||
| } | ||
| } | ||
|
|
||
| #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>"] | ||
| pub unsafe fn get_physical_device_display_plane_properties( | ||
| &self, | ||
| physical_device: vk::PhysicalDevice, | ||
| ) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> { | ||
| let mut count = 0; | ||
| self.display_fn | ||
ehegnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .get_physical_device_display_plane_properties_khr( | ||
| physical_device, | ||
| &mut count, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ptr::null_mut(), | ||
| ); | ||
| let mut v = Vec::with_capacity(count as usize); | ||
| let err_code = self | ||
| .display_fn | ||
| .get_physical_device_display_plane_properties_khr( | ||
| physical_device, | ||
| &mut count, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| v.as_mut_ptr(), | ||
| ); | ||
| v.set_len(count as usize); | ||
| match err_code { | ||
| vk::Result::SUCCESS => Ok(v), | ||
| _ => Err(err_code), | ||
| } | ||
| } | ||
|
|
||
| #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>"] | ||
| pub unsafe fn get_display_plane_supported_displays( | ||
| &self, | ||
| physical_device: vk::PhysicalDevice, | ||
| plane_index: u32, | ||
| ) -> VkResult<Vec<vk::DisplayKHR>> { | ||
| let mut count = 0; | ||
| self.display_fn.get_display_plane_supported_displays_khr( | ||
ehegnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| physical_device, | ||
| plane_index, | ||
| &mut count, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ptr::null_mut(), | ||
| ); | ||
| let mut v = Vec::with_capacity(count as usize); | ||
| let err_code = self.display_fn.get_display_plane_supported_displays_khr( | ||
| physical_device, | ||
| plane_index, | ||
| &mut count, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| v.as_mut_ptr(), | ||
| ); | ||
| v.set_len(count as usize); | ||
| match err_code { | ||
| vk::Result::SUCCESS => Ok(v), | ||
| _ => Err(err_code), | ||
| } | ||
| } | ||
|
|
||
| #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDisplayModePropertiesKHR.html>"] | ||
| pub unsafe fn get_display_mode_properties( | ||
| &self, | ||
| physical_device: vk::PhysicalDevice, | ||
| display: vk::DisplayKHR, | ||
| ) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> { | ||
| let mut count = 0; | ||
| self.display_fn.get_display_mode_properties_khr( | ||
ehegnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| physical_device, | ||
| display, | ||
| &mut count, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ptr::null_mut(), | ||
| ); | ||
| let mut v = Vec::with_capacity(count as usize); | ||
| let err_code = self.display_fn.get_display_mode_properties_khr( | ||
| physical_device, | ||
| display, | ||
| &mut count, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| v.as_mut_ptr(), | ||
| ); | ||
| v.set_len(count as usize); | ||
| match err_code { | ||
| vk::Result::SUCCESS => Ok(v), | ||
| _ => Err(err_code), | ||
| } | ||
| } | ||
|
|
||
| #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDisplayModeKHR.html>"] | ||
| pub unsafe fn create_display_mode( | ||
| &self, | ||
| physical_device: vk::PhysicalDevice, | ||
| display: vk::DisplayKHR, | ||
| create_info: &vk::DisplayModeCreateInfoKHR, | ||
| allocation_callbacks: Option<&vk::AllocationCallbacks>, | ||
| ) -> VkResult<vk::DisplayModeKHR> { | ||
| let mut display_mode = mem::zeroed(); | ||
ehegnes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let err_code = self.display_fn.create_display_mode_khr( | ||
| physical_device, | ||
| display, | ||
| create_info, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| allocation_callbacks.as_raw_ptr(), | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| &mut display_mode, | ||
Ralith marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| match err_code { | ||
| vk::Result::SUCCESS => Ok(display_mode), | ||
| _ => Err(err_code), | ||
| } | ||
| } | ||
|
|
||
| #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>"] | ||
| pub unsafe fn get_display_plane_capabilities( | ||
| &self, | ||
| physical_device: vk::PhysicalDevice, | ||
| mode: vk::DisplayModeKHR, | ||
| plane_index: u32, | ||
| ) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> { | ||
| let mut display_plane_capabilities = mem::zeroed(); | ||
ehegnes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let err_code = self.display_fn.get_display_plane_capabilities_khr( | ||
| physical_device, | ||
| mode, | ||
| plane_index, | ||
| &mut display_plane_capabilities, | ||
Ralith marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| match err_code { | ||
| vk::Result::SUCCESS => Ok(display_plane_capabilities), | ||
| _ => Err(err_code), | ||
| } | ||
| } | ||
|
|
||
| #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html>"] | ||
| pub unsafe fn create_display_plane_surface( | ||
| &self, | ||
| create_info: &vk::DisplaySurfaceCreateInfoKHR, | ||
| allocation_callbacks: Option<&vk::AllocationCallbacks>, | ||
| ) -> VkResult<vk::SurfaceKHR> { | ||
| let mut surface = mem::zeroed(); | ||
ehegnes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let err_code = self.display_fn.create_display_plane_surface_khr( | ||
| self.handle, | ||
| create_info, | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| allocation_callbacks.as_raw_ptr(), | ||
Ralith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| &mut surface, | ||
Ralith marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| match err_code { | ||
| vk::Result::SUCCESS => Ok(surface), | ||
| _ => Err(err_code), | ||
| } | ||
| } | ||
|
|
||
| pub fn fp(&self) -> &vk::KhrDisplayFn { | ||
| &self.display_fn | ||
| } | ||
|
|
||
| pub fn instance(&self) -> vk::Instance { | ||
| self.handle | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.