feat(agc): accept graphics programs without an AGC shader header #1732
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1732"
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 TheAggie on 2026-10-08T17:51:29Z.
What
A draw resolves each stage's program address (
SPI_SHADER_PGM_LO/HI_*) against the shaders registered throughsceAgcDriverRegisterShader. An address outside every registration threwgraphics program does not belong to a compatible registered shader. Dispatches already fall back to reading the code from guest memory (ReadRawComputeShader).RADV on the PS5 (mihawk-99/PS5_Mesa) never registers its shaders. It uploads ACO's code to GPU memory and programs the registers directly, as on Linux. Every RADV draw was dropped: ccleste (PPSA59322) presented only black frames.
Rule (from review). An empty shader registry is known before the draw, so it is the reason a graphics program may be read without registration:
ProgramSnapshot(registry, address, types)returns the registered program of a compatible type.ReadRawComputeShader, renamedReadRawShader).main.RegisterShaderthrowsa shader was registered after graphics programs were drawn without registration. A title that registers shaders after drawing unregistered programs isn't understood yet, so it stops where that happens.main's own compute fallback (RegisteredProgram, thenReadRawShader).Header-less programs:
Drawleaves out empty memory regions, so no empty header region reachesRequestMemoryView.DecodeVertexStageInforeturns no embedded fetch for an empty header. RADV vertex shaders load their own attributes.Preparation.
ReportPreparedAtUseaccepts an unregistered graphics program and prepares it at first use, asmaindoes for unregistered compute programs. For a rect-list draw whose programs are unregistered,DrawcallsResolvePreparedGraphics(front, fragment, 17, …)beforePreparedRectangle. Registration would otherwise have prepared the rectangle shaders.Draw cache. The register draw key identifies an unregistered program only by its address, and a key hit reused the entry's decode without reading the program again. A key hit now re-reads each raw program (
DecodeProgramsCurrent, throughReadRawShader's by-value check) and drops the entry when one changed. Registered programs are not checked.Tests:
agc_driver(testProgramSnapshots):agc_driver_graphics(HeaderlessVertexStageTests): a header-less vertex program gets no fetch table, and a truncated non-empty header still throws.agc_driver_prepared_unregistered_graphics:RegisterShaderthrows.InvocationForprepares each stage once and reuses it, also for a relocated push-constant block.PreparedRectanglefinds the rectangle shaders afterResolvePreparedGraphics.RegisterShadercheck removed, it fails.agc_driver_prepared_graphics: a registry that holds other shaders but not this program still rejects the decode with "registered".Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti. Rebased onto
maine28fbc27.agc|shader|recompiler|guest: 589 passed, 1 skipped, 5 failed. Those five fail the same way onmainhere:guest_memory(dlopen) andguest_filesystem(creating a symbolic link needs Developer Mode on this machine);agc_driver_cmask_fast_clear,agc_driver_conservative_rasterizationandagc_driver_ngg_vertex_wave_info(vkWaitForFencestimeouts on this machine).mainccleste now stops earlier, at_umtx_op(#1482), thenpthread_set_name_np(#3031) andpthread_attr_getscope.Not tested on AMD, Intel or Linux.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T19:49:29Z.
Heads-up: since #639, graphics programs are prepared at registration and only unregistered compute programs fall back to preparing at dispatch, so this PR as it stands would now stop at
unregistered program is not a compute shader. I'm reworking it to give unregistered graphics programs the same fallback (including the rect-list path) and will update the branch and description when it's tested; no need to review the current version.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T20:08:51Z.
Updated for #639: unregistered graphics programs are now prepared at first use (and their rect-list shaders resolved before
PreparedRectangle), while the registration-time static-ABI decode still requires registered programs. New GPU testagc_driver_prepared_unregistered_graphics; the description is updated. Ready for review.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T01:22:26Z.
Linux results, since this was tested on Windows only. Everything passes here.
Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
BUILD_TESTING=ON. This PR merged ontomain29e533ac.main29e533acmain+ this PRctest -R agc_driver -j1-E agc_driver)The CPU failure is
guest_dynamic_loader, which fails the same way onmain.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:32:47Z.
Review: APPROVED
Reviewed the current head and full diff, including unregistered program resolution, cache invalidation, the headerless vertex path, and the new GPU regression. The issue raised after #639 is addressed in this revision. The reported Linux results from fisherjoey cover NVIDIA and RADV; upstream check rollup is still empty, so CI has not reported on this head.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T22:31:05Z.
Could this decide up front which programs are deferred, the way #1836 does (a header that is missing for a known reason), instead of compiling whatever wasn't registered at the first draw? Anything else should still throw at registration.
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T07:50:19Z.
@oneandonlydean thanks for the pointer to #1836. Before I change the code, here's the rule I'd like to use. Please say if it isn't what you meant.
Where this stands. At draw time
DecodeGraphicsProgramsis called withstaticAbifalse, so as written this PR prepares any unregistered graphics program at its first draw. That's the behaviour you objected to.Proposed known reason: the title registers no shaders at all. RADV on the PS5 builds and places its own programs and never calls
RegisterShader. AGC titles register every program before drawing it. I logged both on Windows (local build, logging not committed):So a draw would read an unregistered graphics program raw only while the registry is empty. As soon as any shader has been registered, an unregistered program throws
graphics program does not belong to a registered shaderas it does today. A title that registers shaders and then draws one it didn't register still stops there.The decision is made at the draw, before any preparation, from the registry state. The raw path stays the one unregistered compute shaders already take. Compute itself wouldn't change: unregistered compute shaders on
mainare prepared at dispatch whatever the registry holds. I can apply the same rule there too if you prefer, but that would be a behaviour change for compute, so I'd keep it out of this PR.Two questions:
Once you're happy with the rule I'll implement it, with tests for both sides, and update #1825 on top.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T08:06:34Z.
It also conflicts with main in
DrawDecode.cppandShaderRegistry.cpp; please rebase with the change.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T18:08:36Z.
The rebase is in, but not the rule from my answer above:
ProgramSnapshot(DrawDecode.cpp) still reads any unregistered graphics program raw, andtestProgramSnapshotsexpects that with shaders registered. Please read raw only while the registry is empty, throw atRegisterShaderonce raw draws have happened, and update the description to match.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-10T18:26:51Z.
Additional empty-registry title evidence: PPSA99902
Sonic Unleashed Recompiled (PPSA99902, 01.003.000) reaches the existing graphics-program refusal after local startup-library validation. This report checks the registry at that refusal; it does not claim to have tested this PR's head or fixed rendering.
Windows 11 Enterprise 26200, RTX 5080, WinLibs r7 GCC 15.2.0, Release,
BUILD_TESTING=ON. The conditional local stack is based on57f96fd2, commitf61e0d7768005504fc70ea385534182a2061ebfb; the executable uses the main relinker at that snapshot withunused-filter=2. Main's AGC/AGC-driver source did not change between that snapshot and freshly fetchedbf6e25a1. Unmodified-main startup still stops earlier atdup.Program-name validation and the controlled comparison explain the prerequisites. With the native
getprognameimplementation, five runs reached RTX 5080 Vulkan device readiness and swapchain creation, then stopped at:To identify the exact registry state, temporarily added this diagnostic immediately before the unchanged
require(it != registry.begin(), ...)inDecodeGraphicsPrograms:Two startup runs agreed:
Both exited
0xC0000409after 6.545 and 6.657 seconds. The immutable diagnostic runtime profile changed onlylibSceAgcDriver.prxfrom the program-name comparison profile. The logging leaves the throwing guard and all decoding/preparation behavior intact. Source was restored; full system libraries rebuilt.agc_driver,agc_driver_graphicsandagc_driver_prepared_graphicspassed 5/5 each both with the diagnostic and after restoration, with no skips and every test below 30 seconds (largest about 4 seconds).This title's observed failing draw has an empty registry and
staticAbi=false, so it supplies another measured case relevant to the agreed empty-registry policy. It does not validate accepting missing programs when registered shaders exist, or registration after raw draws. Those remain the separate refusal cases required by the review.Original unwrapped executable SHA256
c34f5b0848ef49e96a855076d8254254047e966e4fe56589d0e504fe13828479; baseline libraries and guest libc preserved. No rendering/gameplay, Linux or console claim. Logs, manifests and temporary patch retained locally outside the repository. AI-assisted investigation: Codex. No new PR or branch push.Current-main confirmation: refreshed the local diagnostic stack onto main
bf6e25a1ddc009eb232fdfdb3e6ff58b962df006(local commit1c2b72a0941314b063e0993f4c74b05dc67d72df) and rebuilt full libraries plus the relinker. All 30 TLS coverage groups and five relevant library tests passed 5/5 each; conventions and test registration passed. Reconverted the original title in both filter modes in an isolated output directory. Five strict-filter startup runs again reached the RTX 5080 Vulkan device/swapchain and the same shader-registration refusal; the default-filter stop remains missingpathconf(oc98+zOImus). The new strict executable and guest libc are bit-for-bit identical to their earlier-main conversion, so the recent TLS change does not change these particular artifacts. Baseline runtime-library and original-source hashes verified after all runs. No rendering/gameplay or standalone-current-main compatibility claim; other local prerequisites remain in this stack.Follow-up: exact-head tests, policy correction and controlled title comparison
Now tested #1732 head
00fcac677eda65daa66e8498364a71f3e57e8d08: replayed its four exclusive commits onto pinned main1476f76941a789690fd0f9c84c1cc929bb6fe262, with full libraries and the four existing relevant AGC test groups passing 5/5 each on Windows 11 Enterprise 26200, RTX 5080, WinLibs r7 GCC 15.2.0, Release,BUILD_TESTING=ON.Additional behavioral probes confirm the two gaps in the agreed review policy:
DecodeGraphicsProgramsaccepted a raw program with an unrelated registered shader present. Empty-registry raw decoding succeeded too. Existing tests passing did not cover this refusal.sceAgcDriverSubmitDcb, followed byAgcDriverWaitIdle, completed a raw vertex/pixel draw; a subsequent valid compute-shader registration succeeded. This is a real driver-path probe, not only a registry helper call.An unpublished local correction (
7c2a34b64099e597403e80c182c422056992dd24) restricts raw graphics to!staticAbi && registry.empty(), tracks entry into the raw draw path after prechecks, and refuses later registration under the driver mutex. It also checks the live registry when an earlier submission captured an empty registry, and rechecks registration at publication. Compute raw lookup remains available with a nonempty registry. No console or instruction semantics were added.New behavioral tests cover nonempty/static-ABI refusal, supported registered lookup, preserved compute lookup, two completed raw draws followed by registration refusal, zero-count draws followed by successful registration, a registered-first raw draw refusal, and a wait-gated submission whose captured empty registry becomes stale before execution. All 15 relevant test groups passed five repetitions before and after mutation testing, with no skips and a largest restored test of 4.03 seconds. Four deliberate changes were caught by the intended assertions: broadening the fallback, removing the draw marker, removing the live-registry check, and removing the early registration check. The final publication guard remains in place; its narrow concurrent-preparation race was not separately mutation-tested. Full libraries restored; conventions and test registration passed. An initial new-test teardown failure was fixed by using the existing availability-probe scope and explicit driver shutdown pattern; its failing log is retained locally.
For PPSA99902, copied the preserved 120-PRX diagnostic profile at
1c2b72a0941314b063e0993f4c74b05dc67d72dfand changed onlylibSceAgcDriver.prxto the independently built proposal plus correction above. The executable and guest libc remain the verified bf6-main conversion, whose relinker source is unchanged at main1476. This is a conditional runtime with other local prerequisites, not standalone current-main compatibility.Five strict-filter runs (6.834, 6.781, 6.856, 6.752, 6.702 seconds) passed the previous registration refusal, prepared raw vertex
0x205830e00, pixel programs0x205831000/0x205831200, and rectangle variants, then stopped atAGC graphics: unsupported color tile mode(0xC0000409). Restoring the earlier profile both before and after reproduced the original registration refusal. Default filtering still stops atpathconf(oc98+zOImus). No rendering, gameplay or physical-audio result is claimed.Fresh unmodified main1476 has merged
dup; its first stop in both filter modes is now unresolvedfork(cjt-4ySmYTs) before entry. The earlier first-stop observations in this thread are pinned historical results.Baseline integrity after the comparisons: all 123 original runtime-library files and guest libc match preserved copies; original
eboot.binremains SHA256c34f5b0848ef49e96a855076d8254254047e966e4fe56589d0e504fe13828479. Title-generated cache/configuration files are outside that claim. Reports, test logs, probes, manifests and temporary diagnostic patches are retained outside the repository. No new PR or branch push. AI-assisted investigation and local correction: Codex.Color-target follow-up: the rejected descriptor is confirmed as
COLOR_SW_MODE=0x1a(SW_64KB_D_X); exact fields and independent decoder controls are now reported in #2970. This is a separate explicit unsupported color-target mode, with no speculative layout change included.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:59:05Z.
Review: DISMISSED
Checked against the head (
00fcac677) and the thread. Dean's rule from the comments above is not in this head yet, and it conflicts withmain:ProgramSnapshot(DrawDecode.cpp:106) still falls back toReadRawShaderfor any unregistered address, with shaders registered. Per the agreed rule: read raw only while the registry is empty, and throw atRegisterShaderonce raw draws have happened.testProgramSnapshots(tests/Submit.cpp) currently pins the opposite and needs to change with it.main(conflicts inDrawDecode.cppandShaderRegistry.cpp), then rerunagc_driver,agc_driver_graphicsandagc_driver_prepared_unregistered_graphics.Linux results from @fisherjoey and the approval from @MarcZX100 are for the previous head, so they will need repeating after the change.
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-11T00:18:42Z.
@oneandonlydean done, in
39fdc48bon top of a rebase ontomaine28fbc27:ProgramSnapshotreads an unregistered graphics program raw only while the registry is empty. With any shader registered it throws asmaindoes (graphics program does not belong to a compatible registered shader).RegisterShader: a draw that uses a raw program is noted, andRegisterShaderthrows once that has happened.testProgramSnapshots: now expects the throw with shaders registered, and raw reads only with an empty registry.agc_driver_prepared_unregistered_graphicschecks theRegisterShaderrefusal after a raw draw, and fails without it.agc_driver_prepared_graphicsrejects a decode against a registry that holds other shaders.main's own compute fallback.ReportPreparedAtUseaccepts an unregistered graphics program, where it only accepted compute before.AI-assisted (Claude Code).