Include hasWarn and textures in the shader rebuild key#59
Closed
kmatzen wants to merge 1 commit into
Closed
Conversation
This was referenced Jul 18, 2026
Fixes #55. The rebuild decision compared only glsl and paramCount, but rebuild() bakes two more inputs into the material: hasWarn selects the fragment source via buildFrag, and each texture becomes a uniform. An evaluation producing identical GLSL and param count but a different hasWarn therefore never reached the GPU, leaving the thin-wall highlight showing the previous evaluation's state. Correction to the issue as I filed it: the textures half is latent, not live. codegen declares `textures`, resets it, and returns it, but nothing ever pushes to it, and nothing else in src/worker/sdf references textures -- so sdf.textures is always [] at runtime and cannot currently go stale. Only hasWarn is a live bug. The texture key is included anyway: it costs nothing while the array is empty, and it means the key is already correct when textures get wired up rather than being a trap waiting for that change. The texture key hashes content (FNV-1a) rather than just dimensions, so a content edit at unchanged width/height still invalidates. Tests fail 2/3 against the base branch. The third asserts that an identical display does NOT rebuild, which both satisfy -- it guards against over-invalidating, since each rebuild recompiles a shader and disposes the previous one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kmatzen
force-pushed
the
fix-gpu-resource-leak
branch
from
July 25, 2026 16:38
0501983 to
bef0825
Compare
kmatzen
force-pushed
the
fix-shader-rebuild-key
branch
from
July 25, 2026 16:38
c6ebbdd to
405f63f
Compare
Owner
Author
|
Can't reopen this — GitHub refuses (HTTP 422) because the head branch was force-pushed (rebased onto main) after the PR auto-closed. Re-filed as #67 with the same commit and body. Closing the loop here. |
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.
Fixes #55. Stacked on #57 — base is
fix-gpu-resource-leak, so this shows only its own diff and will retarget tomainwhen #57 merges.The rebuild decision compared only
glslandparamCount:but
rebuild()bakes two more inputs into the material —hasWarnselects the fragment source viabuildFrag(sdf.glsl, sdf.paramCount, sdf.hasWarn), and each texture becomes a uniform. An evaluation producing identical GLSL and param count but a differenthasWarntherefore never reached the GPU, leaving the thin-wall highlight showing the previous evaluation's state.Correction to the issue as I filed it
The textures half is latent, not live.
codegen.tsdeclarestextures(:6), resets it (:324), and returns a copy (:352), but nothing ever pushes to it:Nothing else in
src/worker/sdf/mentions textures. Sosdf.texturesis always[]at runtime and a texture-only change cannot currently produce a stale render. I over-claimed a user-visible symptom that can't presently occur, and have said so on the issue rather than quietly narrowing the fix.Only
hasWarnis a live bug. The texture key is included anyway — it costs nothing while the array is empty, and it means the key is already correct whenever textures get wired up, rather than being a trap waiting for that change. It hashes content (FNV-1a) rather than just dimensions, so a content edit at unchanged width/height still invalidates.Verification
tsc --noEmitSdfMeshtests, this branchThe test that passes on both asserts an identical display does not rebuild. That guards the opposite direction: each rebuild recompiles a shader and (after #57) disposes the previous one, so an over-eager key would trade a stale-render bug for a churn bug.
🤖 Generated with Claude Code