summaryrefslogtreecommitdiff
path: root/ext/webgpu/03_surface.js
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-03-16 19:29:32 -0400
committerGitHub <noreply@github.com>2023-03-17 00:29:32 +0100
commit35196eab279340376929dd75ed717ef4830e2fa9 (patch)
tree5aefff339ef50d3e89ff36422c90e929dea3897f /ext/webgpu/03_surface.js
parent3f031ad9af2d61671f8408632f31592ac4186926 (diff)
BREAKING(unstable): remove WebGPU (#18094)
This PR _**temporarily**_ removes WebGPU (which has behind the `--unstable` flag in Deno), due to performance complications due to its presence. It will be brought back in the future; as a point of reference, Chrome will ship WebGPU to stable on 26/04/2023. --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/webgpu/03_surface.js')
-rw-r--r--ext/webgpu/03_surface.js146
1 files changed, 0 insertions, 146 deletions
diff --git a/ext/webgpu/03_surface.js b/ext/webgpu/03_surface.js
deleted file mode 100644
index 2a391613c..000000000
--- a/ext/webgpu/03_surface.js
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-// @ts-check
-/// <reference path="../../core/lib.deno_core.d.ts" />
-/// <reference path="../web/internal.d.ts" />
-/// <reference path="../web/lib.deno_web.d.ts" />
-/// <reference path="./lib.deno_webgpu.d.ts" />
-
-const core = globalThis.Deno.core;
-const ops = core.ops;
-import * as webidl from "ext:deno_webidl/00_webidl.js";
-const primordials = globalThis.__bootstrap.primordials;
-const { Symbol } = primordials;
-import {
- _device,
- assertDevice,
- createGPUTexture,
-} from "ext:deno_webgpu/01_webgpu.js";
-
-const _surfaceRid = Symbol("[[surfaceRid]]");
-const _configuration = Symbol("[[configuration]]");
-const _canvas = Symbol("[[canvas]]");
-const _currentTexture = Symbol("[[currentTexture]]");
-class GPUCanvasContext {
- /** @type {number} */
- [_surfaceRid];
- /** @type {InnerGPUDevice} */
- [_device];
- [_configuration];
- [_canvas];
- /** @type {GPUTexture | undefined} */
- [_currentTexture];
-
- get canvas() {
- webidl.assertBranded(this, GPUCanvasContextPrototype);
- return this[_canvas];
- }
-
- constructor() {
- webidl.illegalConstructor();
- }
-
- configure(configuration) {
- webidl.assertBranded(this, GPUCanvasContextPrototype);
- const prefix = "Failed to execute 'configure' on 'GPUCanvasContext'";
- webidl.requiredArguments(arguments.length, 1, { prefix });
- configuration = webidl.converters.GPUCanvasConfiguration(configuration, {
- prefix,
- context: "Argument 1",
- });
-
- this[_device] = configuration.device[_device];
- this[_configuration] = configuration;
- const device = assertDevice(this, {
- prefix,
- context: "configuration.device",
- });
-
- const { err } = ops.op_webgpu_surface_configure({
- surfaceRid: this[_surfaceRid],
- deviceRid: device.rid,
- format: configuration.format,
- viewFormats: configuration.viewFormats,
- usage: configuration.usage,
- width: configuration.width,
- height: configuration.height,
- alphaMode: configuration.alphaMode,
- });
-
- device.pushError(err);
- }
-
- unconfigure() {
- webidl.assertBranded(this, GPUCanvasContextPrototype);
-
- this[_configuration] = null;
- this[_device] = null;
- }
-
- getCurrentTexture() {
- webidl.assertBranded(this, GPUCanvasContextPrototype);
- const prefix =
- "Failed to execute 'getCurrentTexture' on 'GPUCanvasContext'";
-
- if (this[_configuration] === null) {
- throw new DOMException(
- "context is not configured.",
- "InvalidStateError",
- );
- }
-
- const device = assertDevice(this, { prefix, context: "this" });
-
- if (this[_currentTexture]) {
- return this[_currentTexture];
- }
-
- const { rid } = ops.op_webgpu_surface_get_current_texture(
- device.rid,
- this[_surfaceRid],
- );
-
- const texture = createGPUTexture(
- {
- size: {
- width: this[_configuration].width,
- height: this[_configuration].height,
- depthOrArrayLayers: 1,
- },
- mipLevelCount: 1,
- sampleCount: 1,
- dimension: "2d",
- format: this[_configuration].format,
- usage: this[_configuration].usage,
- },
- device,
- rid,
- );
- device.trackResource(texture);
- this[_currentTexture] = texture;
- return texture;
- }
-
- // Extended from spec. Required to present the texture; browser don't need this.
- present() {
- webidl.assertBranded(this, GPUCanvasContextPrototype);
- const prefix = "Failed to execute 'present' on 'GPUCanvasContext'";
- const device = assertDevice(this[_currentTexture], {
- prefix,
- context: "this",
- });
- ops.op_webgpu_surface_present(device.rid, this[_surfaceRid]);
- this[_currentTexture].destroy();
- this[_currentTexture] = undefined;
- }
-}
-const GPUCanvasContextPrototype = GPUCanvasContext.prototype;
-
-function createCanvasContext(options) {
- const canvasContext = webidl.createBranded(GPUCanvasContext);
- canvasContext[_surfaceRid] = options.surfaceRid;
- canvasContext[_canvas] = options.canvas;
- return canvasContext;
-}
-
-export { createCanvasContext, GPUCanvasContext };