You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LEGACY_GL_EMULATION: duplicate-texture-load regex truncates sample expressions when a texture matrix is active (invalid GLSL for COMBINE shaders) #27946
and the lazy .*? stops at the first) — inside the matrix parentheses — capturing the truncated prefix texture2D(u_texUnit0, (u_textureMatrix0 * v_texCoord0). The following
lines=lines.split(texLoadExpr).join(texLoadVar);
replaces that prefix everywhere and leaves the dangling .xy) fragments behind, producing GLSL that fails to compile. Any GL_COMBINE environment that references the texture more than once (MODULATE, INTERPOLATE, …) combined with a non-identity texture matrix produces a broken fragment shader, so entire scenes render with the pink/unlinked-program fallback.
Also
The regex is re-created after a substitution as /(texture.*\(.*\))/g — a greedy variant inconsistent with the first, which over-captures when one line contains two loads.
Suggested fix
Extract the expression with balanced-parenthesis scanning, or skip the hoist when the match contains an unbalanced (. (Our ship workaround post-processes the generated JS to disable the cache entirely; the hoist is only an optimization.)
Yes, the sentinel works. I made a minimal repro: two GL_COMBINE setups that use the texture more than once, one with two loads on a single line and one with INTERPOLATE, drawn with a texture matrix set. Without the change, the generated shader fails to compile (texload0 = texture2D(u_texUnit0, (u_textureMatrix0 * v_texCoord0);). With your diff it compiles and draws the right colours on Chrome/ANGLE Metal and SwiftShader. The leftover /*endload*/ comments after merging are harmless. PR with your diff plus that test: #28061.
Activity
juj commentedon Oct 14, 2026
Could a super-simple sentinel comment work here as a fix?
TheTomBritton commentedon Oct 23, 2026
Yes, the sentinel works. I made a minimal repro: two GL_COMBINE setups that use the texture more than once, one with two loads on a single line and one with INTERPOLATE, drawn with a texture matrix set. Without the change, the generated shader fails to compile (
texload0 = texture2D(u_texUnit0, (u_textureMatrix0 * v_texCoord0);). With your diff it compiles and draws the right colours on Chrome/ANGLE Metal and SwiftShader. The leftover/*endload*/comments after merging are harmless. PR with your diff plus that test: #28061.