diff options
author | chirsz <chirsz-ever@outlook.com> | 2024-04-25 12:28:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 09:58:16 +0530 |
commit | 1de162f1c1ef0ea9a2b653bc29cd0e3e00386abd (patch) | |
tree | a72a8346a158f9095214495226d827e1c60e8765 /ext/webgpu/byow.rs | |
parent | f3284529f1689f1294929eb17c55ddf088f3d3bb (diff) |
feat(ext/webgpu): support `UnsafeWindowSurface` on wayland (#23423)
Diffstat (limited to 'ext/webgpu/byow.rs')
-rw-r--r-- | ext/webgpu/byow.rs | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/ext/webgpu/byow.rs b/ext/webgpu/byow.rs index 984eaae1b..30824c52b 100644 --- a/ext/webgpu/byow.rs +++ b/ext/webgpu/byow.rs @@ -105,23 +105,38 @@ fn raw_window( window: *const c_void, display: *const c_void, ) -> Result<RawHandles, AnyError> { - if system != "x11" { + let (win_handle, display_handle); + if system == "x11" { + win_handle = { + let mut handle = raw_window_handle::XlibWindowHandle::empty(); + handle.window = window as *mut c_void as _; + + raw_window_handle::RawWindowHandle::Xlib(handle) + }; + + display_handle = { + let mut handle = raw_window_handle::XlibDisplayHandle::empty(); + handle.display = display as *mut c_void; + + raw_window_handle::RawDisplayHandle::Xlib(handle) + }; + } else if system == "wayland" { + win_handle = { + let mut handle = raw_window_handle::WaylandWindowHandle::empty(); + handle.surface = window as _; + + raw_window_handle::RawWindowHandle::Wayland(handle) + }; + + display_handle = { + let mut handle = raw_window_handle::WaylandDisplayHandle::empty(); + handle.display = display as _; + + raw_window_handle::RawDisplayHandle::Wayland(handle) + }; + } else { return Err(type_error("Invalid system on Linux")); } - let win_handle = { - let mut handle = raw_window_handle::XlibWindowHandle::empty(); - handle.window = window as *mut c_void as _; - - raw_window_handle::RawWindowHandle::Xlib(handle) - }; - - let display_handle = { - let mut handle = raw_window_handle::XlibDisplayHandle::empty(); - handle.display = display as *mut c_void; - - raw_window_handle::RawDisplayHandle::Xlib(handle) - }; - Ok((win_handle, display_handle)) } |