Skip to content

[GPU 10/20] Implement WebGPU rendering, canvas presentation and Kestrel pipelines #32

Open

Description

@danwalmsley

Parent epic: #22
Implementation order: 10 of 20.
Depends on: #31.

Outcome

Run Kestrel's production WGSL and rendering commands unchanged into GPU-resident canvases inside both presenters.

Implementation

  • Implement createShaderModule and compilation information, render pipeline creation (including the required async path), render/command encoders, render passes, texture views and queue write/submit operations.
  • Implement exclusive getContext('webgpu'), GPUCanvasContext configure/unconfigure/getConfiguration/getCurrentTexture, current-texture identity/expiry and resize semantics according to the pinned spec. Public canvas APIs must not expose a native swapchain.
  • Integrate current textures with versioned canvas image leases and presentation publication. Preserve configure format/usage/alpha/color settings while keeping any required internal allocation usage private.
  • Implement vertex layouts/step modes, uniform bindings, blending, depth comparison/bias, multisampling, render-pass clear/load/store, resolve targets and instanced/non-instanced drawing.
  • Execute Kestrel's exact WGSL: 48-byte line instances, 40-byte mesh vertices, 96-byte camera uniform, line/mesh/x-ray pipelines, depth24plus and sample count 4. Do not rewrite application shaders to conceal backend failures.
  • Preserve call-time queue.writeBuffer data and retained geometry/pipeline resources. Camera pans should update uniforms, not cause full geometry reuploads.
  • Add relevant native/V8 and presented-pixel tests before enabling a Kestrel preview support claim.

Tests

  • Real antialiased instanced lines, shaded triangles, depth occlusion, MSAA resolve, all four styles and both themes.
  • Invalid WGSL, invalid entry points/layouts/formats, wrong-device objects and pass/encoder misuse.
  • Repeated current-texture calls, configure/unconfigure, bitmap resize and expired texture behavior.
  • Multiple GPU canvases with Canvas2D overlays and DOM on both presenters.
  • Coordinates near 1e9 using unchanged Kestrel camera-relative rendering.

Verification evidence

Attach WGSL compilation output, validation results, actual presented pixel images and command/upload counters. Distinguish successful GPU rendering from Canvas2D fallback or offscreen-only output.

Acceptance

  • Unchanged Kestrel production pipelines render correctly through native V8.
  • Correct canvas texture lifecycle, four-sample resolve and depth behavior.
  • Geometry remains retained across unchanged/camera-only frames.
  • Both presenters display GPU output with zero ordinary CPU readback.
  • Invalid inputs produce appropriate failures rather than silent success.

Completion requirements

Link the implementation PR, exact test commands, native/runtime/framework revisions and verification artifacts before closing. Follow the epic's architecture and copy/lifetime invariants. Any unavailable mandatory hardware or missing required functionality remains incomplete, not a pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions