XCB support

This commit is contained in:
Dzmitry Malyshau 2018-01-30 11:19:37 -05:00
parent c049bac241
commit 05e8abbde0
3 changed files with 50 additions and 5 deletions

View file

@ -2856,17 +2856,18 @@ pub extern "C" fn gfxCmdSetDiscardRectangleEXT(
#[inline]
pub extern "C" fn gfxCreateWin32SurfaceKHR(
instance: VkInstance,
pCreateInfos: *const VkWin32SurfaceCreateInfoKHR,
pCreateInfo: *const VkWin32SurfaceCreateInfoKHR,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult {
let info = unsafe { &*pCreateInfo };
#[cfg(all(feature = "vulkan", target_os = "windows"))]
{
unsafe {
assert_eq!((*pCreateInfos).flags, 0);
assert_eq!(info.flags, 0);
assert!(pAllocator.is_null());
*pSurface = Handle::new(
instance.create_surface_from_hwnd((*pCreateInfos).hinstance, (*pCreateInfos).hwnd),
instance.create_surface_from_hwnd(info.hinstance, info.hwnd),
);
VkResult::VK_SUCCESS
}
@ -2874,15 +2875,36 @@ pub extern "C" fn gfxCreateWin32SurfaceKHR(
#[cfg(feature = "dx12")]
{
unsafe {
assert_eq!((*pCreateInfos).flags, 0);
assert_eq!(info.flags, 0);
assert!(pAllocator.is_null());
*pSurface = Handle::new(instance.create_surface_from_hwnd((*pCreateInfos).hwnd));
*pSurface = Handle::new(instance.create_surface_from_hwnd(info.hwnd));
VkResult::VK_SUCCESS
}
}
#[cfg(not(target_os = "windows"))]
unreachable!()
}
pub extern "C" fn gfxCreateXcbSurfaceKHR(
instance: VkInstance,
pCreateInfo: *const VkXcbSurfaceCreateInfoKHR,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult {
let info = unsafe { &*pCreateInfo };
#[cfg(feature = "vulkan")]
{
unsafe {
assert_eq!(info.flags, 0);
assert!(pAllocator.is_null());
*pSurface = Handle::new(
instance.create_surface_from_xcb(info.connection as _, info.window),
);
VkResult::VK_SUCCESS
}
}
#[cfg(not(feature = "vulkan"))]
unreachable!()
}
#[inline]
pub extern "C" fn gfxAcquireNextImageKHR(
_device: VkDevice,

View file

@ -4753,6 +4753,19 @@ pub struct VkWin32SurfaceCreateInfoKHR {
impl Clone for VkWin32SurfaceCreateInfoKHR {
fn clone(&self) -> Self { *self }
}
pub type VkXcbSurfaceCreateFlagsKHR = VkFlags;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct VkXcbSurfaceCreateInfoKHR {
pub sType: VkStructureType,
pub pNext: *mut ::std::os::raw::c_void,
pub flags: VkXcbSurfaceCreateFlagsKHR,
pub connection: *mut ::std::os::raw::c_void,
pub window: u32,
}
impl Clone for VkXcbSurfaceCreateInfoKHR {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct VkPhysicalDeviceFeatures2KHR {

View file

@ -276,6 +276,16 @@ pub extern "C" fn vkCreateWin32SurfaceKHR(
gfxCreateWin32SurfaceKHR(instance, pCreateInfos, pAllocator, pSurface)
}
#[no_mangle]
pub extern "C" fn vkCreateXcbSurfaceKHR(
instance: VkInstance,
pCreateInfos: *const VkXcbSurfaceCreateInfoKHR,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult {
gfxCreateXcbSurfaceKHR(instance, pCreateInfos, pAllocator, pSurface)
}
#[no_mangle]
pub extern "C" fn vkMapMemory(
device: VkDevice,