diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index a19bb31c0c..d60d14beab 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -9096,11 +9096,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3139,
+ "line": 3165,
"character": 4
},
"end": {
- "line": 3139,
+ "line": 3165,
"character": 55
}
}
@@ -9114,11 +9114,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3309,
+ "line": 3335,
"character": 4
},
"end": {
- "line": 3309,
+ "line": 3335,
"character": 47
}
}
@@ -9150,11 +9150,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3117,
+ "line": 3143,
"character": 4
},
"end": {
- "line": 3120,
+ "line": 3146,
"character": 26
}
}
@@ -9168,11 +9168,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3287,
+ "line": 3313,
"character": 4
},
"end": {
- "line": 3290,
+ "line": 3316,
"character": 26
}
}
@@ -9186,11 +9186,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3413,
+ "line": 3439,
"character": 4
},
"end": {
- "line": 3413,
+ "line": 3439,
"character": 39
}
}
@@ -9204,11 +9204,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3576,
+ "line": 3602,
"character": 4
},
"end": {
- "line": 3576,
+ "line": 3602,
"character": 43
}
}
@@ -9222,11 +9222,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3625,
+ "line": 3651,
"character": 4
},
"end": {
- "line": 3625,
+ "line": 3651,
"character": 39
}
}
@@ -9240,11 +9240,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3744,
+ "line": 3770,
"character": 4
},
"end": {
- "line": 3744,
+ "line": 3770,
"character": 39
}
}
@@ -9258,11 +9258,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3897,
+ "line": 3923,
"character": 4
},
"end": {
- "line": 3897,
+ "line": 3923,
"character": 39
}
}
@@ -9276,11 +9276,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 4056,
+ "line": 4082,
"character": 4
},
"end": {
- "line": 4056,
+ "line": 4082,
"character": 43
}
}
@@ -9294,11 +9294,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3140,
+ "line": 3166,
"character": 4
},
"end": {
- "line": 3143,
+ "line": 3169,
"character": 31
}
}
@@ -9312,11 +9312,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3310,
+ "line": 3336,
"character": 4
},
"end": {
- "line": 3313,
+ "line": 3339,
"character": 31
}
}
@@ -9330,11 +9330,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3125,
+ "line": 3151,
"character": 4
},
"end": {
- "line": 3128,
+ "line": 3154,
"character": 30
}
}
@@ -9348,11 +9348,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3295,
+ "line": 3321,
"character": 4
},
"end": {
- "line": 3298,
+ "line": 3324,
"character": 30
}
}
@@ -9366,11 +9366,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3329,
+ "line": 3355,
"character": 2
},
"end": {
- "line": 3334,
+ "line": 3360,
"character": 4
}
}
@@ -9384,11 +9384,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3440,
+ "line": 3466,
"character": 2
},
"end": {
- "line": 3451,
+ "line": 3477,
"character": 4
}
}
@@ -9402,11 +9402,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3645,
+ "line": 3671,
"character": 2
},
"end": {
- "line": 3652,
+ "line": 3678,
"character": 4
}
}
@@ -9420,11 +9420,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3121,
+ "line": 3147,
"character": 4
},
"end": {
- "line": 3124,
+ "line": 3150,
"character": 31
}
}
@@ -9438,11 +9438,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3291,
+ "line": 3317,
"character": 4
},
"end": {
- "line": 3294,
+ "line": 3320,
"character": 31
}
}
@@ -9456,11 +9456,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.deno.unstable.d.ts",
"range": {
"start": {
- "line": 3926,
+ "line": 3952,
"character": 2
},
"end": {
- "line": 3939,
+ "line": 3965,
"character": 4
}
}
diff --git a/cli/tests/unit/webgpu_test.ts b/cli/tests/unit/webgpu_test.ts
index 7ac88dd804..b204c5e0b2 100644
--- a/cli/tests/unit/webgpu_test.ts
+++ b/cli/tests/unit/webgpu_test.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { assert, assertEquals } from "./test_util.ts";
+import { assert, assertEquals, assertThrows } from "./test_util.ts";
let isCI: boolean;
try {
@@ -227,6 +227,15 @@ Deno.test({
Deno.close(Number(resources[resources.length - 1]));
});
+Deno.test(function webgpuNullWindowSurfaceThrows() {
+ assertThrows(
+ () => {
+ // @ts-expect-error: runtime test for null handle
+ new Deno.UnsafeWindowSurface("cocoa", null, null);
+ },
+ );
+});
+
async function checkIsWsl() {
return Deno.build.os === "linux" && await hasMicrosoftProcVersion();
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index 827c95556f..f0f6f45716 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -3,6 +3,7 @@
///
///
///
+///
///
///
@@ -764,6 +765,31 @@ declare namespace Deno {
symbols: Const,
): DynamicLibrary;
+ /** **UNSTABLE**: New API, yet to be vetted.
+ *
+ * Creates a presentable WebGPU surface from given window and
+ * display handles.
+ *
+ * The parameters correspond to the table below:
+ *
+ * | system | winHandle | displayHandle |
+ * | ----------------- | ------------- | --------------- |
+ * | "cocoa" (macOS) | `NSView*` | - |
+ * | "win32" (Windows) | `HWND` | `HINSTANCE` |
+ * | "x11" (Linux) | Xlib `Window` | Xlib `Display*` |
+ *
+ * @category WebGPU
+ */
+ export class UnsafeWindowSurface {
+ constructor(
+ system: "cocoa" | "win32" | "x11",
+ windowHandle: UnsafePointerView,
+ displayHandle: UnsafePointerView | null,
+ );
+ getContext(context: "webgpu"): GPUCanvasContext;
+ present(): void;
+ }
+
/** **UNSTABLE**: New API, yet to be vetted.
*
* These are unstable options which can be used with {@linkcode Deno.run}.
diff --git a/cli/tsc/dts/lib.deno_webgpu.d.ts b/cli/tsc/dts/lib.deno_webgpu.d.ts
index f83ea5aa52..606c776341 100644
--- a/cli/tsc/dts/lib.deno_webgpu.d.ts
+++ b/cli/tsc/dts/lib.deno_webgpu.d.ts
@@ -1313,3 +1313,22 @@ declare interface GPUExtent3DDict {
/** @category WebGPU */
declare type GPUExtent3D = number[] | GPUExtent3DDict;
+
+/** @category WebGPU */
+declare type GPUCanvasAlphaMode = "opaque" | "premultiplied";
+
+/** @category WebGPU */
+declare interface GPUCanvasConfiguration {
+ device: GPUDevice;
+ format: GPUTextureFormat;
+ usage?: GPUTextureUsageFlags;
+ viewFormats?: GPUTextureFormat[];
+ colorSpace?: "srgb" | "display-p3";
+ alphaMode?: GPUCanvasAlphaMode;
+}
+/** @category WebGPU */
+declare interface GPUCanvasContext {
+ configure(configuration: GPUCanvasConfiguration): undefined;
+ unconfigure(): undefined;
+ getCurrentTexture(): GPUTexture;
+}