summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tsc/dts/lib.deno.unstable.d.ts3
-rw-r--r--ext/webgpu/byow.rs45
2 files changed, 32 insertions, 16 deletions
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index 0c1ab8af0..0c20ec1b6 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -776,12 +776,13 @@ declare namespace Deno {
* | "cocoa" (macOS) | `NSView*` | - |
* | "win32" (Windows) | `HWND` | `HINSTANCE` |
* | "x11" (Linux) | Xlib `Window` | Xlib `Display*` |
+ * | "wayland" (Linux) | `wl_surface*` | `wl_display*` |
*
* @category WebGPU
*/
export class UnsafeWindowSurface {
constructor(
- system: "cocoa" | "win32" | "x11",
+ system: "cocoa" | "win32" | "x11" | "wayland",
windowHandle: Deno.PointerValue<unknown>,
displayHandle: Deno.PointerValue<unknown>,
);
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))
}