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
ShaderCompiler: fix 3-argument texture() rejected by glslang (#1755)
## Summary
The sampler vertical-flip applied on the **D3D / Metal / Vulkan**
backends was injected as a **2-argument** function-like macro:
```glsl
#define texture(x,y) texture(x, flip(y))
#define textureLod(x,y,z) textureLod(x, flip(y), z)
```
This cannot match the **3-argument** bias form `texture(sampler, uv,
bias)` emitted by some Babylon.js shaders (e.g. GreasedLine:
`texture(grl_colors, uv, 0.)`), and glslang's preprocessor has **no
variadic-macro support** (`Too many args in macro`), so those shaders
failed to compile — surfacing as a `BJS - Error compiling effect` retry
loop that hangs the test.
## Fix
Replace the `texture()`/`textureLod()` macros with a
`FlipSamplerCoordinates` **AST traverser** that rewrites a 2-component
sample coordinate to `vec2(u, 1.0 - v)` for any call arity and sampler
type. It runs only on the backends that already apply
`ProcessSamplerFlip` (D3D, Metal, Vulkan); the OpenGL backend shares
bgfx's V-orientation and is unaffected. `texelFetch` keeps its macro
(integer texel coordinates), and 3D/cube/array (vec3+) coordinates are
left untouched, matching the previous `flip(vec2)`/`flip(vec3)`
behavior.
Fixes
[ThePirateCove#1656](BabylonJS/ThePirateCove#1656).
## Verification (D3D11 Debug)
- GreasedLine idx 149 / 150 now **compile and render** — no hang, no
`Error compiling effect`.
- **No regression** across 20 diverse texture / postprocess / shadow /
refraction / glow / cubemap tests (idx 5, 8, 25, 35, 37, 155, 373, 396,
410, 487, 4, 23, 32, 36, 49, 131, 135, 254, 343, 394).
- OpenGL backend build-checked (`GRAPHICS_API=OpenGLWindowsDevOnly`);
the unchanged sampler path compiles clean.
## Note
This PR originally also bumped the bgfx transient vertex-buffer limits
for
[ThePirateCove#1570](BabylonJS/ThePirateCove#1570).
On investigation that turned out to be a misdiagnosis (the overflow is a
nanovg Canvas burst, not Gaussian Splatting / vertex pulling), so that
change was dropped — details posted on #1570.
Co-authored-by: Branimir Karadzic <branimirkaradzic@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments