fix(shader): honour SPI_BARYC_CNTL.FRONT_FACE_ALL_BITS for the front-face input #5314
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5314"
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 XairRrR on 2026-10-13T17:01:52Z.
What
The pixel shader's front-face VGPR was always
+1.0/-1.0. That is its form only whileSPI_BARYC_CNTL.FRONT_FACE_ALL_BITS(bit 24) is clear. With the bit set, a back face reads0and a front face non-zero:v_cmp_lg_u32 0, front_face(aco_instruction_selection.cpp).fgt 0, andfsignfor±1.0, inac_nir_lower_intrinsics_to_args.c). That is the form the driver produced until now.Uncharted: Legacy of Thieves Collection (PPSA05684) sets the bit. Its two-sided cloth shaders enable FRONT_FACE (
SPI_PS_INPUT_ENA = 0x1b02, so the input isv5) and test it withv_cmp_lt_u32 0, v5.-1.0(0xbf800000) is non-zero, so every back face was taken as a front face. The insides of the menu skeleton's rags kept their front normals and were lit white by the spot light behind the cage. With this change the rags render dark, as on the PC version.Changes:
ShaderPixelStageInfo::frontFaceAllBits, decoded fromSPI_BARYC_CNTLonly when FRONT_FACE is an active input, so contexts without the input don't need the register.RequestSerializerTestsupgrades older fixtures to version 27), the shader cache key, the draw lookup key and the draw register key comparison.DrawKeyRegisterscovers0x1b6..0x1b8.0xffffffff/0.0xffffffff) is not measured; only back = 0 and front ≠ 0 are sourced. It is listed indocs/dev/debt/shader.md.Tested
agc_driver_front_face_all_bits: a front-facing and a back-facing triangle export the raw front-face VGPR into an R32_UINT target. It expects0x3f800000/0xbf800000without the bit and0xffffffff/0with it. With the translator change reverted, it fails withwith FRONT_FACE_ALL_BITS: the front-facing triangle read FRONT_FACE as 0x3f800000, expected 0xffffffff.agc_driver_graphicsdecodes the bit (set, clear, and set without the front-face input).agc_shader_memoryround-trips the flag and replays a version 26 request.main32e810db4, before adriadam10's rebase onto version 27 (he re-ran the affected tests on the rebase).tools/check_conventions.py --base origin/mainpasses.mainyet, it needs #757/#758): the white rags are gone and the skeleton matches the PC reference.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 adriadam10 on 2026-10-14T19:10:53Z.
Checked on a build merged onto current main:
agc_driver_graphics,agc_shader_memory(incl. the version 25 replay),agc_driver_front_face_all_bitsand the prepared-graphics tests pass; the flag is in the serialization, shader cache key, draw lookup key and draw register comparison. The only red test in the scoped run,agc_driver_tessellation, segfaults insidelibvulkan_radeon.soon a tree without this PR too. Minor: the body says "replays a version 23 request", the test replays version 25. The front value0xffffffffis unmeasured and listed in the debt file; merging.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T19:40:00Z.
Rebased onto current
main, which took serialization version 26 for the linked call fallbacks in the meantime. The front-face all-bits flag is now serialized in version 27 (RequestSerializer.cpp);RequestSerializerTests.cppandShaderMemory.cppfollow (upgrade fixtures, the replay case is now a version 26 request, the "unsupported version" fixture is 28). Re-ranagc_shader_memory,agc_driver_graphics,agc_driver_front_face_all_bits, the serializer and prepared-graphics tests on the rebase: green.agc_driver_tessellationstill segfaults inlibvulkan_radeon.so, as onmain. Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T19:41:28Z.
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)core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL2905, L3020-3021, L3023, L3139-3142core/shader/recompiler/ControlFlow/src/RequestSerializer.cppL341, L393, L765, L798core/shader/recompiler/tests/RequestSerializerTests.cppL205-206, L243-244, L267-268, L390-391, L405, L407core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL2905, L3020-3021, L3023, L3141core/shader/recompiler/ControlFlow/src/RequestSerializer.cppL341, L393, L765, L798core/shader/recompiler/tests/RequestSerializerTests.cppL205-206, L243-244, L267-268, L390-391, L405, L407