Repository navigation
feat(shaders): Add outline shader - #988
Open
wouterlucas wants to merge 2 commits into
Open
wouterlucas wants to merge 2 commits into
wouterlucas wants to merge 2 commits into
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.
Phase 3 of the L2-style fast paths: an explicit, opt-in outline
primitive for simple rectangles — not a transparent replacement for the
anti-aliased general Border shader, which is unchanged.
- New Outline shader (src/core/shaders/webgl/Outline.ts +
OutlineTemplate.ts, exported from exports/webgl-shaders.ts) with props
{ w = 0, color = 0xffffffff }: rectangular fill plus a uniform-width,
hard-edged, inside-aligned stroke via step()/mix() on interpolated
edge coordinates. No radius, gap or shadow; no u_dimensions, so
mixed-size nodes batch together.
- Dedicated OutlineBuffer (7 floats/vertex incl. a_dimensions, 112 B per
quad, capped at 16384 quads by the shared Uint16 index buffer) and
OutlineRenderOp; WebGlRenderer.addQuad routes nodes whose shader type
sets usesOutlineBuffer to this buffer. Full bufferData upload per pass
in render()/renderRTTNodes(). Canvas renderer falls back to the
default shader for this shader type.
- WebGlShaderType gains the usesOutlineBuffer flag; WebGlShaderNode and
WebGlShaderProgram carry the outline buffer/routing. Existing Border
and Default rendering paths are untouched.
Selection is explicit (shader: { type: Outline } via createShader);
plain rectangles keep the Default shader and border users keep Border.
Tests: WebGlRenderer.outline.test.ts (8). Full suite 569 passed on top
of phase 1, build clean, eslint 0 errors.
This branch has not been deployed
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.
Similar to L2 - simple rect step outline shader