Repository navigation
Strip RelaxedPrecision and use highp for Vulkan and OpenGL ES shaders - #2059
Conversation
60819a0 to
8a3abd4
Compare
8a3abd4 to
4830f91
Compare
ffc7922 to
401ef50
Compare
There was a problem hiding this comment.
🟡 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
RelaxedPrecisiondecorations 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
fb2b4ec to
93c847a
Compare
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
93c847a to
96c159b
Compare
|
CI note (run 44332812166, attempts 1 and 2) Only
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. |
## 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


Strips
RelaxedPrecisiondecorations from SPIR-V produced by the shader compiler, and requestshighpdefault 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 tomediump. 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.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.RelaxedPrecisionand emitprecision 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.StripRelaxedPrecisionmoves intoShaderCompilerCommonso 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.