fix(shader): accept a local tessellation index that nothing observes #6657

Merged
xQuakes merged 3 commits from upstream-pr/6657 into main 2026-10-24 09:26:52 +00:00
xQuakes commented 2026-10-16 02:00:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xQuakes on 2026-10-16T02:00:25Z.


What

A local tessellation program that uses the relative patch index only to address local data share, and otherwise keeps it on inactive lanes or in a vector-window slot nothing reloads, was refused:

tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0

usedAsData treated every value that was not itself an address as a data use. The index is now followed through the arithmetic, selects, bitcasts and other pure operations that carry its bits. A side effect counts only when the value it observes still depends on the index. An exec-masked select counts only the arm that exec takes. A vector-window store counts only when a later load can see it. Storing the index into local data share, or reloading it from the window, is still refused.

PPSA12361 (Transport Fever 2: Console Edition) stops at startup on this refusal for shader 0x287f20000, stage 6.

#6551 also edits TessellationLowering.cpp, for a hull read at a control point chosen by a select or a phi. This change is the data-use check for a local program.

Tested

Windows 11, MinGW-w64 GCC 16.1.0, NVIDIA GeForce RTX 5090, driver 610.62.

  • agc_driver_tessellation_tests passes. A local program whose relative index survives only on inactive lanes compiles. Restoring exec before storing the index, and a window load after the address is stored, are still refused, as is the existing LocalIndexAsData case. The previous hull and domain cases pass.
  • The captured PPSA12361 request for shader 0x287f20000 compiles. The title gets past that shader and later stops on the multisampled storage-image refusal, which is #5881.

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
  • Unblocks: PPSA12361 (no Game bring-up discussion yet)
  • GPUs tested: NVIDIA GeForce RTX 5090, driver 610.62, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4882339615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657). Originally posted by [xQuakes](https://github.com/xQuakes) on 2026-10-16T02:00:25Z. --- ### What A local tessellation program that uses the relative patch index only to address local data share, and otherwise keeps it on inactive lanes or in a vector-window slot nothing reloads, was refused: ``` tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0 ``` `usedAsData` treated every value that was not itself an address as a data use. The index is now followed through the arithmetic, selects, bitcasts and other pure operations that carry its bits. A side effect counts only when the value it observes still depends on the index. An exec-masked select counts only the arm that exec takes. A vector-window store counts only when a later load can see it. Storing the index into local data share, or reloading it from the window, is still refused. PPSA12361 (Transport Fever 2: Console Edition) stops at startup on this refusal for shader `0x287f20000`, stage 6. #6551 also edits `TessellationLowering.cpp`, for a hull read at a control point chosen by a select or a phi. This change is the data-use check for a local program. ### Tested Windows 11, MinGW-w64 GCC 16.1.0, NVIDIA GeForce RTX 5090, driver 610.62. - `agc_driver_tessellation_tests` passes. A local program whose relative index survives only on inactive lanes compiles. Restoring exec before storing the index, and a window load after the address is stored, are still refused, as is the existing `LocalIndexAsData` case. The previous hull and domain cases pass. - The captured PPSA12361 request for shader `0x287f20000` compiles. The title gets past that shader and later stops on the multisampled storage-image refusal, which is #5881. ### 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] Unblocks: PPSA12361 (no Game bring-up discussion yet) - [x] GPUs tested: NVIDIA GeForce RTX 5090, driver 610.62, Windows 11 - [x] AI-assisted: yes
jotitadev commented 2026-10-16 02:58:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T02:58:38Z.

Review: COMMENTED


Linux run on NVIDIA and lavapipe, which the Linux CI job uses.

Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head 41972eeb9 merged into main 5d9dcc42d (clean merge), -j1 --timeout 30.

  • Tests only (TessellationLowering.cpp restored from main): agc_driver_tessellation fails on both devices with tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0.
  • With the fix: agc_driver_tessellation and agc_tessellation_factor_ring pass 3/3 on the RTX 3070 and 3/3 on lavapipe.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5542491139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657#pullrequestreview-5542491139). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T02:58:38Z. **Review:** COMMENTED --- Linux run on NVIDIA and lavapipe, which the Linux CI job uses. **Machine:** NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `41972eeb9` merged into `main` `5d9dcc42d` (clean merge), `-j1 --timeout 30`. - Tests only (`TessellationLowering.cpp` restored from `main`): `agc_driver_tessellation` fails on both devices with `tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0`. - With the fix: `agc_driver_tessellation` and `agc_tessellation_factor_ring` pass 3/3 on the RTX 3070 and 3/3 on lavapipe. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
savvaniss commented 2026-10-17 13:10:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-17T13:10:11Z.


Intel and AMD Windows data: the new cases pass on both GPUs with this change and fail on both without it.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. "Without" means this PR's test files on main c9e6c45de, with none of its other changes.

UHD 770 RX 9070 XT
This head 41972eeb9 merged into main ca82d7d88: agc_driver_tessellation, ×3 pass pass
Without, ×3 fails: tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0 fails, same

Full CTest (--parallel 4) on main c9e6c45de with seven open GPU PRs merged (#6258, #6657, #6324, #6246, #6174, #6360, #6598): UHD 770 1381 of 1389, RX 9070 XT 1383 of 1389. main alone passes 1378 of 1385 and 1381 of 1385. The merge adds only two failures: agc_buffer_pool (#6174, both GPUs) and agc_driver_indirect_dispatch_limit (#6360, RX 9070 XT).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234269714 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657#issuecomment-6234269714). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-17T13:10:11Z. --- Intel and AMD Windows data: the new cases pass on both GPUs with this change and fail on both without it. Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, `ANYPS5_NO_SHADER_CACHE=1`, serial CTest. Intel UHD Graphics 770 (`8086:a780`), driver 32.0.101.7088. AMD Radeon RX 9070 XT (`1002:7550`), driver 32.0.31041.1004, with `VkCache` emptied first. "Without" means this PR's test files on `main` `c9e6c45de`, with none of its other changes. | | UHD 770 | RX 9070 XT | |---|---|---| | This head `41972eeb9` merged into `main` `ca82d7d88`: `agc_driver_tessellation`, ×3 | pass | pass | | Without, ×3 | fails: `tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0` | fails, same | Full CTest (`--parallel 4`) on `main` `c9e6c45de` with seven open GPU PRs merged (#6258, #6657, #6324, #6246, #6174, #6360, #6598): UHD 770 1381 of 1389, RX 9070 XT 1383 of 1389. `main` alone passes 1378 of 1385 and 1381 of 1385. The merge adds only two failures: `agc_buffer_pool` (#6174, both GPUs) and `agc_driver_indirect_dispatch_limit` (#6360, RX 9070 XT). AI-assisted: yes (Claude Code)
klosixgaming-arch commented 2026-10-19 00:51:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-19T00:51:49Z.


Tested on Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 5090 (driver 617.42), Ryzen 9 9950X3D. Head 41972eeb9 merged onto current main (a373e85e5); the merge is clean.

  • agc_driver_tessellation passes with the change.
  • On main with only this PR's test file (tests/execution/Tessellation.cpp) the same test fails with tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0, the refusal quoted in the description. So the new cases do exercise the fix.

Not tested: PPSA12361 (no dump here). I skimmed dependsOnRelative and windowLoadObserves but did not check their soundness line by line. Since this relaxes a refusal, a mistake would silently accept a real data use of the index; the negative cases in the test (restored exec before the store, window load after the address store, LocalIndexAsData) still pass, but they only cover the shapes the author thought of. I am leaving this as a test report rather than an approval.

AI-assisted: yes. Written with AI assistance and reviewed by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6257331926 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657#issuecomment-6257331926). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-19T00:51:49Z. --- Tested on Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 5090 (driver 617.42), Ryzen 9 9950X3D. Head `41972eeb9` merged onto current `main` (a373e85e5); the merge is clean. - `agc_driver_tessellation` passes with the change. - On `main` with only this PR's test file (`tests/execution/Tessellation.cpp`) the same test fails with `tessellation lowering: the relative patch or vertex index is used outside a tessellation ring or LDS address at pc 0x0`, the refusal quoted in the description. So the new cases do exercise the fix. Not tested: PPSA12361 (no dump here). I skimmed `dependsOnRelative` and `windowLoadObserves` but did not check their soundness line by line. Since this relaxes a refusal, a mistake would silently accept a real data use of the index; the negative cases in the test (restored exec before the store, window load after the address store, `LocalIndexAsData`) still pass, but they only cover the shapes the author thought of. I am leaving this as a test report rather than an approval. AI-assisted: yes. Written with AI assistance and reviewed by me.
adriadam10 commented 2026-10-19 07:45:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T07:45:20Z.

Review: CHANGES_REQUESTED


Thanks for the change and the thorough third-party runs. One correctness problem blocks it:

  • core/shader/recompiler/Optimization/src/TessellationLowering.cpp:256 (ImpliesNot): for predicate = !p it returns Implies(p, condition). p => condition does not give !p => !condition. Example: p = a && b, condition = a, predicate = !(a && b). With a = true, b = false the predicate holds and the select takes its first arm, but dependsOnRelative follows only the second arm and can accept an index that is observed. The sound cases are p == condition (then !p => !condition), or the other direction, condition => p. Please fix it (probably only the equality case, since Implies only looks at LogicalAnd on the left) and add a test whose masked-select predicate is a negated conjunction where the observed arm carries the index, which must stay refused.

The rest of the diff (the CarriesRelativeBits set, the window-load reachability walk, the existing refusals kept) reads fine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5568379046 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657#pullrequestreview-5568379046). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T07:45:20Z. **Review:** CHANGES_REQUESTED --- Thanks for the change and the thorough third-party runs. One correctness problem blocks it: - `core/shader/recompiler/Optimization/src/TessellationLowering.cpp:256` (`ImpliesNot`): for `predicate = !p` it returns `Implies(p, condition)`. `p => condition` does not give `!p => !condition`. Example: `p = a && b`, `condition = a`, `predicate = !(a && b)`. With `a = true, b = false` the predicate holds and the select takes its first arm, but `dependsOnRelative` follows only the second arm and can accept an index that is observed. The sound cases are `p == condition` (then `!p => !condition`), or the other direction, `condition => p`. Please fix it (probably only the equality case, since `Implies` only looks at `LogicalAnd` on the left) and add a test whose masked-select predicate is a negated conjunction where the observed arm carries the index, which must stay refused. The rest of the diff (the `CarriesRelativeBits` set, the window-load reachability walk, the existing refusals kept) reads fine.
DavidAmsellem commented 2026-10-19 17:22:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T17:22:04Z.


First AMD-on-Linux (RADV) run of this PR. Merged onto main dbac9fa15 (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1638/1640 with this PR, against 1638/1640 on main. The failures are the same two on both, so this PR adds none: agc_driver_image_table_vouched_lookups (#7766, fixed by #7916) and agc_driver_guest_memory_lifetime (#7784).

agc_driver_tessellation, agc_tessellation_lowering and agc_tessellation_factor_ring run and pass. The PR adds no new ctest entry, and no test is skipped or removed compared with main.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6273048200 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657#issuecomment-6273048200). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T17:22:04Z. --- First AMD-on-Linux (RADV) run of this PR. Merged onto `main` `dbac9fa15` (clean merge), built in full and compared with the same `main`, on the same machine. AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. Full suite (`ANYPS5_REQUIRE_VULKAN=1 ctest -j8`): **1638/1640 with this PR, against 1638/1640 on `main`**. The failures are the same two on both, so this PR adds none: `agc_driver_image_table_vouched_lookups` (#7766, fixed by #7916) and `agc_driver_guest_memory_lifetime` (#7784). `agc_driver_tessellation`, `agc_tessellation_lowering` and `agc_tessellation_factor_ring` run and pass. The PR adds no new ctest entry, and no test is skipped or removed compared with `main`. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes
DavidAmsellem commented 2026-10-19 18:16:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T18:16:49Z.


First AMD-on-Linux (RADV) run of this PR. Merged onto main dbac9fa15 (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8) at 4779e727d: 1638/1640 with this PR, against 1638/1640 on main. The two failures are the same on both, so this PR adds none: agc_driver_image_table_vouched_lookups (#7766, fixed by #7916) and agc_driver_guest_memory_lifetime (#7784).

Comparing the JUnit output with main: this PR adds no ctest entry, and none is skipped or removed.

This checks correctness only; I did not measure performance.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6274104655 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657#issuecomment-6274104655). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T18:16:49Z. --- First AMD-on-Linux (RADV) run of this PR. Merged onto `main` `dbac9fa15` (clean merge), built in full and compared with the same `main`, on the same machine. AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. Full suite (`ANYPS5_REQUIRE_VULKAN=1 ctest -j8`) at `4779e727d`: **1638/1640 with this PR**, against 1638/1640 on `main`. The two failures are the same on both, so this PR adds none: `agc_driver_image_table_vouched_lookups` (#7766, fixed by #7916) and `agc_driver_guest_memory_lifetime` (#7784). Comparing the JUnit output with `main`: this PR adds no ctest entry, and none is skipped or removed. This checks correctness only; I did not measure performance. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes
MarcZX10 commented 2026-10-21 23:59:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:59:11Z.


One checklist item remains incomplete independently of the code concern in the existing changes-requested review. CONTRIBUTING.md requires a title unblock to name both the title ID and its Game bring-up discussion. The current line says Unblocks: PPSA12361 (no Game bring-up discussion yet), so it does not meet that format. Please add the discussion link if this PR is intended to unblock the title, or use none if it is not.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329268781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6657#issuecomment-6329268781). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:59:11Z. --- One checklist item remains incomplete independently of the code concern in the existing changes-requested review. `CONTRIBUTING.md` requires a title unblock to name both the title ID and its Game bring-up discussion. The current line says `Unblocks: PPSA12361 (no Game bring-up discussion yet)`, so it does not meet that format. Please add the discussion link if this PR is intended to unblock the title, or use `none` if it is not.
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!6657
No description provided.