mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
6d55d87be4
Part 1 of #21713 Changes: - Remove `.present()` and add a `presentGPUCanvasContext` (not exposed yet to users) - Move lazy load logic to `00_init.js`. This can be used to use webgpu on-demand from future code (OffScreenCanvas)
39 lines
681 B
JavaScript
39 lines
681 B
JavaScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { core } from "ext:core/mod.js";
|
|
const ops = core.ops;
|
|
|
|
let webgpu;
|
|
|
|
function webGPUNonEnumerable(getter) {
|
|
let valueIsSet = false;
|
|
let value;
|
|
|
|
return {
|
|
get() {
|
|
loadWebGPU();
|
|
|
|
if (valueIsSet) {
|
|
return value;
|
|
} else {
|
|
return getter();
|
|
}
|
|
},
|
|
set(v) {
|
|
loadWebGPU();
|
|
|
|
valueIsSet = true;
|
|
value = v;
|
|
},
|
|
enumerable: false,
|
|
configurable: true,
|
|
};
|
|
}
|
|
|
|
function loadWebGPU() {
|
|
if (!webgpu) {
|
|
webgpu = ops.op_lazy_load_esm("ext:deno_webgpu/01_webgpu.js");
|
|
}
|
|
}
|
|
|
|
export { loadWebGPU, webgpu, webGPUNonEnumerable };
|