Skip to content

Commit f87a2b9

Browse files
committed
webgpu: ensure instaceof checks work
Some webgpu libraries use `instaceof`checks on objects returned from the API. Ensure that these work for some objects.
1 parent baf7c0b commit f87a2b9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/workerd/api/global-scope.h

+5
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ class ServiceWorkerGlobalScope: public WorkerGlobalScope {
491491

492492
#ifdef WORKERD_EXPERIMENTAL_ENABLE_WEBGPU
493493
// WebGPU
494+
JSG_NESTED_TYPE_NAMED(api::gpu::GPUAdapter, GPUAdapter);
495+
JSG_NESTED_TYPE_NAMED(api::gpu::GPUOutOfMemoryError, GPUOutOfMemoryError);
496+
JSG_NESTED_TYPE_NAMED(api::gpu::GPUValidationError, GPUValidationError);
497+
JSG_NESTED_TYPE_NAMED(api::gpu::GPUInternalError, GPUInternalError);
498+
JSG_NESTED_TYPE_NAMED(api::gpu::GPUDeviceLostInfo, GPUDeviceLostInfo);
494499
JSG_NESTED_TYPE_NAMED(api::gpu::GPUBufferUsage, GPUBufferUsage);
495500
JSG_NESTED_TYPE_NAMED(api::gpu::GPUShaderStage, GPUShaderStage);
496501
JSG_NESTED_TYPE_NAMED(api::gpu::GPUMapMode, GPUMapMode);

src/workerd/api/gpu/webgpu-errors-test.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const read_sync_stack = {
99

1010
const adapter = await navigator.gpu.requestAdapter();
1111
ok(adapter);
12+
ok(adapter instanceof GPUAdapter);
1213

1314
const device = await adapter.requestDevice();
1415
ok(device);

0 commit comments

Comments
 (0)