test(agc): run csub without glc and pin it to the RDNA2 measurement #18667

Merged
angrysandhill merged 1 commit from upstream-pr/18667 into main 2026-11-13 01:47:32 +00:00
angrysandhill commented 2026-11-12 01:15:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by angrysandhill on 2026-11-12T01:15:18Z.


What

This answers the question in the review of #15252: does the hardware still write the destination register without glc, or treat the encoding differently? It doesn't, on RDNA2 (gfx1031; the PS5's gfx1013 is not measured). With glc clear, buffer_atomic_csub and global_atomic_csub apply the clamped subtract and write no register. That is what the translation from #15252 and #15253 already does, so the recompiler does not change.

  • Tests: agc_driver_buffer_atomic_csub and agc_driver_global_atomic_csub only compiled the encoding without glc. They now run it, with all lanes active and under the partial exec mask the tests already use, and check:
    • Memory: the clamped subtract on active lanes, unchanged on inactive ones.
    • The data register: unchanged.
    • The global form's v0: the register its vdst field names stays the thread id.
  • Debt: both entries record the RDNA2 result. They stay open, since they close on a PS5 measurement.

Tested

Setup: Windows 10 Home 22H2 (10.0.19045), AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, on main d5fc44ac7f.

RDNA2 measurement (hardware oracle, HIP), wave32 and wave64, IEEE 0, DX10_CLAMP 1, f32 and f16 denormals kept, round to nearest even, FP16_OVFL 0.

  • Encodings: the assembler refuses both forms without glc. The probe assembles the glc forms and clears the bit by hand: bit 16 of word 0 for global_atomic_csub, bit 14 for buffer_atomic_csub. That gives the words the tests' NoReturnCode already holds, 0xdcd08000 0x00080a03 and 0xe0d01000 0x80010702.
  • Rows: 64 (memory, subtrahend) pairs: the tests' 16 edge pairs (around 0, 1, 0x7fffffff, 0x80000000 and 0xffffffff, both ways) and 48 random ones. Each lane gets its own dword, and its destination register is filled with a marker first.
  • Exec: all lanes, and exec_lo 0x55555555.
  • Memory type: coarse-grained. On the oracle's default fine-grained memory, csub does nothing at all: memory is unchanged, and even the glc form returns 0. global_atomic_add works there.
glc set glc clear
memory clamped subtract, 64 of 64 clamped subtract on active lanes, unchanged on inactive ones, 64 of 64
register the old memory value, 64 of 64 not written, 64 of 64: the vdst field's register (v0 or v13) and the data register

Through HW_ORACLE_RUNTIME=vulkan, the recompiler gives the same values on a first probe's 64 rows with all lanes active (vdst v11/v13). The new tests cover the vdst field 0 and the partial exec mask.

Tests:

  • This change: both tests pass on the RX 6750 XT under the validation layer (1.4.367, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1). With buffer_atomic_csub_translation and global_atomic_csub_translation, 4 of 4 tests pass, and there is no VUID- line. Both GPU tests log the layer insertion; the translation tests open no device.
  • After the rebase onto 389e0e17fc: the four tests pass again under the validation layer, with no VUID- line, and the mutation check below fails both GPU tests as before.
  • No red run: main already behaves as measured, so the new checks also pass there.
  • Mutation check: with if (inst.glc) in BufferInstructions.cpp and FlatInstructions.cpp replaced by an unconditional write:
    • agc_driver_buffer_atomic_csub fails on the new check: buffer atomic csub without glc: wave32 32 threads thread 1 lane 1 data register is 0x00000000, expected 0x00000001.
    • agc_driver_global_atomic_csub fails earlier. Without glc the decoder gives the global form no destination operand, so the forced write does not compile (writeRawU32 invalid decoded operand used as a destination). Its v0 check guards against a later change that decodes and writes the vdst field.
  • tools/check_conventions.py: passed.
  • git diff --check: clean.
  • Not run: the full suite, since only tests and the debt list change.

Overlap:

  • #15488, #16571 and #18530: add entries next to the two csub entries in shader.md, so they conflict textually. None changes the csub entries, so the resolution keeps both.
  • #16887: did the same and is merged. This branch is rebased onto main 389e0e17fc (8b0efa5ef8), keeping its new entry above the global_atomic_csub one.
  • #14212: reformats every entry of the file.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (32.0.21045.16010), Windows 10 22H2
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5269481282 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18667). Originally posted by [angrysandhill](https://github.com/angrysandhill) on 2026-11-12T01:15:18Z. --- ### What This answers the question in the review of #15252: does the hardware still write the destination register without `glc`, or treat the encoding differently? It doesn't, on RDNA2 (gfx1031; the PS5's gfx1013 is not measured). With `glc` clear, `buffer_atomic_csub` and `global_atomic_csub` apply the clamped subtract and write no register. That is what the translation from #15252 and #15253 already does, so the recompiler does not change. - **Tests:** `agc_driver_buffer_atomic_csub` and `agc_driver_global_atomic_csub` only compiled the encoding without `glc`. They now run it, with all lanes active and under the partial exec mask the tests already use, and check: - **Memory:** the clamped subtract on active lanes, unchanged on inactive ones. - **The data register:** unchanged. - **The global form's `v0`:** the register its vdst field names stays the thread id. - **Debt:** both entries record the RDNA2 result. They stay open, since they close on a PS5 measurement. ### Tested **Setup:** Windows 10 Home 22H2 (10.0.19045), AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), WinLibs GCC 15.2.0 r7 UCRT, Release, `BUILD_TESTING=ON`, on `main` `d5fc44ac7f`. **RDNA2 measurement** ([hardware oracle](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/HW_ORACLE.md), HIP), wave32 and wave64, IEEE 0, DX10_CLAMP 1, f32 and f16 denormals kept, round to nearest even, FP16_OVFL 0. - **Encodings:** the assembler refuses both forms without `glc`. The probe assembles the `glc` forms and clears the bit by hand: bit 16 of word 0 for `global_atomic_csub`, bit 14 for `buffer_atomic_csub`. That gives the words the tests' `NoReturnCode` already holds, `0xdcd08000 0x00080a03` and `0xe0d01000 0x80010702`. - **Rows:** 64 (memory, subtrahend) pairs: the tests' 16 edge pairs (around 0, 1, `0x7fffffff`, `0x80000000` and `0xffffffff`, both ways) and 48 random ones. Each lane gets its own dword, and its destination register is filled with a marker first. - **Exec:** all lanes, and `exec_lo` `0x55555555`. - **Memory type:** coarse-grained. On the oracle's default fine-grained memory, csub does nothing at all: memory is unchanged, and even the `glc` form returns 0. `global_atomic_add` works there. | | `glc` set | `glc` clear | |---|---|---| | memory | clamped subtract, 64 of 64 | clamped subtract on active lanes, unchanged on inactive ones, 64 of 64 | | register | the old memory value, 64 of 64 | not written, 64 of 64: the vdst field's register (`v0` or `v13`) and the data register | Through `HW_ORACLE_RUNTIME=vulkan`, the recompiler gives the same values on a first probe's 64 rows with all lanes active (`vdst` `v11`/`v13`). The new tests cover the vdst field 0 and the partial exec mask. **Tests:** - **This change:** both tests pass on the RX 6750 XT under the validation layer (1.4.367, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1`). With `buffer_atomic_csub_translation` and `global_atomic_csub_translation`, 4 of 4 tests pass, and there is no `VUID-` line. Both GPU tests log the layer insertion; the translation tests open no device. - **After the rebase onto `389e0e17fc`:** the four tests pass again under the validation layer, with no `VUID-` line, and the mutation check below fails both GPU tests as before. - **No red run:** `main` already behaves as measured, so the new checks also pass there. - **Mutation check:** with `if (inst.glc)` in `BufferInstructions.cpp` and `FlatInstructions.cpp` replaced by an unconditional write: - **`agc_driver_buffer_atomic_csub`** fails on the new check: `buffer atomic csub without glc: wave32 32 threads thread 1 lane 1 data register is 0x00000000, expected 0x00000001`. - **`agc_driver_global_atomic_csub`** fails earlier. Without `glc` the decoder gives the global form no destination operand, so the forced write does not compile (`writeRawU32 invalid decoded operand used as a destination`). Its `v0` check guards against a later change that decodes and writes the vdst field. - **`tools/check_conventions.py`:** passed. - **`git diff --check`:** clean. - **Not run:** the full suite, since only tests and the debt list change. **Overlap:** - **#15488, #16571 and #18530:** add entries next to the two csub entries in `shader.md`, so they conflict textually. None changes the csub entries, so the resolution keeps both. - **#16887:** did the same and is merged. This branch is rebased onto `main` `389e0e17fc` (`8b0efa5ef8`), keeping its new entry above the `global_atomic_csub` one. - **#14212:** reformats every entry of the file. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (32.0.21045.16010), Windows 10 22H2 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!18667
No description provided.