92: macOS surface changes and more r=kvark a=grovesNL



Co-authored-by: Joshua Groves <josh@joshgroves.com>
This commit is contained in:
bors[bot] 2018-06-06 03:00:38 +00:00
commit 0012de8dfe
4 changed files with 76 additions and 3 deletions

View file

@ -43,7 +43,7 @@ FULL_LIBRARY_PATH=$(CURDIR)/target/debug
LIBRARY=target/debug/libportability.$(LIB_EXTENSION) LIBRARY=target/debug/libportability.$(LIB_EXTENSION)
LIBRARY_FAST=target/release/libportability.$(LIB_EXTENSION) LIBRARY_FAST=target/release/libportability.$(LIB_EXTENSION)
.PHONY: all rebuild debug release binding run cts cts-pick cts-debug clean cherry .PHONY: all rebuild debug debug-version release binding run cts cts-pick cts-debug clean cherry
all: $(TARGET) all: $(TARGET)
@ -53,6 +53,9 @@ rebuild:
debug: debug:
cargo build --manifest-path libportability/Cargo.toml --features "$(BACKEND) debug" cargo build --manifest-path libportability/Cargo.toml --features "$(BACKEND) debug"
debug-version:
cargo rustc --manifest-path libportability/Cargo.toml --features "$(BACKEND) debug" -- -Clink-arg="-current_version 1.0.0" -Clink-arg="-compatibility_version 1.0.0"
release: $(LIBRARY_FAST) release: $(LIBRARY_FAST)
binding: $(BINDING) binding: $(BINDING)

View file

@ -275,7 +275,7 @@ pub extern "C" fn gfxGetPhysicalDeviceProperties(
driverVersion: DRIVER_VERSION, driverVersion: DRIVER_VERSION,
vendorID: adapter_info.vendor as _, vendorID: adapter_info.vendor as _,
deviceID: adapter_info.device as _, deviceID: adapter_info.device as _,
deviceType: VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_OTHER, // TODO deviceType: VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, // TODO
deviceName: device_name, deviceName: device_name,
pipelineCacheUUID: [0; 16usize], pipelineCacheUUID: [0; 16usize],
limits, limits,
@ -352,6 +352,9 @@ pub extern "C" fn gfxGetInstanceProcAddr(
vkGetPhysicalDeviceSurfacePresentModesKHR, PFN_vkGetPhysicalDeviceSurfacePresentModesKHR => gfxGetPhysicalDeviceSurfacePresentModesKHR, vkGetPhysicalDeviceSurfacePresentModesKHR, PFN_vkGetPhysicalDeviceSurfacePresentModesKHR => gfxGetPhysicalDeviceSurfacePresentModesKHR,
vkCreateWin32SurfaceKHR, PFN_vkCreateWin32SurfaceKHR => gfxCreateWin32SurfaceKHR, vkCreateWin32SurfaceKHR, PFN_vkCreateWin32SurfaceKHR => gfxCreateWin32SurfaceKHR,
vkCreateMacOSSurfaceMVK, PFN_vkCreateMacOSSurfaceMVK => gfxCreateMacOSSurfaceMVK,
vkDestroySurfaceKHR, PFN_vkDestroySurfaceKHR => gfxDestroySurfaceKHR,
} }
} }
@ -622,7 +625,12 @@ lazy_static! {
VkExtensionProperties { VkExtensionProperties {
extensionName: [0; 256], // VK_KHR_WIN32_SURFACE_EXTENSION_NAME extensionName: [0; 256], // VK_KHR_WIN32_SURFACE_EXTENSION_NAME
specVersion: VK_KHR_WIN32_SURFACE_SPEC_VERSION, specVersion: VK_KHR_WIN32_SURFACE_SPEC_VERSION,
} },
#[cfg(target_os="macos")]
VkExtensionProperties {
extensionName: [0; 256], // VK_MVK_MACOS_SURFACE_EXTENSION_NAME
specVersion: VK_MVK_MACOS_SURFACE_SPEC_VERSION,
},
]; ];
extensions[0] extensions[0]
@ -636,6 +644,12 @@ lazy_static! {
.copy_from_slice(unsafe { .copy_from_slice(unsafe {
mem::transmute(VK_KHR_WIN32_SURFACE_EXTENSION_NAME as &[u8]) mem::transmute(VK_KHR_WIN32_SURFACE_EXTENSION_NAME as &[u8])
}); });
#[cfg(target_os = "macos")]
extensions[1]
.extensionName[..VK_MVK_MACOS_SURFACE_EXTENSION_NAME.len()]
.copy_from_slice(unsafe {
mem::transmute(VK_MVK_MACOS_SURFACE_EXTENSION_NAME as &[u8])
});
extensions.to_vec() extensions.to_vec()
}; };
@ -3901,3 +3915,27 @@ pub extern "C" fn gfxQueuePresentKHR(
VkResult::VK_SUCCESS VkResult::VK_SUCCESS
} }
#[inline]
pub extern "C" fn gfxCreateMacOSSurfaceMVK(
instance: VkInstance,
pCreateInfo: *const VkMacOSSurfaceCreateInfoMVK,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult {
assert!(pAllocator.is_null());
let info = unsafe { &*pCreateInfo };
#[cfg(target_os="macos")]
unsafe {
assert_eq!(info.flags, 0);
*pSurface = Handle::new(
instance.backend.create_surface_from_nsview(info.pView),
);
VkResult::VK_SUCCESS
}
#[cfg(not(target_os = "macos"))]
{
let _ = (instance, info, pSurface);
unreachable!()
}
}

View file

@ -288,8 +288,11 @@ pub const VK_KHR_SURFACE_SPEC_VERSION: ::std::os::raw::c_uint = 25;
pub const VK_KHR_SURFACE_EXTENSION_NAME: &'static [u8; 15usize] = pub const VK_KHR_SURFACE_EXTENSION_NAME: &'static [u8; 15usize] =
b"VK_KHR_surface\x00"; b"VK_KHR_surface\x00";
pub const VK_KHR_WIN32_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_WIN32_SURFACE_EXTENSION_NAME: &'static [u8; 21usize] = pub const VK_KHR_WIN32_SURFACE_EXTENSION_NAME: &'static [u8; 21usize] =
b"VK_KHR_win32_surface\x00"; b"VK_KHR_win32_surface\x00";
pub const VK_MVK_MACOS_SURFACE_EXTENSION_NAME: &'static [u8; 21usize] =
b"VK_MVK_macos_surface\x00";
pub const VK_KHR_swapchain: ::std::os::raw::c_uint = 1; pub const VK_KHR_swapchain: ::std::os::raw::c_uint = 1;
pub const VK_KHR_SWAPCHAIN_SPEC_VERSION: ::std::os::raw::c_uint = 68; pub const VK_KHR_SWAPCHAIN_SPEC_VERSION: ::std::os::raw::c_uint = 68;
pub const VK_KHR_SWAPCHAIN_EXTENSION_NAME: &'static [u8; 17usize] = pub const VK_KHR_SWAPCHAIN_EXTENSION_NAME: &'static [u8; 17usize] =
@ -4866,6 +4869,18 @@ pub struct VkXcbSurfaceCreateInfoKHR {
impl Clone for VkXcbSurfaceCreateInfoKHR { impl Clone for VkXcbSurfaceCreateInfoKHR {
fn clone(&self) -> Self { *self } fn clone(&self) -> Self { *self }
} }
pub type VkMacOSSurfaceCreateFlagsMVK = VkFlags;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct VkMacOSSurfaceCreateInfoMVK {
pub sType: VkStructureType,
pub pNext: *mut ::std::os::raw::c_void,
pub flags: VkMacOSSurfaceCreateFlagsMVK,
pub pView: *mut ::std::os::raw::c_void,
}
impl Clone for VkMacOSSurfaceCreateInfoMVK {
fn clone(&self) -> Self { *self }
}
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]
pub struct VkPhysicalDeviceFeatures2KHR { pub struct VkPhysicalDeviceFeatures2KHR {
@ -6919,3 +6934,10 @@ pub type PFN_vkCreateWin32SurfaceKHR = ::std::option::Option<unsafe extern "C" f
pAllocator: *const VkAllocationCallbacks, pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR, pSurface: *mut VkSurfaceKHR,
) -> VkResult>; ) -> VkResult>;
pub type PFN_vkCreateMacOSSurfaceMVK = ::std::option::Option<unsafe extern "C" fn(
instance: VkInstance,
pCreateInfo: *const VkMacOSSurfaceCreateInfoMVK,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult>;

View file

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