Skip to content

fix: chrome shader varying-pack compatibility#20

Merged
chiefcll merged 1 commit into
mainfrom
fix/chrome-shader-varying-pack
May 19, 2026
Merged

fix: chrome shader varying-pack compatibility#20
chiefcll merged 1 commit into
mainfrom
fix/chrome-shader-varying-pack

Conversation

@chiefcll
Copy link
Copy Markdown
Contributor

Summary

  • Drops the v_edgeWidth and v_borderZero varyings from Border, RoundedWithBorder, and RoundedWithBorderAndShadow shaders and recomputes them as locals in the fragment shader.
  • Surfaces real link errors from createProgram instead of silently returning undefined.

Why

Older ANGLE/GLSL packers (Chrome 35-era TV browsers) reject these shader programs with Could not pack varying _v_borderZero / Could not pack varying _v_edgeWidth even though they nominally fit within MAX_VARYING_VECTORS=8. The stray float varyings refused to coalesce into the leftover scalar slot of a vec2-packed row. Moving them to fragment locals removes the packer ambiguity entirely — same render result, fewer slots needed.

Ports lightning-js/renderer#758 and adapts it to the local border-gap / border-align / border-fill shader variants that this fork carries. The upstream PR only touched RoundedWithBorder and RoundedWithBorderAndShadow; this PR additionally cleans up Border.ts for consistency since the same trivially-computable varying lived there.

Test plan

  • pnpm build — clean
  • pnpm test — 148/148 pass
  • Visual regression: run pnpm test:visual and verify shader-border*, shader-rounded*, and shader-shadow* snapshots are unchanged
  • Manual smoke test on a Chrome 35-era TV (or pnpm start:prod) — shader programs link without warnings

🤖 Generated with Claude Code

Drops the v_edgeWidth and v_borderZero varyings from Border,
RoundedWithBorder, and RoundedWithBorderAndShadow shaders and
recomputes them as locals in the fragment shader. Older ANGLE/GLSL
packers (e.g. Chrome 35 on TVs) reject these shaders with
"Could not pack varying _v_borderZero/_v_edgeWidth" even though
they nominally fit within MAX_VARYING_VECTORS=8.

Also surfaces real link errors from createProgram instead of
silently returning undefined.

Ports lightning-js/renderer#758 with the local border-gap/border-align
shader variants preserved, and additionally applies the same
v_edgeWidth removal to Border.ts for consistency.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@chiefcll chiefcll merged commit da5c77f into main May 19, 2026
1 check passed
@chiefcll chiefcll deleted the fix/chrome-shader-varying-pack branch May 19, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant