fix(agc): prepare a rect-list draw's missing rectangle at draw from its prepared stages #1928
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1928"
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-09T00:16:15Z.
Closes #1927
What
A rect-list draw needs a prepared rectangle for its (front, vertex variant, fragment variant). Rectangles are built only when the title resolves the graphics ABI through
sceAgcCreateInterpolantMapping. A fragment variant prepared at the draw (the null pixel program, or a shader deferred at registration) therefore has none, and the draw throwsprepared rectangle artifacts are missing.There are two commits:
refactor(agc): look up a rect-list draw's rectangle through DrawRectanglemoves the lookup intoDrawRectangle(front, fragment, vertexId, fragmentId, target). Behaviour is unchanged.fix(agc): prepare a rect-list draw's missing rectangle at draw from its prepared stages: when the lookup misses,DrawRectanglelogs it, callsResolvePreparedGraphics(front, fragment, 17, target)and looks it up again. Any other failure still throws.Tested
Linux (Nobara 44, GCC), RTX 5070 Ti, NVIDIA 595.91.07.
The new check in
tests/execution/PreparedGraphics.cppprepares a fragment variant that was never linked to the front through the ABI, then draws a rectangle with it throughDrawRectangle.ctest -R agc_driver_prepared_graphicsmain1be6f9f1+ commit 1 (lookup moved, no behaviour change) + the testAGC driver: prepared rectangle artifacts are missingRect-list draw of shader ... has no rectangle for fragment shader ...; preparing it at drawThe test can't run on
mainwithout commit 1. The draw path has no function a test can call short of a full GPU draw, and the ctest suite has no harness for that. Commit 1 adds that function without changing behaviour, so the test builds and fails there because of the bug, not because it doesn't compile. I can squash the two commits if you prefer one.The
agc_driver_prepared_shaders*tests andpixel_ancillaryalso pass on the combined branch.Stray, with #1902: without this change it aborts on the first rect-list draw that uses the null pixel program. With it, the log shows
Rect-list draw of shader 0x200bbe0000 has no rectangle for fragment shader ...; 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 klosixgaming-arch on 2026-10-09T00:46:20Z.
Review: APPROVED
Small, correct, and the test strategy is the right one for a code path that otherwise can only be reached by a full GPU draw.
DrawRectangle) is behaviour-preserving and gives a callable seam for the test — good reasoning, and the test genuinely fails onmain+commit-1 and passes on this branch.ResolvePreparedGraphics, then re-looks-up; any other failure still throws. No silent stub, no guessing.One note (non-blocking): the fallback hard-codes
17as theprimitiveTypepassed toResolvePreparedGraphics. Everywhere else the primitive type comes from the decoded draw state. If a rect-list draw can legitimately be issued with a different primitive type, preparing with17may produce a rectangle that doesn't match. Please confirm rect-list draws are always type17(or pull the real value from the packet if not) — that's the only thing I'd want grounded before this is a long-term fix rather than a workaround.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T02:01:07Z.
#1825 and #1732 change the same lines in
Draw.cpp. Both callResolvePreparedGraphics(..., 17u, ...)before thePreparedRectanglelookup, but only when the vertex program is unregistered (programs[0].snapshot->header.empty()). This PR covers a different trigger: the vertex program is registered and the fragment variant was prepared at the draw (the null pixel program from #1902, or a shader deferred by #1836).So the changes don't duplicate each other, but they will conflict. Whichever lands first, I'm happy to rebase so both cases go through one helper (
DrawRectanglehere, which builds the rectangle when the lookup misses), or to drop that part if the other PR's version covers it once merged.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:37:11Z.
I verified the primitive-type question against the current decoder:
Graphics::DecodeStatesetsrectListonly for primitive values 7 or 17.ResolvePreparedGraphicsuses the value only to setrectangleRequestedwhen it is either 7 or 17; rectangle generation does not distinguish them. So passing 17 from this fallback is equivalent for any draw that reached the rect-list path.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:49:16Z.
Review: APPROVED
Reviewed the full diff and current head. The helper move is behavior-preserving, the fallback only runs on a missing rectangle, and the execution test exercises the prepared-fragment case. I checked that primitive values 7 and 17 both enter the rect-list path and generate the same rectangle request. Linux and Windows checks and Conventions are green. The author has also documented the distinct overlapping triggers in #1732/#1825 and offered to rebase as needed.
Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-09T07:44:41Z.
Tested this with Hades II (PPSA36082), together with a fix for the null program miss (the registration fix I described on #1902). The fallback kicks in once while the level loads, for the null fragment program, and the game goes on to gameplay without problems.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-09T11:55:26Z.
Uncharted: Legacy of Thieves Collection (PPSA05684) stops here once its fragment variants are prepared at the draw (locally: the null pixel program and its own shaders, see #1902):
I fixed it locally the same way (build the rectangle pair from the prepared stages at the draw and keep it with the snapshot) to reach the title's main menu. Separately, the fault buffer of the built control/evaluation shaders could collide with another stage's binding group; that fix is #2198. I have not run this branch itself with the title.
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T12:31:37Z.
Two more titles hit the case this PR fixes, on Linux with an RX 9070 XT (RADV).
main43972e69+ #1673, #1339, #1836, #1837, #1893, #2105, #2184, #2226, #2219, #1902:prepared rectangle artifacts are missing.Rect-list draw of shader 0x116643b200 has no rectangle for fragment shader 0x7f33…1700; preparing it at drawfour times. The fragment shader is the null pixel program that #1902 prepares at draw.color views of several array slices are unsupported, #2102).66dwas prepared at draw, with only(30a, 30b)and(30a, 30c)rectangles registered.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T12:44:50Z.
Astro's Playroom (PPSA01325) hits this on Windows with NVIDIA, right after #1902.
Setup:
main745b775e+ #1836 + #1837 + #1395 (rebased locally) + #1902, plus a local workaround forvertex fetch exceeds descriptor record count(no PR yet).AGC driver: prepared rectangle artifacts are missing.def0be10) it logsRect-list draw of shader 0x400201900 has no rectangle for fragment shader 0x7ff9c095b700; preparing it at drawand the draw goes through.compute shader 0x5001c6a00: AGC driver: guest memory is not readable at 0x28 (range 0x28+0x4). That is the #757-#759 stack.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:32Z.
Tested with Sonic Origins (PPSA05324) on Linux, R9 380 (RADV). Its depth/stencil clears are rect-list draws without a pixel program, so they stopped at
prepared rectangle artifacts are missingonce #1902 prepared the null pixel variants. With this PR, the log shows threeRect-list draw of shader ... has no rectangle for fragment shader ...; preparing it at drawlines, the clears run, and the title presents its SEGA logo. Testing branch:maind70b8998+ #2022, #2219, #1902, #1837, #425 and #1544.Bring-up thread: #2021
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-10T01:51:50Z.
Tested on Windows with Marvel's Wolverine (PPSA03671), after #1902.
Setup: Windows 11 Pro (10.0.26200), RTX 3070, GCC 15.2.0 UCRT (WinLibs), Release. This PR (
def0be10) merged onto main54f28f2d3with #1836, #1893, #1709, #1837, #1940, #2022, #2219, #1902, and a local change that letssceKernelSignalSemaaccept a count of 0. It merged without conflicts.Without this PR: the first presentation fails with
AGC driver: prepared rectangle artifacts are missing.With this PR: the rect-list draws pass. The next stop is a compute shader deferred at registration:
GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x00001140(GetBufferResource(ReadConst(GetSrtResource, Immediate), ..., probably #757's case.Limits: one title, one run each way. No frame is presented yet.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:05:20Z.
Checked the lookup move is behaviour-preserving, the fallback only runs on a missing rectangle (any other failure still throws), and primitive types 7/17 take the same rect-list path. Build + ctest of libSceAgcDriver green (273/273,
agc_driver_prepared_graphicspasses), CI green on this head, and several title runs in the thread confirm it. Merging.Note: #2261 touches the same lines in
Draw.cpp; whichever lands second needs a rebase.