Skip to content

Strip RelaxedPrecision and use highp for Vulkan and OpenGL ES shaders - #2059

Merged
bkaradzic-microsoft merged 4 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:fix/vulkan-strip-relaxed-precision
Nov 18, 2026
Merged

bkaradzic-microsoft merged 4 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:fix/vulkan-strip-relaxed-precision

Conversation

@bkaradzic-microsoft

@bkaradzic-microsoft bkaradzic-microsoft commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Strips RelaxedPrecision decorations from SPIR-V produced by the shader compiler, and requests highp default precision for OpenGL ES output.

Babylon GLSL is parsed as ESSL, so glslang decorates much of the module RelaxedPrecision (samplers default to lowp), and SPIRV-Cross defaults ES fragment shaders to mediump. Mobile GPUs (Adreno/Mali/Pixel) and NVIDIA desktop Vulkan evaluate those at fp16, which overflows e.g. the 1e6 depth sentinel used by fluid rendering. D3D11 and desktop GL ignore precision qualifiers, so this makes Vulkan and OpenGL ES match them.

  • Vulkan (graphics and compute / transform-feedback emulation): strip RelaxedPrecision. Fixes on Win32 + Pixel 9a: Fluid rendering (box sphere, particle system, GPU particle variants), Instances/Thin instances + motion blur, FrameGraph nrge SSR neon / OIT / multi RTT MSAA.
  • OpenGL ES: strip RelaxedPrecision and emit precision highp float/int. On a Pixel 9a (Mali-G715) the fluid bilateral depth blur otherwise produces Inf/NaN. Together with Native: only filter depth textures that use a comparison function Babylon.js#19153 (depth texture filtering), all four "Fluid rendering" tests that ran on Android OpenGL now pass.

StripRelaxedPrecision moves into ShaderCompilerCommon so both backends share it. The shader cache version goes to 15, so cached shaders compiled with the old precision are regenerated.

This PR bumps Babylon.js to 9.37.1, which includes BabylonJS/Babylon.js#19136. Running at full precision exposes a normalize(vec3(0)) NaN in the SSAO2 shader that fp16 used to hide; without that fix 9 "Prepass SSAO" tests regress on Vulkan. The release also includes BabylonJS/Babylon.js#19182, so Gaussian-splat sorting supplies the native implementation with view-space depth and handedness.

Validation: Win32 RelWithDebInfo UnitTests passed 200/200. The D3D11 validation sweep ran 833 tests: 755 passed, 78 failed, and 59 were skipped, improving on the 9.37.0 result of 754/79/59 with no increase in failures. The Gaussian Splatting subset passed all 20 runnable non-module tests; 14 Chakra-incompatible ES-module snippets failed as before, and 17 configured exclusions were skipped.

Android OpenGL full sweep (Pixel 9a) with this and the other pending BN/BJS changes: 720 of 722 tests that ran pass. The remaining two (Multi Scale Grid Material, apply-all-post-processes) also differ on Android Vulkan, so they come from the Mali hardware rather than the renderer.

@bkaradzic-microsoft bkaradzic-microsoft added the bug Something isn't working label Nov 10, 2026
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the fix/vulkan-strip-relaxed-precision branch from 60819a0 to 8a3abd4 Compare November 11, 2026 19:47
@bkaradzic-microsoft bkaradzic-microsoft changed the title Vulkan: strip RelaxedPrecision from generated SPIR-V Strip RelaxedPrecision and use highp for Vulkan and OpenGL ES shaders Nov 11, 2026
@bkaradzic-microsoft bkaradzic-microsoft changed the title Strip RelaxedPrecision and use highp for Vulkan and OpenGL ES shaders Vulkan: strip RelaxedPrecision decorations from generated SPIR-V Nov 12, 2026
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the fix/vulkan-strip-relaxed-precision branch from 8a3abd4 to 4830f91 Compare November 12, 2026 04:20
@bkaradzic-microsoft bkaradzic-microsoft changed the title Vulkan: strip RelaxedPrecision decorations from generated SPIR-V Strip RelaxedPrecision and use highp for Vulkan and OpenGL ES shaders Nov 12, 2026
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the fix/vulkan-strip-relaxed-precision branch from ffc7922 to 401ef50 Compare November 18, 2026 00:35
@bkaradzic-microsoft
bkaradzic-microsoft marked this pull request as ready for review November 18, 2026 02:51
Copilot AI balanced review requested due to automatic review settings November 18, 2026 02:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The compatibility sort path can produce incorrect splat blending order, and unchanged cache versioning allows stale shader binaries to bypass the precision-policy fixes.

2 open issues
1 file not reviewed
  • Apps/package-lock.json: Generated file
What changed in this PR

This PR aligns Vulkan and OpenGL ES shader precision with Babylon Native’s other backends to prevent overflow and rendering artifacts.

Changes:

  • Removes SPIR-V RelaxedPrecision decorations through a shared helper and requests highp defaults for OpenGL ES.
  • Updates Babylon.js dependencies to 9.37.0, including the SSAO fix needed for full-precision rendering.
  • Adds compatibility handling and tests for released and newer Gaussian-splat sorting signatures.
File Description
Plugins/​ShaderCompiler/​Source/​ShaderCompilerVulkan.cpp Strips relaxed-precision decorations from generated SPIR-V.
Plugins/​ShaderCompiler/​Source/​ShaderCompilerOpenGL.cpp Strips decorations and requests highp ES defaults.
Plugins/​ShaderCompiler/​Source/​ShaderCompilerCommon.h Declares the shared precision-stripping helper.
Plugins/​ShaderCompiler/​Source/​ShaderCompilerCommon.cpp Implements SPIR-V decoration removal.
Plugins/​NativeOptimizations/​Source/​NativeOptimizations.cpp Handles both Gaussian-splat sorting call signatures.
Apps/​UnitTests/​Source/​Tests.NativeOptimizations.cpp Adds released-signature sorting tests.
Apps/​UnitTests/​JavaScript/​package.json Updates test dependencies to Babylon.js 9.37.0.
Apps/​package.json Updates application Babylon.js dependencies to 9.37.0.
Apps/​package-lock.json Locks the updated Babylon.js dependency versions.

Review effort: Balanced

@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the fix/vulkan-strip-relaxed-precision branch from fb2b4ec to 93c847a Compare November 18, 2026 03:35
bkaradzic-microsoft and others added 4 commits November 18, 2026 06:45
Babylon GLSL is compiled as ESSL, so glslang marks much of the module
RelaxedPrecision (samplers default to lowp). NVIDIA desktop and mobile
drivers honor it and evaluate at fp16, overflowing values such as the
1e6 depth sentinel used by fluid rendering. D3D and desktop GL ignore
precision qualifiers, so strip the decorations for matching results.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b64bf64-2ec3-499d-bf8a-c8cc0b066e4f
glslang marks ES-parsed values RelaxedPrecision and SPIRV-Cross defaults
ES fragment shaders to mediump, which Mali GPUs run as fp16. This
overflows the 1e6 depth sentinel used by fluid rendering, so the
bilateral depth blur produces Inf/NaN.

Move StripRelaxedPrecision into ShaderCompilerCommon, apply it to the
OpenGL path as well, and request highp default float/int precision.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b64bf64-2ec3-499d-bf8a-c8cc0b066e4f
Update the Babylon.js application and unit-test packages to 9.37.1. This release includes BabylonJS/Babylon.js#19136, whose SSAO2 fix is required when shaders run at full precision.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bd57bfd-bbb3-4e86-8a17-9a44fb995d0f
Invalidate cached shaders so Vulkan and OpenGL ES programs are rebuilt without RelaxedPrecision and with highp defaults.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bd57bfd-bbb3-4e86-8a17-9a44fb995d0f
@bkaradzic-microsoft

Copy link
Copy Markdown
Member Author

CI note (run 44332812166, attempts 1 and 2)

Only MacOS_Installation / test-install failed. In both attempts it was cancelled without ever getting a macOS runner, so it's infra, not this PR:

Attempt Queue wait Result
1 15:11:56Z → 15:29:04Z, 17m08s, no runner cancelled
2 16:00:41Z → 16:16:08Z, 15m27s, no runner cancelled

All other jobs passed in attempt 1. The longest was Win32_x64_V8_D3D11, which ran 45m06s (15:11:59Z → 15:57:05Z). Ubuntu_Clang_JSC ran 26m25s; it predates the new runner image, so it isn't affected by the CMake issue fixed in #2093.

Total wall-clock so far: 15:11:55Z → 16:16:19Z = 1h04m24s.

Rerunning the failed job.

@bghgary bghgary left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Reviewed by Copilot on behalf of @bghgary]

LGTM.

@bkaradzic-microsoft
bkaradzic-microsoft merged commit fcbd2ca into BabylonJS:master Nov 18, 2026
88 of 92 checks passed
bkaradzic-microsoft added a commit that referenced this pull request Nov 19, 2026
## Summary
- bump Babylon.js packages from 9.35.0 to 9.37.1
- enable the deferred post-`setStateCullFaceType` pixel expectations
from #2069 now that BabylonJS/Babylon.js#19175 is released
- re-enable `Gaussian Splatting Loading RH` and `Gaussian Splatting LOD`
after BabylonJS/Babylon.js#19182
- narrow 18 mesh-blending, object-ID, and FrameGraph geometry exclusions
to D3D11/D3D12 after BabylonJS/Babylon.js#19150 and #19151 (six of them
also stay excluded on OpenGL: the FrameGraph geometry renderer scenes
fail to compile the GPU particle update effect, and the coastal cliff
and Gaussian mesh scenes time out in createScene on Linux CI); polyfill
`Object.fromEntries` for ChakraCore in `validation_native.js` (next to
the existing ES2019 polyfills) and re-enable the four FBX animation
scenes
- enable `Alpha-to-coverage transparent overlap` now that #2082 is
merged and Babylon.js 9.37.1 includes BabylonJS/Babylon.js#19148

Rebased onto master after #2059, #2082 and #2093 merged.

## Validation
- Win32 RelWithDebInfo `UnitTests`: 200/200 passed (JavaScript: 150
passed, 29 pending)
- released-fix candidates: Gaussian Splatting Loading RH and LOD passed;
alpha-to-coverage passes on Win32 Chakra D3D11 after #2082 (0.229% pixel
difference); compound splat and FBX tests remain excluded for
independent runtime blockers
- full D3D11 Playground sweep: 757 passed, 78 failed, 57 skipped versus
master baseline 752 passed, 81 failed, 59 skipped; no new failures
- Linux OpenGL CI (Ubuntu_Clang_JSC, run 44337090420 attempt 2): 725
passed, 6 failed before those six were excluded on OpenGL
- Win32 Chakra D3D11: all 18 `FBX loader` tests pass; without the
polyfill `FBX loader - skeletal animation` fails with `Object doesn't
support property or method 'fromEntries'`

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bd57bfd-bbb3-4e86-8a17-9a44fb995d0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants