fix(shader): leave out the all-zero position distance when guest distances fill all eight #6317
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6317"
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 SleglJan on 2026-10-15T11:13:15Z.
What
A vertex or tessellation evaluation program whose
PA_CL_VS_OUT_CNTLenables all eight guest clip distances (CLIP_DIST_ENA0xff with both distance vectors) does not compile onmain:guest clip distances plus the all-zero clip position distance exceed 8 clip distancesA program whose guest clip and cull distances together take eight (four of each, say) compiles, but its draw fails in the pipeline validator with
more than eight clip and cull distances in one shader. The guest distances (#423) and the distance that removes primitives with a vertex at clip position (0,0,0,0) (#3878) share onegl_ClipDistancearray, and eight guest distances leave no slot for the second.The all-zero position distance is now added only while the guest clip and cull distances leave one of the eight slots free. Otherwise the program keeps its guest distances, and a primitive with a vertex at clip position (0,0,0,0) is not removed. The
EmitSetAttributedebt entry records this.It is left out rather than folded into a guest distance. The extra distance (-1 at an all-zero vertex, 0 at the others) removes every primitive with such a vertex, matching the Radeon 610M and llvmpipe results in the
EmitSetAttributedebt entry. Writing -1 into a guest clip distance at that vertex keeps the parts of the primitive where the other vertices' distances are positive, and the minimum with the extra distance turns every positive guest distance into 0. A very large negative value there would remove the primitive and keep the guest plane, but it is not measured and has no equivalent when all eight are cull distances.Related: #4650 (open) adds two clip distances for a depth range remap in the same function. Whichever lands second counts them in the same limit.
Tested
main1db84d574, then rebased without conflicts ontomain8276a1d05, wheretools/check_conventions.py --base upstream/mainandgit diff --checkpass.agc_position_invariance: one vertex program exporting two distance vectors, compiled with seven and eight clip distances (0x007f, 0x00ff) and with three and four clip distances beside four cull distances (0xf007, 0xf00f). The clip distance arrays are 8, 8, 4 and 4, so the all-zero position distance is in the first and third only. Onmainthe second case throws and the fourth gives 5.agc|shader|recompiler|positionon lavapipe (Mesa 26.2.4, LLVM 23.1.1; Arch Linux container, GCC 16.2.1): 577 of 582 pass. The five failures (agc_storage_kept_unit_settle,agc_driver_bc_block_copy,agc_driver_depth_compare_copy,agc_driver_native_multisample_depth,agc_driver_storage_write_back_overhang) also fail onmainbuilt the same way, which with only the test applied failsagc_position_invariancetoo, with the error above.agc|shader|recompiler|position, 582 of 582 pass, two of them skipped as onmain(agc_import_watch_other_family,agc_driver_stencil_ref_export).registered program refers to an incompatible shader binary type).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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:18:35Z.
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.mdL148-149docs/dev/debt/shader.mdL19-20Some 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/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/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/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp