mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 08:51:31 +11:00
Using a RawWindowHandle with hal::create_surface for multi-backend compatibility
This commit is contained in:
parent
8ee8bb03bf
commit
84e95e539f
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -753,6 +753,7 @@ dependencies = [
|
||||||
"lazy_static 1.4.0",
|
"lazy_static 1.4.0",
|
||||||
"log",
|
"log",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
"raw-window-handle",
|
||||||
"renderdoc",
|
"renderdoc",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"typed-arena",
|
"typed-arena",
|
||||||
|
|
|
@ -27,6 +27,7 @@ parking_lot = "0.11"
|
||||||
smallvec = "1"
|
smallvec = "1"
|
||||||
renderdoc = { version = "0.3", optional = true }
|
renderdoc = { version = "0.3", optional = true }
|
||||||
typed-arena = "2"
|
typed-arena = "2"
|
||||||
|
raw-window-handle = "0.3"
|
||||||
|
|
||||||
[dependencies.hal]
|
[dependencies.hal]
|
||||||
package = "gfx-hal"
|
package = "gfx-hal"
|
||||||
|
|
|
@ -4716,17 +4716,33 @@ pub unsafe extern "C" fn gfxCreateXcbSurfaceKHR(
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
assert!(pAllocator.is_null());
|
assert!(pAllocator.is_null());
|
||||||
let info = &*pCreateInfo;
|
let info = &*pCreateInfo;
|
||||||
#[cfg(all(feature = "gfx-backend-vulkan", target_os = "linux"))]
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
assert_eq!(info.flags, 0);
|
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(
|
*pSurface = Handle::new(
|
||||||
instance
|
instance
|
||||||
.backend
|
.backend
|
||||||
.create_surface_from_xcb(info.connection, info.window),
|
.create_surface(&HandleWrapper(xcb_handle))
|
||||||
|
.unwrap(),
|
||||||
);
|
);
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
#[cfg(not(all(feature = "gfx-backend-vulkan", target_os = "linux")))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
{
|
{
|
||||||
let _ = (instance, info, pSurface);
|
let _ = (instance, info, pSurface);
|
||||||
unreachable!()
|
unreachable!()
|
||||||
|
|
Loading…
Reference in a new issue