fix(agc): poison only the pointer-table records a dispatch writes #22690
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22690"
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 milescoviello on 2026-11-18T02:40:51Z.
What
A dispatch that writes a buffer or storage image overlapping one of its image tables' read range sets that table's
TableFault, so selecting any entry faults (table written by its dispatch), even an entry whose record the write misses. The debt entry already says so.In Crimson Desert (PPSA25286) this hits pointer tables (a column read through a 64-bit address):
0x2151d4b5a0(the first record), lies 84 KiB before the first image.deferred write-back failed: ... table written by its dispatchlines per run, from up to a dozen shaders.The change:
start + k * stride,ResourceMaterializerrecords that layout (start, stride, record bytes) with the table snapshot. That covers a column with no indirection, pointer hops or carried offsets, a 4-byte-aligned stride and addend, and no 32-bit offset wrap over the captured keys.ShaderInvocationcarries the layouts asimageTableRecords.ShaderResources::finishImageTableswrites theHeapWrittenpoison into the map codes of just the records a written range overlaps, instead of the table'sTableFault. Any other entry still reads its snapshot descriptor. Tables without such a layout (buffer, nested and indirect tables) keep the whole-table fault.ImageTableRecordLayout::KeysOverlapping, which compares inclusive ends (a store's first and last byte against each record's last byte) instead of adding past them, so a store range that reaches the end of the 64-bit address space, or a record that starts at the last address, still poisons the records it overlaps (MarcZX10's reviews of #22703).LookupTableWord:inMap = aligned && record < keys; otherwiseOutsideSnapshot). So the records outside the write are the descriptors they held when the dispatch started.FormatVersionmoves to 104 (mainwas at 97 then and is at 98 as of 11-27; every number from 96 to 103, and 108 and 110, is used by an open pull request).Tested
Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON, RTX 4070 Ti on NVIDIA 615.71:main859a238b8, one run: 0deferred write-back failed: ... is written by its own dispatchlines in 206 s with 118 frames presented. Onmainthat day, runs that presented 45 frames or more logged 52 to 133 such lines, and runs stuck at 0 to 4 frames logged 2 to 8 (including round 108 on the samemain); details in #22703's Tested. The run was killed at the 20 GiB memory cap, so no title progress is claimed.main3ff0401064asee03b3fa16. One conflict,FormatVersion:mainmoved to 99; this change keeps 104, which no other open pull request uses. Of the 36agc_driver_image_table*,agc_shader_memoryandagc_shader_disk_cache*tests, 35 pass in each of 3 runs. Theagc_shader_disk_cache_large_filetest fails in my batch environment, where the temporary directory is a RAM-backed/tmp(tmpfs, 5.96 GB free) inside a 12 GB memory scope and the 2 GiB write does not complete; withTMPDIRon a disk it passes (run on the #22703 head, which contains this change).main4c7578e0a4as0aaaa698c4. One conflict,FormatVersion:mainmoved to 98; this change keeps 104. The 34agc_driver_image_table*,agc_shader_memoryandagc_shader_disk_cache*tests pass in each of 3 runs.main80781a0e94as19f7d4a0ab. One conflict, theRecompileResultsize check inShaderDiskCache.cpp: #27273 grew it from 560 to 568 bytes withdrawKeyMemo, which is not serialized, and this change adds 24, so the check is now 592, which the build confirms.FormatVersionstays 104. The 34agc_driver_image_table*,agc_shader_memoryandagc_shader_disk_cache*tests pass in each of 3 runs.mainc64b9d323finto the branch as8920a768b4. One conflict, inFormatVersion:mainmoved to 97 (#26800) and the branch kept 100. Since #22602 and #9749 now also use 100,06fae1ad18moves it to 104, which no open pull request uses. The 34agc_driver_image_table*,agc_shader_memoryandagc_shader_disk_cache*tests pass in each of 3 runs at8920a768b4, andagc_driver_image_tableandagc_shader_disk_cache*pass in each of 3 runs at06fae1ad18.mainef7dc4452das660f02cdd7. One text conflict, in the include list oftests/execution/ImageTable.cpp(mainadded<mutex>, this branch<limits>), kept both;FormatVersionstays 100 (mainis at 96 and no open pull request uses 100). The 33agc_driver_image_table*,agc_shader_memoryandagc_shader_disk_cache*tests pass in each of 3 runs (main33/33 once). Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release): the same set, 35 tests there, passes in each of 3 runs.main70602fcc03as74213a85f6. Two text conflicts withmain's pointer-keyed record tables (pointerKeyedinImageTableColumnSnapshotand inResourceMaterializer) are resolved by keeping both; a pointer-keyed column is always indirect, so it never takes this PR's linear record path.mainhad reached format 96, this branch's value, so the last commit moves it to 100. The 33agc_driver_image_table*,agc_shader_memoryandagc_shader_disk_cache*tests pass in each of 3 runs (main33/33 once). Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release): the same set, 35 tests there, passes in each of 3 runs.8021995a83(the fix above for the wrapping range):agc_driver_image_tablealso checksKeysOverlappingdirectly: a store over records 5 to 7 of 48-byte records gives keys 5 to 7, a store running past the top of the 64-bit address space gives the last record, and a store ending at the top gives all four. Linux (Ubuntu 26.04.1, GCC 15.2, Ninja, Release, RTX 4070 Ti on NVIDIA 615.71,ANYPS5_REQUIRE_VULKAN=1): the 33 tests of^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$pass 3 runs. Negative control: with the old formula inKeysOverlapping,agc_driver_image_tablefails withimage table records: a store running past the top of the address space did not select the last record.2e182729d0(test only, MarcZX10's suggestion on #22703): the same checks also cover records of zero bytes and a store past the last of 64 records, which both select no keys. The 33 tests pass 3 runs.db70e3dceb(MarcZX10's second review of #22703):2e182729d0saturated the first record's exclusive end at the top of the address space, so a record starting at the last address looked empty. The range now uses inclusive ends, and the checks add a record at the last address with a one-byte store there and a store ending there (both select key 0). The 33 tests pass 3 runs. Negative control: with2e182729d0'sKeysOverlapping,agc_driver_image_tablefails withimage table records: a one-byte store at the last address did not select the record that starts there.agc_driver_image_tablegains two pointer-table cases next to the existing palette run (keys 0-2 select records 0-2):is written by its own dispatch.^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$(33 tests) passes, 3 runs.agc_shader_disk_cachenow also compares the record layouts after its invocation round trip, and it passes too.main'sShaderResources.cppand the new test,agc_driver_image_tablefails withpointer image table: a store into entries no key of the dispatch selects faulted.Windows 11 (VM, GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release,
ANYPS5_REQUIRE_VULKAN=1):agc_driver_image_tableandagc_shader_disk_cachepass 3 runs on this head746802dc77.Crimson Desert (PPSA25286), Linux, RTX 4070 Ti: offline (
APS5_NET_DISCONNECTED=1), 22G cap. One cold run (420 s) and one warm run (480 s) per arm, with a fresh shader cache per arm.bdd462ac3e(main604828bd44plus #22534 and #22609).5586c9c8d3(the same plus this change).table written by its dispatchfailuresThe screen is still the black loading screen with its spinner in every run. Present counts vary too much between Crimson Desert runs of the same build (2 to 19 in earlier warm runs) to read anything into them here, so I'm only claiming the faults are gone.
main1ccc399b17: the 33 image table, shader memory and disk cache tests pass on bothmainand this PR with noVUID-errors, and the negative control withmain'sShaderResources.cppfailsagc_driver_image_tablein 2 of 2 runs.git merge-treeagainstmainis clean.tools/check_conventions.pypasses on the branch and this body, andtools/debt_fold.py --checkreports nothing new for this fragment.maind89f26516cas8b933712e6(it conflicted withmain;FormatVersionis now 91 againstmain's 90). On Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti), the 33 tests of^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$pass, 3 runs. On the Windows 11 VM (GT 1030, WinLibs GCC 16.2.0, Release), the 35 tests the same pattern selects on Windows pass, 3 runs, on8b933712e6.main0a025bd3c6as742d417e29. It conflicted in the disk cache:mainhad movedFormatVersionto 95 and grownCompiledShaderArtifact(288 to 296 bytes) andRecompileResult(552 to 560). This head setsFormatVersion96 and theRecompileResultassert to 584 (main's 560 plus this change's 24), which the build checks. On Linux (Ubuntu 26.04.1, GCC 15.2, Ninja, Release, RTX 4070 Ti on NVIDIA 615.71,ANYPS5_REQUIRE_VULKAN=1), the 33 tests of^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$pass 3 runs.8b933712e6merged ontomaind89f26516casde9fbd7b86(Linux 7.3.4, GCC 16.2.1, Mesa 26.2.6, RX 7900 XT and the 7800X3D iGPU, Khronos validation layer 1.4.363.1): no new failures againstmainin the full suite (6171 tests) or in^agcwith the layer, and noVUID-orSYNC-HAZARDlines.8b933712e6merged ontomain3c07e1d05e(Radeon 760M, AMD Software 26.11.2, WinLibs GCC 15.2.0, Khronos validation layer 1.4.363):agc_driver_image_tableand the threeagc_driver_nested_image_table*tests pass 3/3 on both sides with noVUID-lines, and with this PR's tests onmain's sourcesagc_driver_image_tablefails. On this device (subgroup size 64) its per-wave key cases are skipped.ee03b3fa16merged ontomainde4730493a:agc_driver_image_table_tests,agc_shader_disk_cache_tests, the five otheragc_driver_image_table_*targets andagc_driver_graphics_testswith its neighbours (176 tests, includingagc_driver_image_table_reuse_recordsand_narrow) pass in 3 of 3 runs. Control, this tree with only the per-record branch infinishImageTablesdisabled:agc_driver_image_tablefails with "pointer image table: a store into entries no key of the dispatch selects faulted". With Khronos validation,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1, noVUID-onmainor this change.ee03b3fa16merged intomain, the whole ctest suite twice per runner: no failures on Server 2025; on Server 2022, 2 and then 3 failures out of 7534, 2 of which also fail onmain(the report does not name the third). 5 GPU tests (AGC, shader recompiler) pass twice on Mesa lavapipe 25.2.8 with Khronos validation and the shader cache off, with no validation message thatmainc1593e4e1ddoes not also produce.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T02:54:15Z.
Review: APPROVED
Reviewed — looks good
The inspected changes implement per-record poisoning for eligible pointer tables and add focused tests; I found no verified blocking defect.
What I ran
Reviewed head
746802dc775456e2612ece8fc99bbbab4f8c425fusing the prepared diff andrepo_read.pyfor targeted source reads. No tests or build commands were run; test results in the PR description are author-reported.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
Full text read for 9 of 10 changed files;
ShaderResources.cppwas excluded from the prepared folder because of its size, so I read the relevant implementation range throughrepo_read.py. In total, all 10 changed files were read at least around their changed hunks; unrelated portions of large files were not read. Build, test, hardware, and console behavior were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T00:41:36Z.
Review: COMMENTED
Reviewed — no blocking findings
The diff and targeted source context at head
8b933712e66722046de813aa5c5697885c498640support the per-record poisoning change; this review environment did not provide a way to run checks.What I ran
Read the prepared description, commits, manifest, diff, and changed-file source ranges using the pinned reader. No tests or build commands were run.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The changed
ShaderResources.cppimplementation and all other changed files listed as reviewed in the manifest were read at relevant ranges. The full contents of files marked included were not read; the code paths relevant to the diff were inspected. No build, automated tests, hardware behavior, or author-reported runs were independently verified.files.jsonwas not available as a review document; the manifest and review-folder listing were used to identify exclusions.ShaderResources.cppwas excluded from the prepared full-text files because it was too large, and was read through the pinned reader around the changed function.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:04:20Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the code I read shows a verified blocking defect; I could not complete a full review because the repository reader command was unavailable.
What I ran
742d417e294bb1b22a80984671f85585e16934dd.repo_read.pyas requested.Results
Findings
Blocking
None verified in the code read.
Non-blocking
None.
Not verified
ShaderResources.cpp’s changed range, materializer logic, cache serialization, and relevant test ranges were read. The full changed-file set was not reviewed.files.jsonwas unavailable through the provided reader; the manifest identifies one excluded changed file:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp(full text too large for the review folder). I read only lines 6810–6875 at the pinned head.To get this to a good state
Nothing is required. The implementation’s selective map poisoning appears consistent with the stated linear record layout for the inspected ranges; review the remaining changed code and run the relevant checks before treating this as a complete approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:56:53Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes appear sound at head
2e182729d04d674d982e42a4ee2eada1547ba721; no checks were run in this review, and author-reported test results were not independently verified.What I ran
No commands or tests were run. I read the prepared diff and changed source through the pinned reader at the stated head.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
ShaderResources.cpp,ShaderDiskCache.cpp(driver test),ImageTable.cpp,ResourcePlan.hpp,ResourceMaterializer.cpp,Recompiler.cpp,Recompiler.hpp,ShaderDiskCache.cpp(recompiler),ShaderDiskCache.hpp, andfix-agc-image-table-written-keys.md.ShaderResources.cppwas not present in the review folder but was read throughrepo_read.py. The remaining changed files were read from the review folder; their changed lines were reviewed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T16:31:07Z.
Review: APPROVED
Reviewed — looks good
The changed source and test hunks support the stated behavior, and I found no verified blocking defect; validation runs are author-reported and were not run here.
What I ran
The pinned head is
db70e3dcebc2a757a2ad924e2a1bbbfd2bc76535. I inspected the prepared diff and traced the changed implementation and serialization at that head. I did not run commands or tests; the build and test results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppwas excluded because it is too large for the review folder; I read the changed hunk throughrepo_read.py. The other eight changed files marked included inmanifest.jsonwere not accessible under thereview/files/paths, so I read their changed hunks and targeted context throughrepo_read.pyinstead of their full text. No runtime tests, builds, or supplied author/CI claims were independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:50:45Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes blocks merging; the selected-record poisoning logic and its boundary cases are covered by the included tests.
What I ran
Read the prepared diff and targeted source ranges at head
74213a85f679410eca815aad5cc278c0a433f260usingrepo_read.py. No tests or build commands were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run.
ShaderResources.cppwas excluded from the prepared full-text bundle because it exceeded the bundle limit; its changed function was read at the pinned head throughrepo_read.py. All changed files listed in the manifest were reviewed through the diff or targeted source reads; full-file text was not read for every file. I did not independently verify the author-reported test runs or hardware behavior.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T15:02:07Z.
Review: APPROVED
Reviewed — looks good
The reviewed head is
660f02cdd7ec94da9562885bbaef666a31ec6327; the available code supports the targeted record poisoning behavior, and I found no verified blocking defect.What I ran
I read the prepared diff and targeted changed code with
repo_read.py; no tests or builds were run. Author-reported test results are not treated as runs performed in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read all files marked included in
manifest.jsonexceptcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp,core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, anddocs/dev/debt/changes/fix-agc-image-table-written-keys.md; their full texts were available but not needed for the targeted logic review. I also did not read the full text ofcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, which was excluded for size; its changed hunk was included in the prepared diff and was reviewed. No checks were run, and console behavior, CI results, and author-reported tests were not independently confirmed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T05:15:10Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes consistently track and poison only overlapping image table records when a supported linear layout is available; execution checks were not run.
What I ran
Reviewed head
06fae1ad18d1b9cf72d3ae3ec5528b6e50add019using the prepared review bundle andrepo_read.pyfor repository context. No commands or tests were run.Results
Negative control
Not run in this review.
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Sources
Reviewed the prepared diff and pinned-head source for the record-overlap logic, layout materialization, serialization, and associated tests.
Not verified
The author-reported Linux, Windows, GPU, and game runs were not independently verified. The full text of
ShaderResources.cppwas excluded from the review folder; its changed function range was read throughrepo_read.py. Read the changed-line ranges for all nine included changed files, plus the changed function range in that excluded file. Also readdescription.md,commits.md,manifest.json,diff.patch, andREADME.md. No changed files were left unread at their changed lines.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T10:36:46Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code supports per-record poisoning for eligible pointer tables and preserves whole-table faults for unsupported layouts.
What I ran
Reviewed head
19f7d4a0ab5839eb72a80a7246cf28dc76dff84ausing the prepared diff and pinned reader. No build or tests were run; reported test results below are author-supplied.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No files were excluded by rule. Read changed files:
ShaderResources.cpp(changed hunk),ShaderDiskCache.cpp,ShaderDiskCache.hpp,ImageTable.cpp(changed hunks),ResourcePlan.hpp(changed hunk),ResourceMaterializer.cpp(changed hunk),Recompiler.cpp(changed hunk),Recompiler.hpp(changed hunk),ShaderDiskCache.cpptest (changed hunks), andfix-agc-image-table-written-keys.md. Other unchanged context and runtime behavior were not verified. The tests described in the PR body were not run by this review.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T13:16:00Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks approval; the reviewed changes correctly limit poisoning to overlapping pointer-table records where a supported linear layout is available.
What I ran
Reviewed head
0aaaa698c4a5d42a863c285f671aaad9bf391923. Read the prepared description, commit list, manifest, diff, and relevant changed code throughrepo_read.py; no build or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run here; author-reported tests and runtime results were not independently verified. Read:
description.md,commits.md,manifest.json,diff.patch; changed code inShaderResources.cpp,ImageTable.cpp,ResourceMaterializer.cpp,ImageTableAbi.hpp,Recompiler.cpp,Recompiler.hpp,ShaderDiskCache.cpp, andShaderDiskCache.hpp. The full text ofShaderResources.cppwas excluded from the prepared review folder, so only the relevant range was read viarepo_read.py. All changed files marked included in the manifest were not read in full.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T14:30:59Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
ee03b3fa16b922170513b846d22cfdd44cb69f07using the pinnedrepo_read.pyreader and the prepared diff. No tests or builds were run.Results
Negative control
Not run locally. The description reports prior negative-control runs; I did not independently verify them.
Findings
Blocking
None.
Non-blocking
None.
Sources
The changed code derives a linear record layout only for supported pointer-table columns, carries it through the invocation and disk cache, and poisons only overlapping keys when that layout is available. The overlap helper handles inclusive address-space ends. Implementation at the reviewed head · Record range helper and tests
Files read:
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp,core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp,core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp,core/shader/recompiler/Recompiler.cpp,core/shader/recompiler/Recompiler.hpp,core/shader/recompiler/ShaderDiskCache.cpp,core/shader/recompiler/ShaderDiskCache.hpp, anddocs/dev/debt/changes/fix-agc-image-table-written-keys.md. Excluded files: none.Not verified
I did not run tests, builds, or hardware checks. Reported test and game runs in the PR description were not independently verified.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T15:57:13Z.
Review: COMMENTED
Both image-table record-reuse CTests passed on main and aborted on the patched tree, including the narrow case. The scalar-buffer and shader-disk-cache controls passed on both trees. I used the same Linux lavapipe device with Vulkan required, shader cache disabled, and validation layer 1.4.369. Both logs show layer insertion and contain no missing-layer diagnostic or
VUID-entry. The two aborts appeared without an assertion message in the CTest log.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.