-
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathinit_webgpu.js
More file actions
68 lines (64 loc) · 2.59 KB
/
Copy pathinit_webgpu.js
File metadata and controls
68 lines (64 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { core } from 'ext:core/mod.js';
import { loadWebGPU } from 'ext:deno_webgpu/00_init.js';
import { GPUCanvasContext, UnsafeWindowSurface } from 'ext:deno_webgpu/02_surface.js';
const lazy = (name) =>
core.propNonEnumerableLazyLoaded((webgpu) => webgpu[name], loadWebGPU);
Object.defineProperties(globalThis, {
GPU: lazy('GPU'),
GPUAdapter: lazy('GPUAdapter'),
GPUAdapterInfo: lazy('GPUAdapterInfo'),
GPUBindGroup: lazy('GPUBindGroup'),
GPUBindGroupLayout: lazy('GPUBindGroupLayout'),
GPUBuffer: lazy('GPUBuffer'),
GPUBufferUsage: lazy('GPUBufferUsage'),
GPUColorWrite: lazy('GPUColorWrite'),
GPUCommandBuffer: lazy('GPUCommandBuffer'),
GPUCommandEncoder: lazy('GPUCommandEncoder'),
GPUCompilationInfo: lazy('GPUCompilationInfo'),
GPUCompilationMessage: lazy('GPUCompilationMessage'),
GPUComputePassEncoder: lazy('GPUComputePassEncoder'),
GPUComputePipeline: lazy('GPUComputePipeline'),
GPUDevice: lazy('GPUDevice'),
GPUDeviceLostInfo: lazy('GPUDeviceLostInfo'),
GPUError: lazy('GPUError'),
GPUExternalTexture: lazy('GPUExternalTexture'),
GPUInternalError: lazy('GPUInternalError'),
GPUMapMode: lazy('GPUMapMode'),
GPUOutOfMemoryError: lazy('GPUOutOfMemoryError'),
GPUPipelineLayout: lazy('GPUPipelineLayout'),
GPUQuerySet: lazy('GPUQuerySet'),
GPUQueue: lazy('GPUQueue'),
GPURenderBundle: lazy('GPURenderBundle'),
GPURenderBundleEncoder: lazy('GPURenderBundleEncoder'),
GPURenderPassEncoder: lazy('GPURenderPassEncoder'),
GPURenderPipeline: lazy('GPURenderPipeline'),
GPUSampler: lazy('GPUSampler'),
GPUShaderModule: lazy('GPUShaderModule'),
GPUShaderStage: lazy('GPUShaderStage'),
GPUSupportedFeatures: lazy('GPUSupportedFeatures'),
GPUSupportedLimits: lazy('GPUSupportedLimits'),
GPUTexture: lazy('GPUTexture'),
GPUTextureUsage: lazy('GPUTextureUsage'),
GPUTextureView: lazy('GPUTextureView'),
GPUUncapturedErrorEvent: lazy('GPUUncapturedErrorEvent'),
GPUValidationError: lazy('GPUValidationError'),
GPUCanvasContext: core.propNonEnumerable(GPUCanvasContext),
});
if (typeof globalThis.navigator !== 'object' || globalThis.navigator === null) {
Object.defineProperty(globalThis, 'navigator', {
configurable: true,
enumerable: true,
writable: true,
value: {},
});
}
Object.defineProperty(globalThis.navigator, 'gpu', {
configurable: true,
enumerable: true,
get() {
const webgpu = loadWebGPU();
webgpu.initGPU();
return webgpu.gpu;
},
});
globalThis.Deno.UnsafeWindowSurface = UnsafeWindowSurface;