fix(shader): interpolate 16-bit values with 64-bit integers on devices without Float64 #6767
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6767"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T11:00:53Z.
What
The 16-bit interpolation steps round an exact sum once (#697, measured on RDNA2):
v_interp_p1ll_f16andv_interp_p1lv_f16roundP10 * I + P0to f32;v_interp_p2_f16roundsP20 * J + S2to f16;v_fma_mixlo_f16andv_fma_mixhi_f16reuse the f16 step in every f16 rounding mode.The exact sum is computed in f64, so on a device without the Float64 capability every shader using them fails to compile:
Apple GPUs have no f64. With MoltenVK 1.4.2 on Apple M2 this stops four catalog titles at their first such pixel shader: ProsperoStore (PPSA99000), PokeMMO Prospero (PPSA98001), Régie5 (PPSA99520) and PS5 OpenGL Showcase (PPSA99005). A temporary log line in
AnalyzeProgramRequirementsshowedFPInterpolateF16is the only 64-bit float operation in all four.Without Float64,
FPInterpolateF32andFPInterpolateF16are now computed in 64-bit integers, which the shader device profile already requires:No floating-point arithmetic is involved, so the device's denormal handling doesn't matter; MoltenVK reports
shaderDenormPreserveFloat32 = false. The module declaresInt64instead ofFloat64. Devices with Float64 keep the f64 path unchanged, and other f64 instructions still need Float64.Commits:
agc_driver_mix_precisionwithout Float64.Tested
macOS 26.7.1, Apple M2, MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363, AppleClang 21.0.0, x86-64 under Rosetta, Release. The GPU tests ran with the SDK's loader on the path; plain
ctestskips them here, since it finds nolibvulkan.1.dylib.maindoesn't build the system libraries on macOS by itself, so the tests and titles ran in a local tree:maince991f1ecwith the macOS runtime work merged (#4627, #4630, #6124, the macOS relinker PRs, mugurc's port branches), plus #6535 and #6741. The branch's 8 files are identical to the ones tested.agc_driver_interpolation_modesskipped onmainhere ("interpolation modes require Float64"). Now it passes 5 runs of 5, 0.4 s with a warm shader cache and 5 s without one:agc_driver_mix_precision(v_fma_mixlo_f16 and v_fma_mixhi_f16) skipped onmainhere ("computed in f64 and the device has no shaderFloat64"). It now passes 5 runs of 5.agc_/shader tests here, with this branch and withmain's files: the same 39 fail with both, all MoltenVK issues outside this change, such as f16 signed zeros inagc_driver_float16_fma_roundingandagc_driver_fp16_overflow. That's whyagc_driver_fp16_overflowkeeps its Float64 skip. Nothing fails only with the branch.Barycentric geometry SPIR-V: geometry shaders are unavailable(#6222's area);tools/check_conventions.py --base origin/mainandgit diff --checkpass.Not tested here: the f64 path, since this device has no Float64. On a device with Float64 the test runs both paths against the hardware rows, and the f64 path against the same reference.
Limits of this Mac's GPU.
vulkaninfoon Apple M2 with MoltenVK 1.4.2 reports no geometry shaders, noshaderFloat64, noVK_EXT_depth_range_unrestrictedand noVK_EXT_provoking_vertex. AnyPS5 turns MoltenVK'sVK_KHR_fragment_shader_barycentricoff (5333a2053), so barycentric pixel shaders need the geometry-shader fallback. These are limits of the device. Apart from the Float64 case below, this PR doesn't remove them. A title named here as stopping on one of them is not tested past that stop:Barycentric geometry SPIR-V: geometry shaders are unavailable: no geometry shaders; #6222 has a route around it.viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted: #4650 works around it.last provoking vertex requires VK_EXT_provoking_vertex: #6741 removes it only for draws whose pixel shader can't observe the provoking vertex.Overlap:
SpirvModuleSetup.cpp. The conflict is textual only, and the integer path does no float arithmetic, so the mode doesn't affect it.shader.md.Interpolate,InterpolateFunction, theFPInterpolateoperations or the Float64 requirement.Whichever lands second rebases.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T11:22:56Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/shader.mdL98-99docs/dev/debt/shader.mdL98-99Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppdocs/dev/debt/shader.mdImported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-17T10:49:42Z.
Rebase handoff — rebased onto current
main(all commits, authorship unchanged). One docs-debt conflict, unioned withmain's entries.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesmainregression (agc_driver_tessellationsegfault, #4727), not this PRTo pick it up:
Head is
09c8b0921.Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-17T15:34:35Z.
Thanks, @blawesom. I checked your
rebase/6767against this branch: the code commits are identical, and the debt-file commit differs only by the conflict resolution. Rather than force-pushing, I merged currentmaininto the branch with the same resolution, so the history stays as reviewed. The PR's diff againstmainnow matches your rebase. Since your rebase,mainalso reworded the twoshader.mdentries this PR edits, so I merged at the word level: both entries keepmain's new text plus this PR's Float64 sentences. Head isf53e01220, and it merges cleanly withmain.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Neithennn on 2026-10-17T20:12:41Z.
Windows NVIDIA run, since the description lists Apple M2 / MoltenVK only.
Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_NO_SHADER_CACHE=1. Headf53e01220(on mainf51724078); full build succeeds.agc_driver_interpolation_f16,agc_driver_interpolation_modes,agc_interpolant_mapping,agc_driver_float16_*,agc_driver_f16_*,agc_float16_conversion, ...): 35/35 pass, withANYPS5_REQUIRE_VULKAN=1.ctest -j 8: 1398/1398. Unchanged main on the same machine: 1398/1398.I did not check which interpolation path the RTX 4080 takes with this change, so this shows no regression on NVIDIA rather than coverage of the new path. No title run.
AI-assisted: yes (runs done with Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Neithennn on 2026-10-19T09:34:28Z.
Rerun of the new head
2b81cc1c6on the RTX 4080 (my earlier run was onf53e01220).Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_NO_SHADER_CACHE=1. Head merged onto mainf78675ae4; full build succeeds.agc_driver_interpolation_f16,agc_driver_interpolation_modes,agc_interpolant_mapping,agc_driver_float16_*,agc_driver_f16_*,agc_f16_single_convert,agc_float16_conversion, ...): 36/36 pass, withANYPS5_REQUIRE_VULKAN=1.ctest -j 8: 1627/1628, the same as unchanged main on this machine; the one failure isagc_driver_bda_device(device lost, #7584), which fails on main too and is fixed by #7571.As before, I did not check which interpolation path the RTX 4080 takes, so this shows no regression on NVIDIA rather than coverage of the new path. No title run.
AI-assisted: yes (runs done with Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T10:55:45Z.
Rebased onto current
main(conflicts with #6503 inSpirvModuleSetup.cpp, now merged, and with the two reworded entries indocs/dev/debt/shader.md); no logic changed. Checked the integer path (alignment with sticky bit, single rounding in all four f16 modes, overflow, f32/f16 subnormal steps, zero signs, NaN order) against the f64 path, the 32 hardware rows and the random-row reference, which runs on every device. Ctest on the rebased tree passes; merged.