Skip to content

[GPU 15/20] Implement WebGL 2 and explicit application GPU fallback coverage #37

Open

Description

@danwalmsley

Parent epic: #22
Implementation order: 15 of 20.
Depends on: #36.

Outcome

Complete WebGL 2 and prove an application's WebGPU→WebGL2→WebGL1 selection without misrepresenting API fallback as automatic shader translation.

Implementation

  • Add WebGL2RenderingContext with WebGL 2 core methods/types/enums and conversions over qualified ANGLE ES3 contexts.
  • Implement VAOs, instancing, uniform buffers, samplers, multiple render targets, transform feedback, queries/syncs, 3D/array textures, multisample framebuffer operations, blits and expanded texture/format/readback rules.
  • Implement the differences between WebGL1 extensions and WebGL2 core behavior, including object ownership and supported extension reporting.
  • Build a separate deterministic fixture with independently authored WGSL and GLSL renderers showing equivalent visible output. It chooses WebGPU, then WebGL2, then WebGL1 based on standard discovery/creation results.
  • Exercise context locking: if a canvas already owns a context, fallback requiring a different mode uses a new canvas as the application must. Never mutate an existing context's API behind the app.
  • Add host policy and manifest-alternative tests that leave WebGL independently available when WebGPU is disabled or requestAdapter returns null.
  • Test mixed WebGPU/WebGL2/WebGL1/Canvas2D scenes, snapshots and exports. Keep Kestrel unchanged and retain its separate Canvas2D fallback gate.

Tests

  • Pinned WebGL2 conformance shards including indexed/instanced/transform-feedback draws, MRT, texture arrays and sync/query behavior.
  • Invalid formats/framebuffers, out-of-bounds accesses, wrong-context objects and loss/restoration.
  • Force each fallback branch and assert selected API, real pixels and zero ordinary CPU readback.
  • Device/context loss during application recovery; capability and extension truthfulness.
  • Mixed-canvas clipping, transparency, paint order and snapshot/export.

Verification evidence

Provide branch-by-branch fallback reports, actual backend identifiers, conformance results and reference image comparisons. Missing GPU hardware is unavailable, not fallback success.

Acceptance

  • WebGL 2 core behavior and extensions are accurately exposed.
  • Each fallback branch runs its own real renderer and produces verified pixels.
  • WebGL does not depend on Dawn/WebGPU availability.
  • Context locking/loss/recreation follow browser semantics.
  • Full WebGL1/2 conformance remains a required later release gate.

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