fix(agc): run the device startup probes as RDNA when a PS4 title has selected GCN shaders #20156

Merged
Gag21 merged 3 commits from upstream-pr/20156 into main 2026-11-22 04:30:55 +00:00
Gag21 commented 2026-11-14 18:30:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gag21 on 2026-11-14T18:30:09Z.


What

A PS4 title selects GCN shader decoding for the whole process (ShaderRecompiler::SetGcnGuestShaders(true)) on its first Gnm submit. When the Vulkan device opens after that, its three startup probes fail: the f32 flush, f32 denormal preserve and f16 conversion probes are RDNA programs built into libSceAgcDriver, and they were decoded as GCN. The device constructor throws and the title stops:

ShaderRecompiler::Recompile: unknown GCN instruction family at program counter 40 raw word 3578462222

0xd54b000e is word 10 of MixedCode in FloatFlushProbe.cpp, an RDNA VOP3 instruction.

  • VulkanDevice's constructor now turns GCN decoding off for the three probes and restores the previous selection after them, also when a probe throws.
  • The existing GCN execution tests did not catch this because each opens its device first and selects GCN afterwards. The new test agc_driver_gcn_device_startup_probes selects GCN first, then opens a device, and checks that the selection is still on afterwards.
  • docs/dev/debt/libSceAgcDriver.md records the remaining limit: the selection is process-wide, so a guest shader that another thread recompiles during the probes of a second device would be decoded as RDNA in that time.

No shader, pipeline or draw path changes; only which decoder the three probe programs go through.

Tested

Windows 11 Pro 10.0.26300, i5-6600K, NVIDIA GeForce RTX 3070 (driver 621.01), WinLibs GCC 16.2.0, CMake 4.4.4, Ninja, Release, BUILD_TESTING=ON, on main a44e050e82.

  • New test agc_driver_gcn_device_startup_probes: passes on this branch. With only the VulkanDevice.cpp change reverted and the test kept, it fails with the message above.

  • Related tests: the tests matching ^agc_driver_(gcn|float|f16|f32|device|two_device) include the float flush and f16 conversion probe tests, the GCN execution tests and the two-device tests.

  • Validation layer comparison, same machine and GPU, Vulkan SDK 1.4.363.1 (VK_LAYER_KHRONOS_validation), with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer and ctest --test-dir build -R "^agc_driver_(gcn|float|f16|f32|device|two_device)" -V, each side rebuilt from its own source:

    Build Tests Insert instance layer "VK_LAYER_KHRONOS_validation" was not found but was requested VUID-
    main a44e050e82 49 of 49 pass 50 lines 0 0
    this PR 50 of 50 pass (the 49 and the new test) 51 lines 0 0

    The change adds no validation errors; neither log has any.

  • A title: a PS4 game dump (CUSA01709 01.02) converted with relinker --windows. It needs local changes that are not in this PR to get this far (#19959 to unwrap, a relinker change equivalent to #17105, a stand-in for #18087, the exports of #17711 and #19990, a relaxed fixed-address check in sceKernelMapDirectMemory, and a compute queue stand-in in place of #18546). With those, and without this change, it stops at device creation with the message above. With this change the device opens, the probes report ([float-controls] f32 denormal flush: hardware (0 of 5472 probe results differ ...)), and the title goes on to AGC graphics: PS4 color target fast clear (CMASK) is not implemented.

  • python tools/check_conventions.py --base origin/main passes. python tools/pr_overlap.py --branch failed closed (exit 2): it could not confirm overlap for open pull requests that conflict with main. I compared the 43 of them that touch VulkanDevice.cpp by their diffs; none changes the probes or the GCN selection (for #7642 and #9508, whose diffs are too large to fetch whole, by their VulkanDevice.cpp patch from the API). The others share only docs/dev/debt/libSceAgcDriver.md.

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: NVIDIA GeForce RTX 3070, driver 621.01, Windows 11 Pro 10.0.26300, validation layer 1.4.363
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5314814334 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20156). Originally posted by [Gag21](https://github.com/Gag21) on 2026-11-14T18:30:09Z. --- ### What A PS4 title selects GCN shader decoding for the whole process (`ShaderRecompiler::SetGcnGuestShaders(true)`) on its first Gnm submit. When the Vulkan device opens after that, its three startup probes fail: the f32 flush, f32 denormal preserve and f16 conversion probes are RDNA programs built into `libSceAgcDriver`, and they were decoded as GCN. The device constructor throws and the title stops: ``` ShaderRecompiler::Recompile: unknown GCN instruction family at program counter 40 raw word 3578462222 ``` `0xd54b000e` is word 10 of `MixedCode` in `FloatFlushProbe.cpp`, an RDNA VOP3 instruction. - `VulkanDevice`'s constructor now turns GCN decoding off for the three probes and restores the previous selection after them, also when a probe throws. - The existing GCN execution tests did not catch this because each opens its device first and selects GCN afterwards. The new test `agc_driver_gcn_device_startup_probes` selects GCN first, then opens a device, and checks that the selection is still on afterwards. - `docs/dev/debt/libSceAgcDriver.md` records the remaining limit: the selection is process-wide, so a guest shader that another thread recompiles during the probes of a second device would be decoded as RDNA in that time. No shader, pipeline or draw path changes; only which decoder the three probe programs go through. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 10.0.26300, i5-6600K, NVIDIA GeForce RTX 3070 (driver 621.01), WinLibs GCC 16.2.0, CMake 4.4.4, Ninja, Release, `BUILD_TESTING=ON`, on `main` `a44e050e82`. - **New test** `agc_driver_gcn_device_startup_probes`: passes on this branch. With only the `VulkanDevice.cpp` change reverted and the test kept, it fails with the message above. - **Related tests**: the tests matching `^agc_driver_(gcn|float|f16|f32|device|two_device)` include the float flush and f16 conversion probe tests, the GCN execution tests and the two-device tests. - **Validation layer comparison**, same machine and GPU, Vulkan SDK 1.4.363.1 (`VK_LAYER_KHRONOS_validation`), with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer` and `ctest --test-dir build -R "^agc_driver_(gcn|float|f16|f32|device|two_device)" -V`, each side rebuilt from its own source: | Build | Tests | `Insert instance layer "VK_LAYER_KHRONOS_validation"` | `was not found but was requested` | `VUID-` | |---|---|---|---|---| | `main` `a44e050e82` | 49 of 49 pass | 50 lines | 0 | 0 | | this PR | 50 of 50 pass (the 49 and the new test) | 51 lines | 0 | 0 | The change adds no validation errors; neither log has any. - **A title**: a PS4 game dump (CUSA01709 01.02) converted with `relinker --windows`. It needs local changes that are not in this PR to get this far (#19959 to unwrap, a relinker change equivalent to #17105, a stand-in for #18087, the exports of #17711 and #19990, a relaxed fixed-address check in `sceKernelMapDirectMemory`, and a compute queue stand-in in place of #18546). With those, and without this change, it stops at device creation with the message above. With this change the device opens, the probes report (`[float-controls] f32 denormal flush: hardware (0 of 5472 probe results differ ...)`), and the title goes on to `AGC graphics: PS4 color target fast clear (CMASK) is not implemented`. - `python tools/check_conventions.py --base origin/main` passes. `python tools/pr_overlap.py --branch` failed closed (exit 2): it could not confirm overlap for open pull requests that conflict with `main`. I compared the 43 of them that touch `VulkanDevice.cpp` by their diffs; none changes the probes or the GCN selection (for #7642 and #9508, whose diffs are too large to fetch whole, by their `VulkanDevice.cpp` patch from the API). The others share only `docs/dev/debt/libSceAgcDriver.md`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: NVIDIA GeForce RTX 3070, driver 621.01, Windows 11 Pro 10.0.26300, validation layer 1.4.363 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-16 22:49:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T22:49:45Z.

Review: COMMENTED


Reviewed — no blocking findings

The startup probes are scoped to RDNA decoding with restoration on normal exit and exceptions, and the new test checks that GCN selection is restored.

What I ran

Reviewed head 951474295f5980af1730d161bf6ca6f287093920. I read the prepared description, commits, manifest, diff, the full added test, and the changed source ranges in VulkanDevice.cpp; repository files were read through repo_read.py. No tests were run.

Results

Check Result Note
Changed code review passed No concrete defect found
Tests not run Results in the description are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

The changed test registration/build configuration and other callers of the process-wide GCN selection were not inspected. VulkanDevice.cpp was too large for the prepared files, so only lines 230–250 and 2770–2865 were read. files.json was unavailable through the reader; the manifest lists three changed files, two included in the review bundle and one excluded as too large. Test results and reported title behavior were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5929280045 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20156#pullrequestreview-5929280045). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T22:49:45Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The startup probes are scoped to RDNA decoding with restoration on normal exit and exceptions, and the new test checks that GCN selection is restored. ## What I ran Reviewed head `951474295f5980af1730d161bf6ca6f287093920`. I read the prepared description, commits, manifest, diff, the full added test, and the changed source ranges in `VulkanDevice.cpp`; repository files were read through `repo_read.py`. No tests were run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | No concrete defect found | | Tests | not run | Results in the description are author reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The changed test registration/build configuration and other callers of the process-wide GCN selection were not inspected. `VulkanDevice.cpp` was too large for the prepared files, so only lines 230–250 and 2770–2865 were read. `files.json` was unavailable through the reader; the manifest lists three changed files, two included in the review bundle and one excluded as too large. Test results and reported title behavior were not independently verified. ## To get this to a good state Nothing is required.
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!20156
No description provided.