fix(agc): prepare the null pixel program at draw when its variant was not prepared #1902
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1902"
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 fisherjoey on 2026-10-08T23:11:06Z.
Closes #1901
What
The driver's null pixel program is prepared only in its registration variants (0 user SGPRs). A draw without a pixel program uses the queue's
SPI_SHADER_PGM_RSRC2_PSuser count andSPI_PS_IN_CONTROLwave bit for it. When those differ from the registration variant,SourceHandleForandInvocationForthrowprepared shader artifact is missing for the requested static ABI.The root cause, found by @Raghav314: since #1178 the two
emplacecalls at registration did nothing, so the null program was registered with the wrong inputs, and a null pixel draw took the last bound pixel shader's user SGPR count.PrepareNullPixelProgram(device), which usesinsert_or_assignfor the program address,SPI_PS_INPUT_ENA/ADDRand RSRC2 (no user SGPRs).PreparedAtUse. For the null program it prepares a variant at the draw only for wave32, which registration doesn't prepare. Every other miss still throws as before.PreparedAtUsereturnssnapshot.prepared->deferredfor a registered shader, so a shader whose preparation #1836 deferred is still prepared at use.Tested
Linux (Nobara 44, GCC), RTX 5070 Ti, NVIDIA 595.91.07.
d83e608e adds
NullPixelMatchesRegistrationtoagc_driver_prepared_graphics: a null pixel draw with a previous shader's leftover state (4 user SGPRs, other inputs, a bound export mapping) must use the artifact prepared at registration. It fails without the fix and still fails with only part of it; it passes with all of it.ctest -R agc_: 248/248 on the RTX 5070 Ti and on RADV (Mesa 26.2.1).tools/check_conventions.pypasses.After the rebase onto
main00112489(with #1836), built withANYPS5_ENABLE_SPIRV_TOOLS=ON:agc_driver_prepared_graphicsandagc_driver_prepared_shaderspass, andctest -R agc_ -j1passes 278 of 279 on the RTX 5070 Ti. The one failure,agc_driver_dcc_keys_first_write, also fails on plainmain00112489on this GPU.The earlier at-draw check and its results:
New check
NullPixelAtDraw()intests/execution/PreparedShaders.cpp. It prepares the registration variant of the null pixel program, then requests a wave32, 4 user SGPR fragment variant at push offset 20 / capacity 108.ctest -R agc_driver_prepared_shadersmain1be6f9f1+ the test onlyprepared shader artifact is missing for the requested static ABI: ... stage=5 wave=32 pushOffset=20 pushCapacity=108 preparedLayouts= [0,128]._debug_failurepasses, as it expects a failure.agc_driver_prepared_graphicspasses tooStray: without this change it aborts on the first such draw (above). With it, the log shows
The null pixel program has no artifact for this draw (wave 64, 4 user SGPRs); preparing it at drawand the run continues to a later, unrelated error.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-09T07:42:55Z.
Hit this exact crash in Hades II (PPSA36082) and dug into why the null program misses in the first place. Two things:
With insert_or_assign there and a user count of 0, the draw matches the variant from registration and nothing needs compiling at draw. That's enough for Hades. The leftover wave32 bit would still need handling the same way, which your PR already covers.
I've got this on a branch with a test that goes through the real registration path. Happy to share it if you want to use any of it here. Your call how you want to handle it.
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T08:05:47Z.
Astro Bot (PPSA21567) hits the case this PR fixes, and the next stop is a rect-list draw with the same null pixel program.
Setup: RX 9070 XT (RADV / Mesa 26.2.4), Linux.
maina8b032b2+ #759 + #1836 + #1837 + CouchRiv's #1789 branch + this PR (fb6aefc2). The only conflict was with #1836 inShaderRegistry.cpp. I kept yourPreparedAtUseand made it returnsnapshot.prepared->deferredinstead offalsefor registered shaders.Without this PR: the run stops about 3 min in on
prepared shader artifact is missing for the requested static ABI ... stage=5 wave=64 pushOffset=0 pushCapacity=128 preparedLayouts= [0,128] [0,0].With it: the log prints
The null pixel program has no artifact for this draw (wave 64, 0 user SGPRs); preparing it at draw. The same frame then stops on:I added a local log in
PreparedRectangle:So the draw is a rect list that uses the null pixel program variant prepared at draw (
66d).ResolvePreparedGraphicsonly builds rectangle pairs from the variants prepared at registration, so no pair exists for66d.PreparedRectanglewould need to build the missing pair the same way when a stage was prepared at use. I'm leaving that to you, since it extends this PR. Happy to run a candidate on this title.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-09T11:55:25Z.
Uncharted: Legacy of Thieves Collection (PPSA05684) hits the same miss for the null pixel program on
main(a host address ending in2700, stage 5,pushOffset=20 pushCapacity=108, prepared layouts[0,128] [0,0]). Like @Raghav314 found, the root cause was theemplaceofSPI_PS_INPUT_ENA/ADDRdoing nothing; locally I prepare the null program withinsert_or_assign, no user SGPRs and an empty export mapping, so its registration variant matches the state its draws decode (a test that fails without it is in the branch below).The title also misses for its own registered shaders, which this PR does not cover:
It links libSceAgc statically, so the driver's ABI-resolution hooks never see its state and registration cannot predict the variant (here the push-constant layout). Locally I prepare a registered shader's missing variant at the draw and keep it with the snapshot (with an error log line), which gets the title to its main menu. In terms of this PR, that is
PreparedAtUseaccepting registered snapshots too. Would you accept that generalization, here or as a follow-up on top of this PR? The branch is XairRrR:feat/agc-prepare-unpredicted-shaders.Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T12:44:48Z.
Astro's Playroom (PPSA01325) hits this on Windows with NVIDIA.
Setup:
main745b775e+ #1836 + #1837 + #1395 (rebased locally), plus a local workaround forvertex fetch exceeds descriptor record count(no PR yet).AGC driver: prepared shader artifact is missing for the requested static ABI: address=140710654621184 stage=5 wave=64 pushOffset=0 pushCapacity=128 preparedLayouts= [0,128] [0,0]The address is 0x7ff9c095b600.
The null pixel program has no artifact for this draw (wave 64, 4 user SGPRs); preparing it at drawand goes on.Windows 11, RTX 3060 Laptop (NVIDIA 616.92), WinLibs GCC 15.2.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-09T14:47:34Z.
Tested with Sonic Origins (PPSA05324) on Linux, R9 380 (RADV). Its depth/stencil clear draws have no pixel program, and the title uses three null pixel variants: wave 64 with 0, 4 and 16 user SGPRs. Without this PR the first one stops at
prepared shader artifact is missing for the requested static ABI ... stage=5 wave=64 pushOffset=0 pushCapacity=128. With it, all three are prepared at draw. Then, with #1928 for their rect-list pairing, the clears run and the title presents its boot frames.Bring-up thread: #2021
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T15:38:57Z.
Thanks, all. @Raghav314, that was the root cause. Since #1178 the two
emplacecalls did nothing, so the null program was registered with inputs 0 while every draw asked for 2. The user SGPR count was wrong too: it came from the last bound pixel shader, which matches orbz22's 4 and NahuelGenchi's 0/4/16 variants.Fixed in d83e608e. Registration now uses
insert_or_assignfor the program address,SPI_PS_INPUT_ENA/ADDRand RSRC2 (no user SGPRs). A null pixel draw gets 0 user SGPRs and an empty export mapping, so it matches the registered variant. The at-draw path is now only for wave32, which registration doesn't prepare. The new check inagc_driver_prepared_graphicsdecodes a null pixel draw with a previous shader's leftover state (4 user SGPRs, other inputs, a bound export mapping) and requires the artifact prepared at registration. It fails on the previous head.ctest -R agc_passes on an RTX 5070 Ti and on RADV.I couldn't find your branch, so the test is mine. If you push yours, I'm happy to add it here with a Co-authored-by line.
@XairRrR, preparing registered shaders at draw is a bigger change than this PR. It decides when registered shaders compile, which oneandonlydean has asked boykopovar to rule on in #1836. I'd keep it as its own PR on top of this one.
@EdouardSence, once #1836 is in I'll rebase and return
snapshot.prepared->deferredfromPreparedAtUse, as you did.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-09T17:45:45Z.
Another title hitting #1901: Seeker: My Shadow (PPSA12500, Unity) stops with
prepared shader artifact is missing for the requested static ABI ... pushOffset=68 pushCapacity=60on the null pixel program. With this PR on top of #2169 it gets past it and keeps rendering.Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-10T01:51:49Z.
Another title hitting #1901: Marvel's Wolverine (PPSA03671) on Windows.
Setup: Windows 11 Pro (10.0.26200), RTX 3070, GCC 15.2.0 UCRT (WinLibs), Release. This PR (d83e608e) merged onto main
54f28f2d3with #1836, #1893, #1709, #1837, #1940, #2022, #2219, and a local change that letssceKernelSignalSemaaccept a count of 0.Without this PR: the first presentation fails with
prepared shader artifact is missing for the requested static ABI: ... stage=5 wave=64 pushOffset=0 pushCapacity=128 preparedLayouts= [0,128] [0,0].With this PR: the null pixel draws pass. The next stop is
AGC driver: prepared rectangle artifacts are missing(#1928).Merge note: with #1836 also applied,
SourceHandleForandInvocationForconflict. I resolved both asif (snapshot.prepared->deferred || PreparedAtUse(snapshot, request)), which keeps #1836's deferred shaders and this PR's at-draw path.Limits: one title, one run each way.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:17:07Z.
#1836 is merged, so this now conflicts in
ShaderRegistry.cpp; could you rebase as planned (snapshot.prepared->deferredfromPreparedAtUse)? It passed testing at d83e608e.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-10T05:57:11Z.
Rebased onto main
00112489as planned. New head: 1140f636.The only conflict was
SourceHandleForandInvocationForinShaderRegistry.cpp. Both now callif (PreparedAtUse(snapshot, request)), andPreparedAtUsereturnssnapshot.prepared->deferredfor a registered shader, so #1836's deferred shaders are still prepared at use. An unregistered program still goes through the compute check as before. Nothing else changed.Tested on an RTX 5070 Ti (NVIDIA 595.91.07), built with
ANYPS5_ENABLE_SPIRV_TOOLS=ON:agc_driver_prepared_graphicsandagc_driver_prepared_shaderspass, andctest -R agc_ -j1passes 278 of 279. The one failure,agc_driver_dcc_keys_first_write, also fails on plain main00112489on this GPU.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:10:20Z.
Rebased onto current
main(conflicts with #2257 and #1836 inShaderRegistry.cpp/.hpp, as Dean asked):SourceHandleForandInvocationForkeep yourPreparedAtUseand now callPrepareShaderWithDiagnostics; the header declares bothShaderPreparationContextandVulkanDevice. No other change.Checked on the rebased head: build + ctest of libSceAgcDriver/libkernel scope, 380/380 passed (
agc_driver_prepared_graphics,agc_driver_prepared_shadersincluded); merging on green CI.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T07:11:33Z.
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)core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppL37-39core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppL203-207, L257-261Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:32:26Z.
CI re-run: the only red job was
write-watch (macos-15-intel),write_watch_threadstiming out at 30 s. This PR doesn't touch write-watch code, the other four write-watch tests and the macos-15 job pass, so it's a runner flake. Merging once the re-run is green.