Skip to content

Tracking issue for using WebGPU to render on the window of the desktop environment #23563

Open
@chirsz-ever

Description

So far we have WebGPU and BYOW, but it need more work to use the front-end graphics ecology.

Repository for testing and integrating: https://github.com/chirsz-ever/deno-webgpu-window-demos

Seamlessly use WebGPU-backended frameworks

Bugs and requirements

Creating and managing native windows

We already have deno_sdl2 and dwm for creating windows. But they rely on third-party libraries SDL2 and GLFW.

Maybe we need some methods to create windows without any third-party libraries? I have two ideas:

  • import winit and design a set of interfaces to use it;1
  • only write JavaScript code, use FFI to create window on respective platform, as a third-party library.

The first idea is easier to implement, but add a built-in component increases deno's compatibility costs and technical debt.

Canvas, CanvasRenderingContext2D and WebGL

Related issues: #5701 #1629

If deno support Canvas, CanvasRenderingContext2D and WebGL, it would be more easy to use front-end graphics libraries.

Deno.UnsafeWindowSurface is analog to Canvas, and it can use getContext("webgpu") to create a GPUCanvasContext. It is worthwhile to support other contexts, getContext("2d"), getContext("webgl"), getContext("webgl2") and getContext("bitmaprenderer").

How to implement CanvasRenderingContext2D (Canvas.getContext("2d"))? There are many methods in #5701, which mostly introduces skia or similar graphics libraries like Vello.

For WebGL, we can just use the native OpenGL implementation (gluton)[https://github.com/deno-windowing/gluten], or import ANGLE to maximize compliance of the WebGL standard.1

Maybe we can do something named "Canvas2D over WebGPU" and "WebGL over WebGPU", which only use JavaScript to implement CanvasRenderingContext2D and WebGL with WebGPU.

If we resolve all above, implementing OffscreenCanvas and ImageBitmapRenderingContext (Canvas.getContext("bitmaprenderer")) seems not hard.

Footnotes

  1. Removed by https://github.com/denoland/deno/issues/23563#issuecomment-2077777430 2

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions