mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #40] rdna2spirv: the PS FRONT_FACE VGPR is 0xffffffff / 0 — all 345 game shaders that read it test it against integer 0 (SHADER-892) #93
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#93
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/40
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/5237📝 Commits (3)
5c85e23rdna2spirv: the PS FRONT_FACE VGPR holds 0xffffffff / 0, the form the game's shaders test (SHADER-892)eea1754docs/design.md: the FRONT_FACE count rules out ±1.0; all-bits over 1/0 is the hardware's other formecaaf14Merge main into fix/front-face-mask📊 Changes
3 files changed (+56 additions, -5 deletions)
View changed files
📝
docs/design.md(+1 -1)➕
tests/test_ps_front_face.py(+47 -0)📝
tools/rdna2spirv.py(+8 -4)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):SHADER-892 (claim); finding by
@Vonsek.The question
On RDNA2, the pixel shader's FRONT_FACE system VGPR holds 0xffffffff (front) / 0 (back) when
SPI_BARYC_CNTL.FRONT_FACE_ALL_BITS= 1, and +1.0 / −1.0 when it is 0 (measured on gfx1036,#5123). Nobody knew which one the console driver programs. The translator wrote the float form.The count (my own 1.0.2.1 copy, full corpus, counts only)
The FRONT_FACE VGPR is the one right after the
SV_Positioncomponents the shader reads (the translator's own layout). I followed it from the entry to its first uses.SV_IsFrontFacev_cmp_ne_u32_e32, 62v_cmp_ne_u32_e64, 1v_cmp_eq_u32_e32+1.0 (
0x3F800000) and −1.0 (0xBF800000) are both non-zero, so in the float form!= 0says "front" for every face. The game's code only works with the mask form, so the console programsFRONT_FACE_ALL_BITS= 1. With the old translation, all 345 shaders treated back faces as front faces.The change
tools/rdna2spirv.pystoresOpSelect %uint FrontFacing 0xffffffff 0into the VGPR. Before, it stored the bitcast ofOpSelect %float FrontFacing 1.0 -1.0. The layout comment says so too.docs/design.md("PS system inputs") records the form and the count.tests/test_ps_front_face.pytranslates a hand-written PS that reads x/y ofSV_Positionand then tests the facing VGPR (v4) withv_cmp_ne_u32 vcc, 0, v4. It checks that the select stores 0xffffffff / 0 into v4 and that the float form is gone. It fails on the old code.Tests
tests/test_shader_meta.py,test_docs_design_rows.pyandtest_docs_links.pypass.python -m unittest discover -s tests/semantic: the only failures (3 failures, 2 errors) aretest_loop_ballot_barrier, the same as onmain(the known wave64-emulation regression,#4363).SV_IsFrontFaceand have av_cmp*with an immediate 0 on the FRONT_FACE register number anywhere in the listing. This is a superset of the 345 that includes register reuse, used as a translation set, not as a count. All 712 translate and passspirv-val, both onmainand with this change.@Kev-Ball, RTX 3080 Ti, Linux: back faces read 1.0 with the parent, the old bug, and 0.0 with this PR. Front faces read 1.0 on both.@CryingLaughing, RTX 4080, Windows, validation on: with this PR, front =v4 == 0xffffffffand back =v4 == 0. That matches a VulkanFrontFacingreference shader byte for byte over 4,096 pixels.Thanks
@Vonsekfor the finding and the gfx1036 measurement (#5123).@Kev-Balland@CryingLaughingfor the two-winding GPU draws that pin the fix on hardware.@Kam471for the Windows run.@sovljanskiifor the Apple M4 (MoltenVK) winding run, the third GPU vendor.@kacper-serewisfor the independent reproduction of the 345 and the review that made the doc precise about 1/0 vs all-bits.@SweatierKeyfor the Linux CPU verification of the follow-up head.@amarovndresand@Atomic258for the Windows CPU runs (Atomic258's with the negative control).@tunczzzfor the RTX 5070 Ti run.@carlos-seiffert: tested on RTX 2060.@SquishyGithub: tested on RTX 3070 (Linux).@morodirule: independent corpus recount.@javdc: tested on Steam Deck.@TG0000: tested on RX 6800.@phudykafor the GTX 1080 run on Linux: the full GPU suite on this head merged onto main, compared with main alone.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.