OLD-5237: rdna2spirv: the PS FRONT_FACE VGPR holds 0xffffffff / 0 (SHADER-892) #1415

Open
github-bot wants to merge 2 commits from github-bot/gh-1415 into main AGit
Owner

@⁠Tortoche on GitHub · 2026-11-24 23:43 UTC · original
Tortoche:test-5237 → main · +56 −5 · 3 files · 2 commits · open

Item ID: OLD-5237 (SHADER-892)
Carried forward from Draft #40 (old-pr/5237 by rafaelpssz), rebased onto main (58be9cdf8) with original commit authorship preserved.
Claimed in #14: #14

AI-assisted: yes

Summary

  • tools/rdna2spirv.py: store OpSelect %uint %ff 0xffffffff 0 into the pixel shader FRONT_FACE system VGPR (SPI_BARYC_CNTL.FRONT_FACE_ALL_BITS = 1), matching how all 345 corpus shaders that read it test it against integer 0 (v_cmp_ne_u32 / v_cmp_eq_u32).
  • tests/test_ps_front_face.py: hand-written synthetic pixel shader test verifying OpSelect %uint %ff 0xffffffff 0 into v4 and absence of the old float form (%ffm1).
  • docs/design.md: updated the PS system inputs contract row to document 0xffffffff / 0 and the corpus count.

Tests Executed (Linux, CPU/translator/runtime-build suites; no local GPU or game-data run performed)

  • python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6168 tests, 0 files failed (exit 0; 4060 s with 4 jobs)
  • python -I tests/test_ps_front_face.py: 1/1 passed (Ran 1 test in 0.022s, OK)
  • python -I tests/test_shader_meta.py: 28/28 passed (Ran 28 tests in 0.348s, OK)
  • python -I tests/test_docs_links.py: 16/16 passed (Ran 16 tests in 0.981s, OK)
  • python -I tests/test_design_contract_rows.py: 5/5 passed (Ran 5 tests in 0.025s, OK)
  • python -I tests/test_text_write_line_endings.py: 3/3 passed (Ran 3 tests in 257.636s, OK)
  • node --test tests/test_viewer_streaming.cjs: 57/57 passed (tests 57, pass 57, fail 0)
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_ps_front_face.py docs/design.md: passed (exit 0, zero game data)
  • python -m compileall -q make_game.py tools tests: passed (exit 0)
  • ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure: 68/71 passed, 2 skipped (shader_library_corpus, vk_sync_validation), 1 timeout (36 - xdxr_build_check at 1502.94s under CPU contention); re-run isolated ctest --test-dir runtime/build -C RelWithDebInfo -R '^xdxr_build_check$' --output-on-failure: 2/2 passed (xdxr_build 3.48s, xdxr_build_check 617.85s) -> 69 passed, 2 skipped, 0 failed.
**@⁠Tortoche** on GitHub · 2026-11-24 23:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1415) `Tortoche:test-5237` → `main` · +56 −5 · 3 files · 2 commits · open Item ID: `OLD-5237` (`SHADER-892`) Carried forward from Draft #40 (`old-pr/5237` by `rafaelpssz`), rebased onto `main` (`58be9cdf8`) with original commit authorship preserved. Claimed in #14: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 AI-assisted: yes ### Summary - `tools/rdna2spirv.py`: store `OpSelect %uint %ff 0xffffffff 0` into the pixel shader `FRONT_FACE` system VGPR (`SPI_BARYC_CNTL.FRONT_FACE_ALL_BITS = 1`), matching how all 345 corpus shaders that read it test it against integer 0 (`v_cmp_ne_u32` / `v_cmp_eq_u32`). - `tests/test_ps_front_face.py`: hand-written synthetic pixel shader test verifying `OpSelect %uint %ff 0xffffffff 0` into `v4` and absence of the old float form (`%ffm1`). - `docs/design.md`: updated the `PS system inputs` contract row to document `0xffffffff` / `0` and the corpus count. ### Tests Executed (Linux, CPU/translator/runtime-build suites; no local GPU or game-data run performed) - `python -I scripts/run_semantic_tests.py tests/semantic`: **470 files, 6168 tests, 0 files failed** (exit 0; 4060 s with 4 jobs) - `python -I tests/test_ps_front_face.py`: **1/1 passed** (`Ran 1 test in 0.022s`, `OK`) - `python -I tests/test_shader_meta.py`: **28/28 passed** (`Ran 28 tests in 0.348s`, `OK`) - `python -I tests/test_docs_links.py`: **16/16 passed** (`Ran 16 tests in 0.981s`, `OK`) - `python -I tests/test_design_contract_rows.py`: **5/5 passed** (`Ran 5 tests in 0.025s`, `OK`) - `python -I tests/test_text_write_line_endings.py`: **3/3 passed** (`Ran 3 tests in 257.636s`, `OK`) - `node --test tests/test_viewer_streaming.cjs`: **57/57 passed** (`tests 57, pass 57, fail 0`) - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_ps_front_face.py docs/design.md`: **passed** (exit 0, zero game data) - `python -m compileall -q make_game.py tools tests`: **passed** (exit 0) - `ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure`: **68/71 passed, 2 skipped** (`shader_library_corpus`, `vk_sync_validation`), 1 timeout (`36 - xdxr_build_check` at 1502.94s under CPU contention); re-run isolated `ctest --test-dir runtime/build -C RelWithDebInfo -R '^xdxr_build_check$' --output-on-failure`: **2/2 passed** (`xdxr_build` 3.48s, `xdxr_build_check` 617.85s) -> **69 passed, 2 skipped, 0 failed**.
RDNA2's FRONT_FACE system VGPR is 0xffffffff (front) / 0 (back) with
SPI_BARYC_CNTL.FRONT_FACE_ALL_BITS = 1 and +1.0 / -1.0 without it (#5123);
which one the console programs wasn't known. Over the 1.0.2.1 corpus, 1,984
pixel shaders declare SV_IsFrontFace, 345 read the VGPR, and every first use
is an integer compare against 0 (282 v_cmp_ne_u32_e32, 62 v_cmp_ne_u32_e64,
1 v_cmp_eq_u32_e32) - no float compare, bit op or other use. +1.0 and -1.0
are both non-zero, so with the float form the translator wrote, all 345
saw every face as front. It now stores the mask form.

tests/test_ps_front_face.py translates a hand-written PS that tests the VGPR
the same way and checks the stored values (fails on the old code). The
712 corpus PS that compare the FRONT_FACE register translate and pass
spirv-val before and after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From @kacper-serewis's review of #5237: an integer compare against 0 can't
tell 0xffffffff/0 from 1/0; the mask form is the other one the hardware
gives (#5123).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:50:44 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-24 23:48 UTC · original

Tested 739d6058e on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 364ab4eab (translator-only PR; binaries from the build at 66d4f5aa3, and no C++ in runtime/test used by these fixtures changed in between):

  • python3 -I tests/test_ps_front_face.py: 1/1 OK at this head. The same file copied onto main's tree fails: AssertionError: unexpectedly None : FRONT_FACE is not stored as a uint select — it does distinguish the two revisions.
  • GPU, MoltenVK 1.4.2: --filter ps_bary 1/1 PASS (4096/4096 pixels match); --filter ps_texture_sample 2/2 PASS (ps_texture_sample OK, ps_texture_sample_d16 4096/4096 exact). ps_ij_computed SKIP — computed I/J pairs need PerVertexKHR inputs and neither --bary-fallback nor --f16-interp-fallback was enabled.
  • The same ps_bary run with main's tools/rdna2spirv.py in the same tree is also 4096/4096 PASS, so this fixture does not distinguish the two revisions here; the new unit test is the only local evidence of the change.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-24 23:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1415#issuecomment-7147824386) Tested `739d6058e` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `364ab4eab` (translator-only PR; binaries from the build at `66d4f5aa3`, and no C++ in `runtime/test` used by these fixtures changed in between): - `python3 -I tests/test_ps_front_face.py`: **1/1 OK** at this head. The same file copied onto `main`'s tree fails: `AssertionError: unexpectedly None : FRONT_FACE is not stored as a uint select` — it does distinguish the two revisions. - GPU, **MoltenVK 1.4.2**: `--filter ps_bary` **1/1 PASS** (4096/4096 pixels match); `--filter ps_texture_sample` **2/2 PASS** (`ps_texture_sample` OK, `ps_texture_sample_d16` 4096/4096 exact). `ps_ij_computed` SKIP — computed I/J pairs need `PerVertexKHR` inputs and neither `--bary-fallback` nor `--f16-interp-fallback` was enabled. - The same `ps_bary` run with `main`'s `tools/rdna2spirv.py` in the same tree is also 4096/4096 PASS, so this fixture does **not** distinguish the two revisions here; the new unit test is the only local evidence of the change. AI-assisted; synthetic fixtures only, no game data.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1415/head:github-bot/gh-1415'
git switch 'github-bot/gh-1415'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1415'
git switch 'github-bot/gh-1415'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1415'
git switch 'github-bot/gh-1415'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1415'
git switch 'main'
git merge --squash 'github-bot/gh-1415'
git switch 'main'
git merge --ff-only 'github-bot/gh-1415'
git switch 'main'
git merge 'github-bot/gh-1415'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.