Skip to content

Webgpu regression with deno 2.2 #28207

Open
Open
@sigmaSd

Description

import { EventType, WindowBuilder } from "jsr:@divy/[email protected]";
console.log("Hello, World!");

const width = 800;
const height = 600;

const win = new WindowBuilder("Hello, World!", width, height).build();

const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
  console.error("WebGPU not supported!");
  Deno.exit(1);
}
const device = await adapter.requestDevice();

/* Returns a Deno.UnsafeWindowSurface */
const surface = win.windowSurface(width, height);
/* Returns a WebGPU GPUCanvasContext */
const context = surface.getContext("webgpu");

context.configure({
  device,
  format: navigator.gpu.getPreferredCanvasFormat(),
}); // panics here

for await (const event of win.events()) {
  if (event.type === EventType.Quit) break;
  if (event.type !== EventType.Draw) continue;

  // Sine wave
  const r = Math.sin(Date.now() / 1000) / 2 + 0.5;
  const g = Math.sin(Date.now() / 1000 + 2) / 2 + 0.5;
  const b = Math.sin(Date.now() / 1000 + 4) / 2 + 0.5;

  const textureView = context.getCurrentTexture().createView();

  const commandEncoder = device.createCommandEncoder();
  const passEncoder = commandEncoder.beginRenderPass({
    colorAttachments: [
      {
        view: textureView,
        clearValue: { r, g, b, a: 1.0 },
        loadOp: "clear",
        storeOp: "store",
      },
    ],
  });
  passEncoder.end();

  device.queue.submit([commandEncoder.finish()]);
  surface.present();
}

deno -A --unstable-webgpu a.ts

works with deno 2.1.10

errors with deno 2.2

error: Uncaught (in promise) Error: Surface image is already acquired
  surface.present();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions