236: Provide VK_KHR_xlib_surface extension mapping r=kvark a=ElArtista



Co-authored-by: TheArtist <agorglouk@gmail.com>
This commit is contained in:
bors[bot] 2020-12-14 18:53:25 +00:00 committed by GitHub
commit c1938e9149
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 0 deletions

View file

@ -572,6 +572,7 @@ pub unsafe extern "C" fn gfxGetInstanceProcAddr(
vkGetPhysicalDeviceSurfacePresentModesKHR, PFN_vkGetPhysicalDeviceSurfacePresentModesKHR => gfxGetPhysicalDeviceSurfacePresentModesKHR,
vkGetPhysicalDeviceWin32PresentationSupportKHR, PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR => gfxGetPhysicalDeviceWin32PresentationSupportKHR,
vkCreateXlibSurfaceKHR, PFN_vkCreateXlibSurfaceKHR => gfxCreateXlibSurfaceKHR,
vkCreateXcbSurfaceKHR, PFN_vkCreateXcbSurfaceKHR => gfxCreateXcbSurfaceKHR,
vkCreateWin32SurfaceKHR, PFN_vkCreateWin32SurfaceKHR => gfxCreateWin32SurfaceKHR,
vkCreateMetalSurfaceEXT, PFN_vkCreateMetalSurfaceEXT => gfxCreateMetalSurfaceEXT,
@ -984,6 +985,8 @@ lazy_static! {
vec![
VK_KHR_SURFACE_EXTENSION_NAME,
#[cfg(target_os="linux")]
VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
#[cfg(target_os="linux")]
VK_KHR_XCB_SURFACE_EXTENSION_NAME,
#[cfg(target_os="windows")]
VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
@ -1003,6 +1006,11 @@ lazy_static! {
specVersion: VK_KHR_SURFACE_SPEC_VERSION,
},
#[cfg(target_os="linux")]
VkExtensionProperties {
extensionName: [0; 256], // VK_KHR_XLIB_SURFACE_EXTENSION_NAME
specVersion: VK_KHR_XLIB_SURFACE_SPEC_VERSION,
},
#[cfg(target_os="linux")]
VkExtensionProperties {
extensionName: [0; 256], // VK_KHR_XCB_SURFACE_EXTENSION_NAME
specVersion: VK_KHR_XCB_SURFACE_SPEC_VERSION,
@ -4708,6 +4716,46 @@ pub unsafe extern "C" fn gfxCreateWin32SurfaceKHR(
unreachable!()
}
}
pub unsafe extern "C" fn gfxCreateXlibSurfaceKHR(
instance: VkInstance,
pCreateInfo: *const VkXlibSurfaceCreateInfoKHR,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult {
assert!(pAllocator.is_null());
let info = &*pCreateInfo;
#[cfg(target_os = "linux")]
{
assert_eq!(info.flags, 0);
use raw_window_handle::{unix::XlibHandle, HasRawWindowHandle, RawWindowHandle};
struct HandleWrapper(XlibHandle);
unsafe impl HasRawWindowHandle for HandleWrapper {
fn raw_window_handle(&self) -> RawWindowHandle {
RawWindowHandle::Xlib(self.0)
}
}
let xlib_handle = XlibHandle {
window: info.window as _,
display: info.dpy,
..XlibHandle::empty()
};
*pSurface = Handle::new(
instance
.backend
.create_surface(&HandleWrapper(xlib_handle))
.unwrap(),
);
VkResult::VK_SUCCESS
}
#[cfg(not(target_os = "linux"))]
{
let _ = (instance, info, pSurface);
unreachable!()
}
}
pub unsafe extern "C" fn gfxCreateXcbSurfaceKHR(
instance: VkInstance,
pCreateInfo: *const VkXcbSurfaceCreateInfoKHR,

View file

@ -357,9 +357,11 @@ pub const VK_MAX_DESCRIPTION_SIZE: ::std::os::raw::c_uint = 256;
pub const VK_KHR_surface: ::std::os::raw::c_uint = 1;
pub const VK_KHR_SURFACE_SPEC_VERSION: ::std::os::raw::c_uint = 25;
pub const VK_KHR_SURFACE_EXTENSION_NAME: &'static [u8; 15usize] = b"VK_KHR_surface\x00";
pub const VK_KHR_XLIB_SURFACE_SPEC_VERSION: ::std::os::raw::c_uint = 6;
pub const VK_KHR_XCB_SURFACE_SPEC_VERSION: ::std::os::raw::c_uint = 6;
pub const VK_KHR_WIN32_SURFACE_SPEC_VERSION: ::std::os::raw::c_uint = 6;
pub const VK_MVK_MACOS_SURFACE_SPEC_VERSION: ::std::os::raw::c_uint = 2;
pub const VK_KHR_XLIB_SURFACE_EXTENSION_NAME: &'static [u8; 20usize] = b"VK_KHR_xlib_surface\x00";
pub const VK_KHR_XCB_SURFACE_EXTENSION_NAME: &'static [u8; 19usize] = b"VK_KHR_xcb_surface\x00";
pub const VK_KHR_WIN32_SURFACE_EXTENSION_NAME: &'static [u8; 21usize] = b"VK_KHR_win32_surface\x00";
pub const VK_MVK_MACOS_SURFACE_EXTENSION_NAME: &'static [u8; 21usize] = b"VK_MVK_macos_surface\x00";
@ -5173,6 +5175,21 @@ impl Clone for VkWin32SurfaceCreateInfoKHR {
*self
}
}
pub type VkXlibSurfaceCreateFlagsKHR = VkFlags;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct VkXlibSurfaceCreateInfoKHR {
pub sType: VkStructureType,
pub pNext: *mut ::std::os::raw::c_void,
pub flags: VkXlibSurfaceCreateFlagsKHR,
pub dpy: *mut ::std::os::raw::c_void,
pub window: u32,
}
impl Clone for VkXlibSurfaceCreateInfoKHR {
fn clone(&self) -> Self {
*self
}
}
pub type VkXcbSurfaceCreateFlagsKHR = VkFlags;
#[repr(C)]
#[derive(Debug, Copy)]
@ -7147,6 +7164,15 @@ pub type PFN_vkDestroyInstance = ::std::option::Option<
unsafe extern "C" fn(instance: VkInstance, pAllocator: *const VkAllocationCallbacks),
>;
pub type PFN_vkCreateXlibSurfaceKHR = ::std::option::Option<
unsafe extern "C" fn(
instance: VkInstance,
pCreateInfo: *const VkXlibSurfaceCreateInfoKHR,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult,
>;
pub type PFN_vkCreateXcbSurfaceKHR = ::std::option::Option<
unsafe extern "C" fn(
instance: VkInstance,