mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-22 23:11:30 +11:00
Merge #235
235: Using a RawWindowHandle with hal::create_surface for multi-backend compatibility r=kvark a=ElArtista Co-authored-by: TheArtist <agorglouk@gmail.com>
This commit is contained in:
commit
6a796a7ba1
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -753,6 +753,7 @@ dependencies = [
|
|||
"lazy_static 1.4.0",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"raw-window-handle",
|
||||
"renderdoc",
|
||||
"smallvec",
|
||||
"typed-arena",
|
||||
|
|
|
@ -27,6 +27,7 @@ parking_lot = "0.11"
|
|||
smallvec = "1"
|
||||
renderdoc = { version = "0.3", optional = true }
|
||||
typed-arena = "2"
|
||||
raw-window-handle = "0.3"
|
||||
|
||||
[dependencies.hal]
|
||||
package = "gfx-hal"
|
||||
|
|
|
@ -4716,17 +4716,33 @@ pub unsafe extern "C" fn gfxCreateXcbSurfaceKHR(
|
|||
) -> VkResult {
|
||||
assert!(pAllocator.is_null());
|
||||
let info = &*pCreateInfo;
|
||||
#[cfg(all(feature = "gfx-backend-vulkan", target_os = "linux"))]
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
assert_eq!(info.flags, 0);
|
||||
use raw_window_handle::{unix::XcbHandle, HasRawWindowHandle, RawWindowHandle};
|
||||
|
||||
struct HandleWrapper(XcbHandle);
|
||||
unsafe impl HasRawWindowHandle for HandleWrapper {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
RawWindowHandle::Xcb(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
let xcb_handle = XcbHandle {
|
||||
window: info.window,
|
||||
connection: info.connection,
|
||||
..XcbHandle::empty()
|
||||
};
|
||||
*pSurface = Handle::new(
|
||||
instance
|
||||
.backend
|
||||
.create_surface_from_xcb(info.connection, info.window),
|
||||
.create_surface(&HandleWrapper(xcb_handle))
|
||||
.unwrap(),
|
||||
);
|
||||
VkResult::VK_SUCCESS
|
||||
}
|
||||
#[cfg(not(all(feature = "gfx-backend-vulkan", target_os = "linux")))]
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
let _ = (instance, info, pSurface);
|
||||
unreachable!()
|
||||
|
|
Loading…
Reference in a new issue