Repository navigation
feat(webgl): cache vertex attribute state per VAO and reuse per-program VAOs - #986
Merged
wouterlucas merged 1 commit intoNov 26, 2026
Conversation
…am VAOs Phase 1 of the L2-style fast paths: behavior-preserving reduction of redundant WebGL attribute setup. - WebGlContextWrapper now keeps per-VAO shadow state (enable flags, full vertexAttribPointer parameter sets, element-buffer binding) and skips native calls when the effective state is unchanged. The ARRAY_BUFFER bind still happens before a skipped pointer call. deleteBuffer/deleteVertexArray invalidate the shadow tables; the constructor seeds them from the live context; context restoration recreates the wrapper, so no stale GL assumptions survive. - WebGlShaderProgram owns a lazily created VAO on WebGL2 and configures it once per BufferCollection layout (identity + layout version), so rebinding the same layout issues zero enable/pointer calls in steady state. WebGL1 keeps the per-attribute path, backed by the wrapper shadow state. detach() unbinds the VAO instead of disabling attributes; destroy() deletes it. - BufferCollection gains a layout version (invalidateLayout) so caches keyed on (collection, version) reconfigure on real layout changes. - createIndexBuffer returns the shared index buffer, stored on the renderer so each program VAO can bind it (ELEMENT_ARRAY_BUFFER is captured per VAO in WebGL2). Tests: WebGlContextWrapper.attribState.test.ts (8) and WebGlShaderProgram.vao.test.ts (4). Full suite 561 passed, build clean.
jfboeve
approved these changes
Nov 26, 2026
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.
Apply fast paths: behavior-preserving reduction of redundant WebGL attribute setup.