fix(agc): keep the user-data tables of a handed-off draw as they were at its draw packet #17024
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17024"
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 muhmuhkuh on 2026-11-08T08:26:12Z.
What
A draw handed to the finisher builds its stages after reading the packet. A later guest write can therefore change a pointed-to user-data table before the stage reads it.
With
APS5_DRAW_TABLE_SNAPSHOT=1, the driver keeps 256 bytes behind each user-data pointer at the draw packet. Shader memory reads those kept words when building the stages. The switch stays off by default and requiresAPS5_DRAW_PIPELINE; phase B ofAPS5_ABcan enable it. A block is kept only when the pending-write checks before and after copying accept it. Overlapping, unmapped, unaligned and otherwise unsupported blocks retain the existing path. The debt entry records the remaining limits.The inactive commit-time comparison commit and its specific test have been dropped. This PR now contains the snapshot and its wiring/word-by-word tests. Commit-time comparison integration with #15455 remains separate and is not claimed as tested here.
Tested
Windows 11, MinGW-w64 GCC 15.2.0, Release. Local rebased head:
434da344030ecfb4f30716908c25f26f3cc4b4e0; tested main:808a902ea17ccff6cab2d013fd5e702217d47f50.guest_standard_streamspasses solo on both main and this head, rc0. These runs use isolated, hash-bound executable/libc copies.agc_runtime_switches,agc_runtime_switches_refused,agc_shader_table_snapshot_reuse,agc_shader_table_snapshot_reuse_unmasked, andagc_shader_table_keep. Main passes the four existing cases. Their executables compile the relevant sources directly and do not importlibSceAgcDriver.prx.CheckGetdelimAndGetline: the secondungetcreturns -1. The precedingfscanfreturns 2 and the expected data. Main already removed that fixture throughff82682151b5f85c319f8fd109cff34052b15ce7; no libc diagnostic or unrelated libc fix is included in this PR.tools/check_conventions.py --base origin/mainandgit merge-tree --write-tree origin/main HEADpass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-08T20:26:15Z.
Review: APPROVED
Windows check of head
f9a3585a11, merged ontomain095ff72367(clean merge), with the validation layer on an NVIDIA and an AMD GPU. The switch does what the description says in a real draw on both. Two notes below, neither blocking from me.Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release,BUILD_TESTING=ON. Both GPUs, selected withANYPS5_GPU: an RTX 5070 Ti (driver 621.01) and the Ryzen 7 7700X's integrated Radeon (AMD 26.10.2).ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.Full
^agcsuite (-j 8), passed / total:mainAPS5_DRAW_PIPELINE=1APS5_DRAW_PIPELINE=1andAPS5_DRAW_TABLE_SNAPSHOT=1agc_driver_quad_pixel_maskon the RTX (#14341) andagc_driver_sample_order_grid_referenceon the Radeon (#9503).agc_driver_draw_recapture_on_change,agc_driver_queued_constant_ram_dumpandagc_driver_draw_unsupported_buffer_type_skip_refused. All three also fail onmainwithAPS5_DRAW_PIPELINE=1, so turning the switch on adds no failures.VUID-lines and no missing-layer lines in any run.agc_shader_table_keep,agc_shader_table_keep_compareand the switch tests pass in 3 of 3 runs on each GPU.tools/check_conventions.py --base upstream/mainpasses.A real draw, with a temporary test. No test here turns the switch on for a draw, so I ran one locally in the
DrawDataHitUserWordsfixture withAPS5_DRAW_PIPELINE=1. It holds the finisher with a blocker job, submits a draw whose table holds a V# for 0.25, waits for the packet to be read, rewrites the table to a V# for 1.0, then releases the finisher. The value is the brightest byte the draw wrote, with the same results on both GPUs from one run of each case:The next draw over the rewritten table wrote 255 in every case, so the draw cache didn't reuse the kept words.
1. The commit-time comparison isn't reached on today's
main. Keeps are only taken on the hand-off path, andtail.queueis only set on the other path (Draw.cpp:786). Each of the fourkeptTablescalls sits behindtail.queue != nullptr, so a comparison never sees a keep. I logged this:tail.queuewasn't set on any finisher job in the runs above or in the 68 fromagc_driver_draw_cache_reuse_draw_pipelineand_plan_verify, where 8 tables were kept, and no comparison ran with a keep. So the second commit does nothing until #15455 drops that condition, and the description's "the check the finisher runs at commit time" describesmainwith #15455 rather thanmaintoday. It might help to say so there. I didn't build the two together.2. Two parts of the switch have no test.
RuntimeSwitches, which only checks the name, no test refers to the switch, so as far as I can see nothing would fail ifKeepUserDataTablesstopped being called. The temporary test above could become one. I setPending::unknown = falseon the blocker job, becausePendingOverlapstreats an unknown job as overlapping everything. Mine waits a fixed 300 ms after the lookup counter moves, which you'd probably want to replace.!page.kept.Test(index)removed fromShaderMemory::read, both new tests still pass. They pass nopendingWrite, so their pages are never read word by word.One small thing: the description says a game run needs
APS5_DRAW_TABLE_SNAPSHOT=1. FromhandOffinDraw.cppit also needsAPS5_DRAW_PIPELINE, since without it no draw reaches the finisher. TheENVIRONMENT.mdentry could name it too.Not run: any title, or this PR merged with #15455.