Repository navigation
Description
Summary
Tracking issue for the WebGL 2 features that became available once #1509 made the renderer WebGL 2 only. Kept as one ticket rather than five, because some of these are concrete cleanups and others enable capabilities we have not decided to build — splitting one out when it is actually picked up keeps the tracker honest about which is which.
Already split out
| Status | Item | Ticket |
|---|---|---|
| ✅ done (20.0, #1571) | InstancedMesh on both GPU backends, plus glTF EXT_mesh_gpu_instancing |
#1508 |
| ✅ done (20.0) | #1507 | |
| ✅ done (20.0, #1564) | #1511 | |
| ✅ done (20.0) | MAX_LIGHTS) |
#1552 |
| 🔶 half done | Shared frame-globals uniform buffer — the WebGPU backend ships this shape (bind-group-0 frame globals). The WebGL half is blocked on a compatibility promise, not merely unfinished: GL uniform blocks need GLSL ES 3.00 while user shaders are contractually ES 1.00 — written up in #1568, deliberately not scheduled | #1555 / #1568 |
| ✅ done (20.0, #1566) | #1554 | |
| ✅ done (20.0) | #1551 |
Concrete, no design question — ✅ both done (20.0, #1567)
. Allocate once with texStorage2D immutable textures + sized internal formatstexStorage2D, update with texSubImage2D. Immutable storage lets drivers skip per-upload completeness validation, and sized formats (RGBA8 etc.) remove format-inference guesswork. Touches MaterialBatcher.createTexture2D and therefore every upload path — compressed textures, FBO attachments, and the video re-upload path added in 19.9.1 — so it is a texture-pipeline change rather than an addition.
Done in #1567. Every non-resource texture allocates immutable sized storage once and updates through
texSubImage2D. The payoff turned out to be larger than the driver-validation saving this entry anticipated: a same-size content update (tickingText,Gradientre-bake, video frame) was creating a fresh texture object every time, becauseCanvasRenderTarget.invalidatedropped the batcher's binding record and sent the next upload down the allocate path. Invalidation now marks the unit content-dirty instead, so with the #1554 size buckets the steady state of dynamic text and gradients allocates nothing at all.
MSAA framebuffers via blitFramebuffer. renderbufferStorageMultisample + resolve-blit gives antialiased post-effect passes, which WebGL 1 could not do at all. Currently antiAlias only affects the default framebuffer, so any scene using post-effects loses edge AA. Changes what post-effect FBOs produce, so it needs visual re-baselining.
Done in #1567, on both GPU backends — it became a paired change once WebGPU shipped, since the same gap existed there. Post-effect capture targets are multisampled (4× color + depth-stencil renderbuffers resolved via
blitFramebufferon WebGL; a per-target multisampled texture resolved by the render pass on WebGPU); ping-pong intermediates stay 1×, since effect blits are screen-aligned quads with no geometric edges to antialias. The WebGPU multisampled half is per-target rather than shared, because nested effect brackets interleave passes and a mid-frame load-back would otherwise read another target's stored samples.toFrameTexture()resolves an active multisampled target before copying and rebinds it afterwards.The visual re-baselining this entry called for was done with a headed edge probe on both backends: with an effect active, MSAA now produces the identical intermediate-coverage signature as the no-effect control (3 distinct levels — the 4× quantization), while
antiAlias: falsemeasures a hard step. Cost is documented in the CHANGELOG: roughly 28 B/px extra on WebGL (~55 MB at 1080p) and ~16 B/px on WebGPU, allocated only whenantiAliasis on.
Speculative — enables features not yet decided
Multiple Render Targets (MRT). drawBuffers writing colour + normal + depth in one pass. The enabler for deferred lighting and G-buffer effects; only worth doing if we want those, since the current forward path is fine for 2D and light 3D.
Texture arrays / 3D textures. TEXTURE_2D_ARRAY would let the GPU tilemap sample one array instead of juggling several atlases, and would relieve the texture-unit pressure that TextureCache works around today. Interacts with #1410 (renderer-agnostic texture cache) — worth designing together rather than separately.
Transform feedback. Capture vertex-shader output into a buffer; the groundwork for GPU skinning and GPU particle simulation. Note #1404 already covers GPU-instanced particles by a different route.
What is left
Everything concrete on this tracker is now done. What remains is #1568
(the GL frame-globals variant, deferred by decision — it is blocked on the
ES 1.00 user-shader guarantee, not merely unfinished) and the three
speculative items below. None are scheduled, and two of them (texture
arrays, MRT) are worth designing against #1410 / the WebGPU backend rather
than in isolation.
Notes
- Everything here is additive and non-breaking, so none of it needs a major version.
- Several items overlap the WebGPU port (WebGPU renderer #1184): MRT, texture arrays and transform feedback all have direct WebGPU equivalents, so implementing them in GL first informs the backend-neutral abstraction (Refactor TextureCache and Batcher base class for renderer-agnostic abstraction #1410 / [WebGPU port] Backend-neutral vertex layout descriptor #1492) rather than duplicating work.
Unblocked by #1509.
Activity
obiot commentedon Aug 6, 2026
Status update now that #1564 (the WebGPU backend completion) is merged:
texStorage2D+ sized formats and MSAA post-effect FBOs are still open. Note the MSAA item is now naturally a paired change: WebGPU has 4× MSAA on canvas passes since WebGPU 3D tier + full backend parity, spine on WebGPU — 20.0.0 (#1184, #1536) #1564, but offscreen post-effect targets deliberately stay single-sampled on both backends for parity — picking this up means multisampled offscreen targets + resolve on both, with the same visual re-baselining caveat.One correction to the Notes section: "implementing them in GL first informs the backend-neutral abstraction" has inverted since the WebGPU backend shipped. MRT, texture arrays and transform feedback all have first-class WebGPU counterparts (transform feedback's modern equivalent being compute), so these should now be designed WebGPU-first with the GL implementation following — the same principle the 20.0 renderer work followed. Texture arrays in particular should be designed together with #1410 (renderer-agnostic texture cache), which is next on the 20.0 cleanup list.
obiot commentedon Aug 6, 2026
Update: #1554 shipped in #1566 (superseding the note above that listed it as open). As re-scoped, gradients now bake into a fixed 256×256 shared target — allocated once, never resized, every re-bake a same-size texture update, memory capped, verified pixel-identical on all three backends — and Text canvases round to 32-pixel grow-only buckets instead of powers of two (waste bounded at 31 px per axis). The structural follow-up (dynamic glyph atlas, so text changes allocate nothing) is #1565, gated on #1410.
Remaining from this tracker: #1508 (instancing) and the WebGL half of #1555 among the split-outs, plus the items listed in the body (
texStorage2D+ sized formats, MSAA post-effect targets — now naturally a paired both-backends change — and the three speculative WebGPU-first items).Immutable texture storage + MSAA that survives post effects (#1556) (#…
obiot commentedon Aug 6, 2026
Both concrete items are done and merged for 20.0 in #1567 —
ee0e93444. They landed together because they touch the same texture / render-target machinery, and the MSAA half turned out to be a two-backend change rather than a WebGL one.texStorage2D+ sized formats. The anticipated win (drivers skipping per-upload completeness validation) is real but driver-dependent and too small to isolate in-frame, so no number is claimed for it. The unanticipated one is larger and structural: same-size content updates were allocating a new texture object every time.CanvasRenderTarget.invalidatediscarded the batcher's binding record, so the next upload took the allocate path — meaning a score counter updating every frame cycled ~60 texture allocations per second through the driver. Invalidation now marks the unit content-dirty, the upload lands as a puretexSubImage2D, and combined with the #1554 buckets the dynamic-text/gradient steady state allocates nothing. Found because a test asserted the cheap path and failed.MSAA under post effects. Verified rather than assumed: a headed edge probe on both backends counts intermediate edge intensities across
antiAlias× post-effect combinations. With an effect active the coverage signature is now identical to the no-effect control on both backends (3 distinct levels, the 4× quantization);antiAlias: falsemeasures a hard step. The memory cost is documented in the CHANGELOG rather than left implicit — ~28 B/px on WebGL (≈55 MB at 1080p), ~16 B/px on WebGPU where the multisampled depth attachment is shared with the canvas, and nothing at all whenantiAliasis off.On the #1555 row. The GL half is not simply unfinished work: GL uniform blocks require GLSL ES 3.00, and
ShaderEffectbodies / rawGLShadersources are contractually ES 1.00 — a guarantee reaffirmed in the 20.0 upgrade notes. A full conversion would break user shaders; only a built-ins-only variant is viable, and it costs maintaining two forms of the same globals. Since frame globals upload once per shader-program switch (not per draw), the win is modest and should be measured before the complexity is taken on. Written up as #1568 and deliberately left unscheduled.That leaves #1508, #1568 and the three speculative items on this tracker, none of them scheduled.
obiot commentedon Aug 7, 2026
Mesh instancing (#1508) is merged for 20.0 —
ed2f8d3d8, via #1571. That was the last concrete item on this tracker.InstancedMeshdraws one geometry many times in a single call on both GPU backends, and glTFEXT_mesh_gpu_instancingloads authored scatters with no user code (static and animated paths alike). The new Instanced Forest example renders 100 000 trees from one 52-vertex geometry in onedrawElementsInstanced, at 60 fps on WebGL and WebGPU — though that figure is vsync-capped, so it says "not the bottleneck" rather than establishing a limit.Two things are worth recording here rather than leaving in the PR:
The refactor underneath was the risky part, not the feature. Both backends assumed a single vertex buffer;
WebGLVertexStateand the WebGPU pipeline cache now take a list of buffer layouts with step modes. Existing callers stay byte-identical by construction — divisors are only issued for instance groups, and WebGPU omitsstepModefor vertex groups since that is the default — and that is pinned by tests rather than asserted in a comment. Every batcher on the GL backend depends on this file, so the 41 pre-existing VAO tests were kept passing unedited as the baseline.Three independent code reviews found six bugs the tests could not. The suite asserted CPU-side records and GL call counts, which is structurally blind to "the right call, made with the wrong state". The most instructive: the group was frustum-culled by the prototype's bounding box, because
Camera3dculls ongetBounds()and never ongetBounds3d()— so a scatter spanning thousands of units presented an ~80 px sphere and the entire forest vanished the moment the group origin left the frustum. MygetBounds3d()union was dead code whose doc comment claimed otherwise. Also found:draw()ignoring the viewport, a custom shader able to leave the transform rows unbound (singular matrix, mesh collapses to a point), one dirty span drained by whichever batcher drew first, recycled slots inheriting the dead instance's emissive, and one animation clip anywhere in an asset silently dropping all instancing. All fixed with regression tests that fail against the reviewed code.Remaining on this tracker: #1568 (deferred by decision — blocked on the ES 1.00 user-shader guarantee, not merely unfinished) and the three speculative items. Nothing scheduled.
obiot commentedon Aug 7, 2026
Closing: every concrete item on this tracker is done, and the remaining ones have been given proper homes.
Shipped for 20.0 — #1507 (retained mesh), #1511 (mipmaps + anisotropy), #1552 (light uniform buffer, 8 → 32 lights), #1551 (backend-neutral vertex formats), #1554 (gradient/text texture sizing), #1508 (mesh instancing), plus the two items that lived only in this issue's body:
texStorage2Dimmutable textures with sized formats, and MSAA framebuffers that survive post-effect chains.Not closed, deliberately — each now has a home:
drawBuffers— the enabler for deferred lighting and G-buffer effects, with a direct WebGPU equivalent. Genuinely undecided and not worth a placeholder ticket; it belongs with the backend work if and when deferred shading is wanted. Searchable here in the meantime.Keeping this open solely for three undecided ideas would misrepresent the WebGL-2 baseline work as unfinished when it is not. Reopen or split one out if any of them becomes real.
example(afterBurner): enable 4x MSAA
example(afterBurner): no ground shadows, and enable 4x MSAA