fix(agc): skip unused pixel stages with retained export formats #5631
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5631"
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?
Imported from boykopovar/AnyPS5. Originally posted by moong15 on 2026-10-14T02:25:42Z.
What
Skip a bound pixel program when it has no enabled consumers or execution requirements, even if
SPI_SHADER_Z_FORMATretains a previous export format. Stellar Blade (PPSA13197 v01.141) issues depth-only draws in this state during loading. Main materializes the retained shader against the next path's unrelated userdata, producing an oversized buffer descriptor and a GPU wait/watchdog failure. In matched runs this is intermittent on main rather than a deterministic boot blocker; see the runtime results below.The captured sequence clears
CB_TARGET_MASK,CB_SHADER_MASK, andDB_SHADER_CONTROL, while retaining Z export format 1 and the preceding pixel program. Full shader-code comparison matched live memory, and the userdata matched the direct command writes. That evidence points to executing an unused stage, rather than stale shader code or corrupted register writes.This change:
COVERAGE_TO_MASK_ENABLEto the existing export/execution mask.DB_ALPHA_TO_MASKis enabled. This is conservative even withALPHA_TO_MASK_DISABLE, because the current Vulkan state decoder does not apply that override.The semantics come from AMD PAL, not a new console hardware measurement:
DbShaderControl, including its explanation of no-consumer PS suppression,SpiShaderZFormat, and GFX10 register definitions. The inferred behavior and alpha-to-coverage limitation are recorded in technical debt.Tested
Controlled comparison on main
2ba3147ac804a2e6e82d558a08f752d6627d4a74(PR head660d2e76a), Windows 11 Pro 10.0.26200, AMD Radeon RX 9070 XT, Windows driver32.0.32015.2008, GCC 15.2.0 UCRT, Release, SPIRV-Tools enabled. A separate worktree contains only this PR's changes; third-party inputs use the existing pinned checkouts. No unrelated local source changes or game settings participate in these tests.Both runs use identical final regression sources. The before run builds
Graphics/src/State.cppexactly from main; the after run recompiles it with this fix.agc_driver_graphicsagc_driver_prepared_graphicsagc_driver_draw_cache_reuseagc_driver_draw_cache_reuse_offagc_driver_register_keyRegression coverage includes formats 0/1/2/3/9; every export/execution bit; valid depth, stencil-reference and sample-mask export combinations; missing execution state; disjoint and high color masks; alpha-to-coverage and its override; and fixed-function depth/stencil operations and clear modes compared with an explicitly unbound pixel program. Preparation uses a nonzero retained address, the captured valid 20-word user SGPR count with 30 unrelated userdata words, a separate poisoned 63-word count, poisoned fragment input/export state, wave32/wave64, linked fragment roles, and draw-time variant reuse. Re-enabling color,
EXEC_ON_NOOP, or alpha-to-coverage restores the real program. The cache regression switches four states over 21 draws and checks four entries and 13 hits, both with and without GPL. Both cache CTest variants now setAPS5_VERIFY_DRAW_RECIPE=1andAPS5_VERIFY_REGISTER_KEYS=1themselves, and the test asserts that fresh-decode verification actually ran with no mismatches, so standard CTest covers it without extra environment.Reproduce with
ANYPS5_GPU="AMD Radeon RX 9070 XT",ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1:For the failing-before comparison, restore only
core/libs/prx/libSceAgcDriver/Graphics/src/State.cppfrom the base revision in a disposable checkout, rebuild, and run the same command. Restore the PR version afterward. All five focused suites pass with the fix; each finishes below 30 seconds.tools/check_conventions.py --base origin/mainand whitespace checks pass. Sanitized test logs: gist.October 14: matched game runs, main against this PR. Clean
main2ba3147acagainst this PR's head 660d2e76a, Stellar Blade PPSA13197 v01.141, same converted executable. The deployed libraries are identical exceptlibSceAgcDriver.prx(main76d86473…, PRf1dd7aac…), checked by SHA-256 on every run. Each run cleared inheritedAPS5_*/ANYPS5_*variables and set onlyANYPS5_GPU="AMD Radeon RX 9070 XT",APS5_HOST_IMPORT_MIB=8192andANYPS5_SHADER_CACHE_DIR(the run's private seed copy). The runner stopped a game whose private commit exceeded 42,000 MiB or when free memory fell below 3,000 MiB; that never happened. It also setAPS5_COMMIT_LIMIT_MIB/APS5_MIN_FREE_MIB, which AnyPS5 does not read. No tracing, image capture, runner timeout or other local patches were used. Each run started from a private copy of a shared shader-cache seed. Input was manual: only the gift dialog was claimed. The menu was confirmed by eye at the screen, then the game was closed by hand. All main runs of a seed ran before its PR runs; they did not alternate. No builds or tests ran concurrently.Seed 1 (6,818 files, 2,602,396,833 bytes), built by one cold main run, excluded:
guest sampler descriptor uses a secondary LOD bias which is not implementedbuffer descriptor uses an unsupported typeSeed 2 (10,795 files, 5,612,809,177 bytes), the final cache of PR seed-1 run 1:
buffer descriptor uses an unsupported typeMain reached the menu in 2 of 6 runs; this PR in 5 of 6. Three of six main runs ended in a host exception on a malformed descriptor during presentation, followed by
abort(); no PR run did. The failure is intermittent on main, not a deterministic boot blocker.The engine watchdog is Unreal's fixed 120 s
GameThread timed out waiting for RenderThread, followed by a deliberate guest access violation. It hit both builds, and only on seed 1. Seed 1 ends where the cold run stopped, so warm runs on it still compiled about 1,400–1,700 shaders late in loading. Runs on seed 2 added at most 22 cache files, and none hit the watchdog. This change does not address that stall.WAIT_REG_MEMtimeouts (2–5 per run) occurred on both builds with seed 1, including PR runs that reached the menu, and on neither with seed 2. Times are from process creation; "menu by" is when the menu was reported.Every main-only failure was a malformed descriptor, the failure class described in What: on main the retained pixel program reads the next draw's unrelated userdata as its resources. None occurred with this change. The native tests show the mechanism directly; the game runs show the matching outcome, though they did not trace each exception back to a specific draw. No gameplay, cold-cache reliability, other-title, Linux, console or other-GPU claim is made. The original game libraries were restored and hash-checked afterward. Per-run exits, peak commit, wait timeouts, cache totals and the only extracted log lines (paths and addresses removed) are in
runtime-runs.md.Earlier title runs (October 13, other local patches): with
APS5_FLAT_3D_COLOR_TARGET=1,APS5_CONTINUE_AFTER_FLIP_FAILURE=1and 16 prebuild threads, three fresh launches reached the menu. That is not a clean-main comparison; the matched runs above supersede it.Related open #5304 and #5521 address unused stencil export and alpha-to-coverage output support respectively; neither implements this skip predicate, and neither is a dependency.
Checklist
main; no other open PR implements the same fix.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T08:30:02Z.
Runs for this PR at head
660d2e76a. Windows 11, MinGW-w64 GCC 15.2.0 Release, two GPUs in one machine: Intel UHD Graphics 770 (driver 32.0.101.6129, picked withANYPS5_GPU=Intel) and RTX 4090 (NVIDIA 616.92).agc_compute_descriptor_layout_flags,agc_descriptor_pool_reset_failure,agc_driver_address_space_teardown,agc_driver_covered_centroid_state,agc_driver_draw_cache_reuse,agc_driver_draw_cache_reuse_off,agc_driver_graphics,agc_driver_prepared_graphics,agc_sparse_buffer_holes) pass on both GPUs.ctest -R "agc_driver|agc_masked|agc_shader" -j4: no failures on either GPU. Intel: 395 tests, 28 skipped. NVIDIA: 395 tests, 1 skipped (agc_driver_stencil_ref_export). The skips are the same as onmainwith each GPU. On the UHD 770 they are features it doesn't support: f64, 64-bit and float atomics, mesh shaders, fp16 interpolation and dot, shader clock.No difference between the two GPUs.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T08:59:29Z.
AMD and NVIDIA runs for this PR at head
660d2e76a. Windows 11 Pro 26200, WinLibs GCC 15.2.0 (MinGW-w64), Release, one machine with two GPUs, each picked withANYPS5_GPU:1002:13c0, RDNA 2), driver 32.0.21036.18ctest -R "agc|shader|video_out" -j 8(511 tests, including the ones this PR adds or changes):agc_driver_lds_mixed_width_atomics,agc_driver_pixel_interlockandagc_driver_layered_volume_vertex_no_gpl. These three fail the same way on currentmain(872f52320) on this GPU and pass there on the RTX 5070; they are the three of #5271, so not caused by this PR.No title run. AI-assisted: yes (Claude Code ran the builds and tests).
Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-14T19:51:51Z.
A second title this fixes: Stray (PPSA02100, Unreal Engine 4), Windows 11, RTX 5070, MinGW GCC 15, Release, driven with Enter presses (Cross) and run without a display.
main4c1de0c0cbuffer descriptor uses an unsupported typemain+ this PR + #5897The
mainresult matches all 5 earlier runs on oldermain. The descriptor is a 2D or 3D T# (…91b00f2e/…a1b00fac) in buffer slot 2 of 3 of a pixel shader. With the buffer bound empty locally, the next stop was a 3D T# in a 2D image slot of the same shader, as @nikowolf123 predicted in #5879. Neither stop appears with this PR, which fits a stale pixel program being skipped on a depth-only draw.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-14T20:57:34Z.
Stray (PPSA02101, the EU version of @p3n1cillin's #5879) on Intel, as @nikowolf123 suggested in #5894. Fedora 44, Intel Arc (Meteor Lake iGPU, Mesa 26.2.3 ANV), Release.
Setup.
maine154f5658with these on top:75083acb3, and #5897.The extra commits are needed because Stray's post-processing compute programs don't compile in time on ANV (#4977, #5405). Each run holds Enter (Cross) at the calibration screen and goes through the menu into the opening cinematic. It runs in a 12 GiB + 4 GiB swap cgroup (two of the runs with this PR: 13 GiB, no swap) at 0.1 to 0.5 FPS, and I took a screenshot every 30 s.
buffer descriptor uses an unsupported typemain66f89476, before #5897)The table counts only runs that left the main menu. With the PR, five runs went past frame 225.
I lost the log of the stopped run on the current stack, so I don't have #5897's line or the context registers for it. In the earlier ones the descriptor was the same T# (
20722c00 c3800000 001dc13f a1b00fac) in buffer slot 0 of a pixel shader.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T21:55:02Z.
Rebased onto main myself: the draw-cache test conflicted with #494, so
RetainedPixelCacheTransitionsnow starts fromDraws(32.0f, {})instead ofDrawThrice()minus its three draws. Merging once the build is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T22:46:38Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libSceAgcDriver.mdL48