Merge pull request #3 from msiglreith/win32surface

Support win32 surface creation
This commit is contained in:
Dzmitry Malyshau 2017-11-24 11:13:21 -05:00 committed by GitHub
commit d2dc11f229
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5214,6 +5214,9 @@ pub struct VkSurfaceInner<Backend: hal::Backend> {
}
pub type VkSurfaceKHR = Handle<VkSurfaceInner<B>>;
// TODO: temporary surface type, should be replacing `VkSurfaceKHR` in the future.
pub type VkSurfaceRawKHR = Handle<<B as hal::Backend>::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 {