feat(webgl): add disableVertexArrayObject setting to toggle VAOs#77
Merged
Conversation
Adds a RendererMainSettings.disableVertexArrayObject option (default false) that forces the per-draw attribute-binding path even when VAOs are available. It's a diagnostic/benchmarking switch for A/B-ing the VAO optimization on a target device; no effect on the Canvas renderer. Plumbed like forceWebGL2: RendererMain settings -> Stage -> CoreRendererOptions -> WebGlRenderer -> WebGlContextWrapper, where it gates canUseVertexArrayObject (isWebGl2 still reflects the real context). The example harness reads `?novao=true` and feeds the setting, so the debug overlay can show the difference live. Verified on stress-multi-texture (WebGL1): toggling novao flips VAO:on->off, vertexAttribPointer/enableVertexAttribArray jump from 0 to ~4x the draw count each, bindVertexArray drops to 0, and total GL calls per interval rise ~2.5x. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
RendererMainSettings.disableVertexArrayObjectoption (defaultfalse) that forces the per-draw attribute-binding path even when VAOs are available. It's a diagnostic / benchmarking switch for A/B-ing the VAO optimization on real hardware — no effect on the Canvas renderer.The example harness reads
?novao=trueand feeds the setting, so the?debug=trueoverlay shows the difference live on a device.Plumbing
Mirrors
forceWebGL2:RendererMainsettings →Stage→CoreRendererOptions→WebGlRenderer→WebGlContextWrapper, where it gatescanUseVertexArrayObject.isWebGl2still reflects the real context — the flag only controls VAO usage, and the create/bind/delete methods stay capability-based (they're never reached when the gate is off).Verified on real hardware behavior
stress-multi-textureon WebGL1, same scene (~303 draws), togglingnovao:VAO:onVAO:offvertexAttribPointerenableVertexAttribArraybindVertexArraydrawElements73,924 / 18,481 ≈ 4confirms 4vertexAttribPointer+ 4enableVertexAttribArrayper draw return when VAOs are off — the 8 attribute calls/draw the VAO collapses into onebindVertexArray.Testing
pnpm build,pnpm lintclean;pnpm test314/314 — addedWebGlContextWrapper.test.ts(mock-GL unit test) covering: VAOs enabled with the OES extension, disabled without it, and forced off by the flag even when supported.?novao=trueoverlay A/B above.Why it's useful
On a draw-call-bound device (e.g. a TV where per-draw GL cost is ~100µs), this lets you measure the VAO FPS delta directly — run a draw-call-heavy scene with and without
novaoand read it off the overlay. On a fill-bound / vsync-capped setup the GL-call count drops ~2.5× but FPS won't move, which the toggle also makes obvious.🤖 Generated with Claude Code