From a9aada84e65125f70a11ce6eda77f1d894caf4c2 Mon Sep 17 00:00:00 2001 From: msiglreith Date: Thu, 23 Nov 2017 18:39:15 +0100 Subject: [PATCH] win32: Support win32 surface creation --- src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ac54f51..09fdbd6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5214,6 +5214,9 @@ pub struct VkSurfaceInner { } pub type VkSurfaceKHR = Handle>; +// TODO: temporary surface type, should be replacing `VkSurfaceKHR` in the future. +pub type VkSurfaceRawKHR = Handle<::Surface>; + pub const VkColorSpaceKHR_VK_COLOR_SPACE_BEGIN_RANGE_KHR: VkColorSpaceKHR = VkColorSpaceKHR::VK_COLOR_SPACE_SRGB_NONLINEAR_KHR; pub const VkColorSpaceKHR_VK_COLOR_SPACE_END_RANGE_KHR: VkColorSpaceKHR = @@ -5804,6 +5807,38 @@ extern "C" { pSwapchains: *mut VkSwapchainKHR) -> VkResult; } +pub type VkWin32SurfaceCreateFlagsKHR = VkFlags; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct VkWin32SurfaceCreateInfoKHR { + pub sType: VkStructureType, + pub pNext: *mut ::std::os::raw::c_void, + pub flags: VkWin32SurfaceCreateFlagsKHR, + pub hinstance: *mut ::std::os::raw::c_void, + pub hwnd: *mut ::std::os::raw::c_void, +} +impl Clone for VkWin32SurfaceCreateInfoKHR { + fn clone(&self) -> Self { *self } +} +#[no_mangle] +pub fn vkCreateWin32SurfaceKHR( + instance: VkInstance, + pCreateInfos: *const VkWin32SurfaceCreateInfoKHR, + pAllocator: *const VkAllocationCallbacks, + pSurface: *mut VkSurfaceRawKHR, +) -> VkResult { + if cfg!(target_os = "windows") { + unsafe { + assert_eq!((*pCreateInfos).flags, 0); + assert!(pAllocator.is_null()); + // TODO: handle HINSTANCE + *pSurface = Handle::new(instance.create_surface_from_hwnd((*pCreateInfos).hwnd)); + VkResult::VK_SUCCESS + } + } else { + unreachable!() + } +} #[repr(C)] #[derive(Debug, Copy)] pub struct VkPhysicalDeviceFeatures2KHR {