Skip to content

fix(agc): keep the user-data tables of a handed-off draw as they were at its draw packet - #17024

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
muhmuhkuh:fix/agc-keep-draw-tables
Nov 16, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
muhmuhkuh:fix/agc-keep-draw-tables

Conversation

@muhmuhkuh

@muhmuhkuh muhmuhkuh commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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 requires APS5_DRAW_PIPELINE; phase B of APS5_AB can 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_streams passes solo on both main and this head, rc0. These runs use isolated, hash-bound executable/libc copies.
  • Five focused CPU/mock cases pass on this head: agc_runtime_switches, agc_runtime_switches_refused, agc_shader_table_snapshot_reuse, agc_shader_table_snapshot_reuse_unmasked, and agc_shader_table_keep. Main passes the four existing cases. Their executables compile the relevant sources directly and do not import libSceAgcDriver.prx.
  • The historical head reproduces the Windows abort in CheckGetdelimAndGetline: the second ungetc returns -1. The preceding fscanf returns 2 and the expected data. Main already removed that fixture through ff82682151b5f85c319f8fd109cff34052b15ce7; no libc diagnostic or unrelated libc fix is included in this PR.
  • tools/check_conventions.py --base origin/main and git merge-tree --write-tree origin/main HEAD pass.
  • Current paired Vulkan qualification remains open. Earlier local GPU runs returned rc0, but a co-located AGC DLL invalidated their source binding. They are excluded as evidence for this head. A subsequent local staging-helper error ended that test window. No GPU red/restore proof or performance result is claimed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA02015 (Death Stranding 2) Death Stranding 2: On the Beach (PPSA02015) #5424
  • GPUs tested: NVIDIA GeForce RTX 3080 Ti, driver 610.88, Windows 11 Pro 10.0.26200; current paired GPU source qualification pending as described above
  • AI-assisted: yes

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line build docs agc libSceAgc* labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 16831 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp L22
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp L28, L43
PR 17738 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp L22
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp L28, L43
PR 17943 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp L22
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp L28, L43
PR 18029 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp L22
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp L28, L43
PR 18293 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp L22
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp L28, L43
PR 19564 core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake L50
PR 19852 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L12844

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1896 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/ENVIRONMENT.md
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4472 docs/dev/ENVIRONMENT.md
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5609 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6186 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/ShaderMemory.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6481 docs/dev/debt/libSceAgcDriver.md
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 docs/dev/debt/libSceAgcDriver.md
PR 7002 docs/dev/debt/libSceAgcDriver.md
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7275 docs/dev/ENVIRONMENT.md
PR 7449 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_cache_reuse_tests.cmake
core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 7643 docs/dev/ENVIRONMENT.md
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 8246 docs/dev/ENVIRONMENT.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9335 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9345 docs/dev/ENVIRONMENT.md
PR 9356 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9712 docs/dev/ENVIRONMENT.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10049 docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_cache_reuse_tests.cmake
core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 10359 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10442 docs/dev/ENVIRONMENT.md
PR 10743 docs/dev/debt/libSceAgcDriver.md
PR 10757 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ENVIRONMENT.md
PR 10867 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 11435 docs/dev/ENVIRONMENT.md
PR 11436 docs/dev/ENVIRONMENT.md
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 11551 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11825 docs/dev/debt/libSceAgcDriver.md
PR 12324 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ENVIRONMENT.md
PR 12746 docs/dev/ENVIRONMENT.md
PR 12828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12849 docs/dev/ENVIRONMENT.md
PR 12904 docs/dev/debt/libSceAgcDriver.md
PR 13809 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp
core/libs/prx/libSceAgcDriver/tests/RuntimeSwitches.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp
core/libs/prx/libSceAgcDriver/tests/RuntimeSwitches.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_cache_reuse_tests.cmake
core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_cache_reuse_tests.cmake
core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13963 docs/dev/debt/libSceAgcDriver.md
PR 14032 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
PR 14262 docs/dev/ENVIRONMENT.md
PR 14944 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
docs/dev/debt/libSceAgcDriver.md
PR 15343 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 15456 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DrawDataHitUserWords.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15529 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15548 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15570 docs/dev/ENVIRONMENT.md
PR 15621 docs/dev/debt/libSceAgcDriver.md
PR 16260 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 16371 docs/dev/ENVIRONMENT.md
PR 16372 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
docs/dev/ENVIRONMENT.md
PR 16483 docs/dev/debt/libSceAgcDriver.md
PR 16753 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/ENVIRONMENT.md
PR 16793 docs/dev/ENVIRONMENT.md
PR 17259 docs/dev/ENVIRONMENT.md
PR 17557 docs/dev/ENVIRONMENT.md
PR 17558 docs/dev/ENVIRONMENT.md
PR 17611 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 17729 docs/dev/ENVIRONMENT.md
PR 17915 docs/dev/debt/libSceAgcDriver.md
PR 17956 docs/dev/debt/libSceAgcDriver.md
PR 18139 docs/dev/debt/libSceAgcDriver.md
PR 18173 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp
docs/dev/ENVIRONMENT.md
PR 18226 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp
docs/dev/ENVIRONMENT.md
PR 18515 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 19429 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp
docs/dev/ENVIRONMENT.md
PR 20084 docs/dev/debt/libSceAgcDriver.md
PR 20187 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 20315 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DrawDataHitUserWords.cpp
docs/dev/ENVIRONMENT.md
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp

@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 8, 2026

@Superseabas Superseabas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows check of head f9a3585a11, merged onto main 095ff72367 (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 with ANYPS5_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=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.

Full ^agc suite (-j 8), passed / total:

RTX 5070 Ti Radeon (iGPU)
main 1489 / 1490 1489 / 1490
this PR, switch off 1491 / 1492 1491 / 1492
this PR, APS5_DRAW_PIPELINE=1 1488 / 1492 1488 / 1492
this PR, APS5_DRAW_PIPELINE=1 and APS5_DRAW_TABLE_SNAPSHOT=1 1488 / 1492 1488 / 1492
  • The one failure in the first two rows is the same with and without this PR: agc_driver_quad_pixel_mask on the RTX (#14341) and agc_driver_sample_order_grid_reference on the Radeon (#9503).
  • The last two rows add agc_driver_draw_recapture_on_change, agc_driver_queued_constant_ram_dump and agc_driver_draw_unsupported_buffer_type_skip_refused. All three also fail on main with APS5_DRAW_PIPELINE=1, so turning the switch on adds no failures.
  • No VUID- lines and no missing-layer lines in any run.
  • agc_shader_table_keep, agc_shader_table_keep_compare and the switch tests pass in 3 of 3 runs on each GPU. tools/check_conventions.py --base upstream/main passes.

A real draw, with a temporary test. No test here turns the switch on for a draw, so I ran one locally in the DrawDataHitUserWords fixture with APS5_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:

Table Switch off Switch on
Page aligned 255 (the table the game wrote later) 64 (the table at the packet)
16 bytes into a block not run 64
Keep crosses a page not run 64

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, and tail.queue is only set on the other path (Draw.cpp:786). Each of the four keptTables calls sits behind tail.queue != nullptr, so a comparison never sees a keep. I logged this: tail.queue wasn't set on any finisher job in the runs above or in the 68 from agc_driver_draw_cache_reuse_draw_pipeline and _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" describes main with #15455 rather than main today. It might help to say so there. I didn't build the two together.

2. Two parts of the switch have no test.

  • The wiring: besides RuntimeSwitches, which only checks the name, no test refers to the switch, so as far as I can see nothing would fail if KeepUserDataTables stopped being called. The temporary test above could become one. I set Pending::unknown = false on the blocker job, because PendingOverlaps treats an unknown job as overlapping everything. Mine waits a fixed 300 ms after the lookup counter moves, which you'd probably want to replace.
  • Word-by-word pages: with !page.kept.Test(index) removed from ShaderMemory::read, both new tests still pass. They pass no pendingWrite, so their pages are never read word by word.

One small thing: the description says a game run needs APS5_DRAW_TABLE_SNAPSHOT=1. From handOff in Draw.cpp it also needs APS5_DRAW_PIPELINE, since without it no draw reaches the finisher. The ENVIRONMENT.md entry could name it too.

Not run: any title, or this PR merged with #15455.

@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

Thank you for the review, and for the real-draw check on both GPUs.

  • Commit-time comparison: you are right, and we checked Draw.cpp: tail.queue = &queue is set after the hand-off path returns, so the four keptTables calls are not reached for a handed-off draw on today's main. The description now says so and names fix(agc): recapture and skip refused draws on the draw finisher #15455 as what makes the second commit take effect.
  • APS5_DRAW_PIPELINE: added to the description. We will name it in the ENVIRONMENT.md entry too.
  • Tests: we will add a test that holds the finisher, rewrites the table after the packet and checks the written value with the switch on and off (without the fixed 300 ms wait), and a case with a pendingWrite so a page is read word by word and !page.kept.Test(index) matters. We push when both pass with the validation layer, and say so here.

AI-assisted: yes

@muhmuhkuh

muhmuhkuh commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Pushed a6e89164ee: one test commit on top, then main 0bae53facde8 merged in (a fast-forward of the branch; its tree is identical to the tree we tested).

  • Word-by-word pages: a new case in agc_shader_table_keep: the page is read word by word (the pending-write query answers for the page), the table is kept, a GPU write is then recorded over it, and the capture must still return the kept words. Without !page.kept.Test(index) in ShaderMemory::read it fails.
  • Wiring: agc_driver_draw_data_hit_user_words_table_keep runs the draw fixture with APS5_DRAW_PIPELINE=1 and APS5_DRAW_TABLE_SNAPSHOT=1 and requires that the draw kept a user-data table (ShaderMemory::TablesKept, new, static like the other counters); in the _draw_pipeline, _plan_verify and _refresh runs it requires that none was kept. Without the KeepUserDataTables call it fails. We did not keep your held-finisher check as a test. In our runs the lookup counter never moved, WaitIdleFor never returned and the finisher's pending writes never showed the draw while a blocker job held the finisher, so our reading, which we did not confirm, is that the worker waits behind the blocker before the hand-off. We could not get the packet read and the rewrite in a fixed order without a sleep, so the test checks the call through the TablesKept() counter instead. Your measurement of the real draw on both GPUs stays the evidence for the effect itself; the test covers that the call is made.
  • ENVIRONMENT.md: the entry names APS5_DRAW_PIPELINE as the prerequisite.

main 65 tests, 65 passed; this branch 68 tests, 68 passed; the three added tests are the new ones. Same machine and GPU, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, validation layer inserted for every instance and device, no was not found but was requested, no VUID-. The description's Tested section has the details.

AI-assisted: yes

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 8, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@muhmuhkuh this needs a rebase onto main (the PR is conflicting), and the windows check failed on this head (https://github.com/boykopovar/AnyPS5/actions/runs/42526828359/job/128876338013). Please say whether that failure comes from this change, and rerun on the rebased head.

One more thing to settle: the commit-time compare commit does nothing on current main, because all four calls sit behind tail.queue != nullptr, and it only takes effect together with #15455, which conflicts on that line. Either say which of the two lands first and how, or drop that commit from this PR.

The table snapshot itself looks sound to me, and the 64 vs 255 measurement on a real draw is useful evidence.

@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Thanks. The failed Windows job has one failing test: guest_standard_streams, exiting with 0xc0000409 after the fscanf diagnostic. I have not established an unchanged-main reproduction, so I have not dismissed the failure or rerun the old head.

I prepared an unapplied revert of f9a3585a11, bound to current head a6e89164ee. It removes the inactive commit-time comparison and its specific test, retaining the table snapshot, wiring and word-by-word coverage. The proposed order is this snapshot-only PR first; commit-time comparison can follow separately with #15455.

Next are the main conflict resolution and paired focused validation before any push. No updated branch or new test result is claimed here.

AI-assisted: yes

@muhmuhkuh
muhmuhkuh force-pushed the fix/agc-keep-draw-tables branch from a6e8916 to 434da34 Compare November 11, 2026 17:27
@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

Rebased to 434da344030 and dropped the inactive commit-time comparison. Five focused CPU/mock cases pass.

On Windows, guest_standard_streams passes locally on main and this rebased head, both rc0. The historical abort does not reproduce on the rebased head. The old head does reproduce a second-ungetc failure in the Getdelim fixture, already removed on main; fscanf returns the expected values. Current paired GPU qualification remains open because of a local DLL-staging error.

I requested one Windows rerun for the failed job. GitHub CLI returned job 128876338013 cannot be rerun; this account has no upstream write permission. Please start Windows CI for the new head.

AI-assisted: yes

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 11, 2026
@adriadam10 adriadam10 self-assigned this Nov 12, 2026
@muhmuhkuh
muhmuhkuh force-pushed the fix/agc-keep-draw-tables branch from 434da34 to 04b58e0 Compare November 12, 2026 21:10
@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (446248d). Conflicts were only in the switch lists of RuntimeSwitches.hpp and RuntimeSwitches.cpp: main adds APS5_PIPELINE_DISPATCH_MISSES, this PR adds APS5_DRAW_TABLE_SNAPSHOT; both are kept, in that order. The PR head is now 04b58e0 (was 434da34).

Tested on Windows 11, NVIDIA GeForce RTX 3080 Ti, Release, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:

  • main 446248d: agc_driver_draw_cache_reuse_off, agc_driver_draw_cache_reuse_verify, the agc_driver_draw_data_hit_user_words variants, agc_runtime_switches, agc_shader_memory: 9 of 9 pass.
  • This PR: the same tests plus the new agc_driver_draw_data_hit_user_words_table_keep: 10 of 10 pass.
  • No VUID- line and no was not found but was requested by env var VK_INSTANCE_LAYERS line in either log.
  • check_conventions.py --base origin/main: passes.

AI-assisted: yes

@muhmuhkuh
muhmuhkuh force-pushed the fix/agc-keep-draw-tables branch from 04b58e0 to b817023 Compare November 12, 2026 21:27
@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

Rebased again onto current main (a221a74), since main moved past the previous base. Head is now b817023 (was 04b58e0).

Tested on Windows 11, NVIDIA GeForce RTX 3080 Ti, Release, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:

  • main a221a74: 9 of 9 pass.
  • This PR: 10 of 10 pass (incl. agc_driver_draw_data_hit_user_words_table_keep).
  • No VUID- line and no 'was not found but was requested by env var VK_INSTANCE_LAYERS' line in either log. check_conventions passes.

AI-assisted: yes

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 13, 2026
@brajankw

Copy link
Copy Markdown
Contributor

Linux run of this head on an NVIDIA and an Intel GPU, with the validation layer; the runs here so far are Windows. AI-assisted run and report.

  • Head b8170233c1 merged onto main c76eb6a264 (clean merge). Debian 13 container with both GPUs passed through, GCC 14.2.0, Release. The guest write watch was active.
  • NVIDIA GeForce RTX 3060, driver 610.57.04; Intel UHD Graphics 770 (ADL-S GT1), Mesa 25.0.7 (ANV).
  • ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, Khronos validation layer 1.4.363, ctest -V, one run per side on the same machine. Every log shows Insert instance layer "VK_LAYER_KHRONOS_validation", and none shows the missing-layer line.

Tests: every agc_driver_draw_cache_reuse*, agc_driver_draw_data_hit_user_words*, agc_runtime_switches*, agc_shader_table_snapshot* and agc_shader_table_keep test. That is 19 on main, and 21 on the merge, which adds agc_shader_table_keep and agc_driver_draw_data_hit_user_words_table_keep.

GPU main merge
RTX 3060 19/19 21/21
UHD 770 19/19 21/21

No VUID- on either side, and no test skipped.

@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 13, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 13, 2026
@blawesom

Copy link
Copy Markdown
Contributor

Validation report — item 6 of queue10 (AGC handed-off draw user-data tables)

Verdict: PASS — frozen head validated as-is on Linux/AMD; no new validation IDs; pushed to blawesom/AnyPS5:validation/pr-17024.

Environment

  • Machine: CachyOS, kernel 7.3.4-1-cachyos, Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RADV, GFX1201), /dev/kfd present; AI PRO R9700 also present but unused.
  • Compilers: gcc/g++, Ninja, CMAKE_BUILD_PARALLEL_LEVEL=12, cmake --build build --parallel 12 (core cap N=12 respected).
  • PR state re-checked before work: state=OPEN, headRefOid=b8170233c1d950705e6adede80f342cc1650e8fb, locked=false, mergedAt=null — head matches the frozen queue SHA exactly.

SHAs

  • Base (origin/main, prebuilt read-only worktree /home/benj/scratch/wt5/base-main): 0f4538fa022a7d82d467fd74e112514abc30345f (clean, build/build.ninja present — reused).
  • PR head (worktree /home/benj/scratch/wt5/pr-17024): b8170233c1d950705e6adede80f342cc1650e8fb ("fix(agc): keep the user-data tables of a handed-off draw as they were at its draw packet"; branch commits 27a0db05c6e feat + b8170233c1d test).

Build (PR tree)

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON
cmake --build build --parallel 12

Configure: exit 0, wall 11 s (log t6-pr17024-configure.log). Build: exit 0, wall 357 s, 9638 ninja steps (log t6-pr17024-build.log). Submodules git submodule update --init --recursive exit 0.

Focused test pattern (identical matched set in both trees, verified via ctest -N -R + diff)

agc_driver_draw_pipeline|agc_driver_draw_cache|agc_driver_draw_data_hit_user_words$|agc_driver_draw_data_hit_user_words_draw_pipeline|agc_driver_draw_data_hit_user_words_plan_verify|agc_driver_draw_data_hit_user_words_verify|agc_driver_draw_data_hit_user_words_refresh|agc_shader_table_snapshot_reuse|agc_shader_memory$|agc_draw_snapshot|agc.*user_data|agc.*sgpr

36 tests matched in each tree; matched name lists identical (diff clean; saved as t6-names-base-main.txt / t6-names-pr-17024.txt, pattern in t6-pattern.txt). The PR-only new tests (agc_shader_table_keep, agc_driver_draw_data_hit_user_words_table_keep) and main-only stale-base tests (agc_shader_memory_coherent_atomic_loads, etc.) were deliberately excluded to keep the sets identical.

Tests (both trees, identical env, timeout 3600 each)

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
VK_ADD_LAYER_PATH=/home/benj/scratch/vvl-layer VK_LOADER_DEBUG=layer ANYPS5_GPU='AMD Radeon RX 9070 XT' \
ctest --test-dir build -R '<pattern>' -V
  • Base: exit 0, 36/36 passed (100%, wall 4 s) — t6-tests-base.log.
  • PR: exit 0, 36/36 passed (100%, wall 4 s) — t6-tests-pr.log.
  • Per-test comparison: passed-name sets identical; zero ***Failed / ***Skipped / ***Exception / ***Timeout in either log.

Layer checks (per AGENTS.md)

  • was not found but was requested by env var VK_INSTANCE_LAYERS: 0 occurrences in both logs (phrase absent).
  • Insert instance layer "VK_LAYER_KHRONOS_validation": 57 occurrences in both logs (layer insert present).

VUID / SYNC-HAZARD / bracketed-ID diff

  • VUID- strings: 0 in both logs. SYNC-HAZARD: 0 in both logs.
  • Bracketed validation message IDs ([ ... ] | MessageID = 0x...): identical sets and counts in both logs — 24× Undefined-Value-ShaderOutputNotConsumed-DynamicRendering (0x46877e3e), 3× Undefined-Value-OutputNotWritten-DynamicRendering (0x82d5604b), 1× Undefined-Value-ShaderOutputNotConsumed (0x9805298c); 28 validation warnings total in each. No new IDs introduced by the PR (diff empty).

Push

  • git push fork +b8170233c1d950705e6adede80f342cc1650e8fb:refs/heads/validation/pr-17024 → succeeded, new branch validation/pr-17024 on blawesom/AnyPS5.

Limitations

  • Scope: Linux + AMD RADV (RX 9070 XT) only; no NVIDIA/Windows/macOS coverage. Validation-layer version is the local vvl-layer build; message IDs use the layer's bracketed message-key format rather than VUID- strings.
  • The PR branch is based on an older main, so the focused set was restricted to tests present in both trees (36); PR-only new tests (agc_shader_table_keep, agc_driver_draw_data_hit_user_words_table_keep) were not in the compared set.
  • Single run per tree (no repetition), so intermittent faults are not excluded; ctest reported Passed with zero validation errors logged in either tree.

muhmuhkuh and others added 2 commits November 15, 2026 11:19
A draw handed to the draw finisher reads the 256 bytes behind each user-data pointer from the kept copy taken when the packet is read, behind APS5_DRAW_TABLE_SNAPSHOT.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ages

A draw handed to the finisher keeps its user-data tables with APS5_DRAW_TABLE_SNAPSHOT set and keeps none without it, counted by ShaderMemory::TablesKept. A kept word on a page read word by word survives a GPU write recorded over the table. ENVIRONMENT.md names APS5_DRAW_PIPELINE as the switch's prerequisite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@muhmuhkuh
muhmuhkuh force-pushed the fix/agc-keep-draw-tables branch from b817023 to edea654 Compare November 15, 2026 10:37
@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

Rebased onto main 858ee24770a (head edea6547b7f). The content is unchanged. Three conflicts: the two runtime-switch lists (APS5_NO_EXTENDED_FAST_PROOFS and APS5_DRAW_TABLE_SNAPSHOT now both stay), the wordwise page check in ShaderMemory.cpp (it keeps pendingSpan from main plus the kept-word test of this PR), and DrawDataHitUserWords.cpp (both tests stay). In tests/ShaderMemory.cpp the table-keep cases now pass the span query as the pending-write query too, because the wordwise path on main calls it.

Tested on Windows 11 Pro, NVIDIA GeForce RTX 3080 Ti, driver 610.88, MinGW GCC 15.2, Release, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (the log shows the layer inserted, and no "was not found" line):

  • main: the agc_driver_draw_cache_reuse*, agc_driver_draw_data_hit_user_words*, agc_runtime_switches*, agc_shader_table* and agc_shader_memory* tests, 23 of 23 pass.
  • This branch: the same set plus agc_shader_table_keep and agc_driver_draw_data_hit_user_words_table_keep, 25 of 25 pass.
  • 0 VUID- lines on both sides. check_conventions passes.

AI-assisted: yes.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed needs rebase Conflicts with main, rebase needed labels Nov 15, 2026
@oneandonlydean
oneandonlydean merged commit 2864d3d into boykopovar:main Nov 16, 2026
14 checks passed
@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants