fix(shader): skip a bit-field low word in a pointer-keyed table's Phi #14853
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14853"
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 liskeee on 2026-11-01T20:19:06Z.
What
I skip a bit-field low-word edge in a pointer-keyed image table's record-pointer Phi walk. I am stacking this PR on #9749 at
365f2b551fbf9ee85806586fb754c094d0f68015. My earlier push wasc7767c2c690, which incorporates maincb8ce41f7751127bdf3b86777a711667075f5a4f. On 2026-11-19 a maintainer merged main731bf998634a607ffc94ce073301bb292823d749into the branch asb6b2b39ee134313bbdcfef3966a9a22d30b0e603. On 2026-11-26 I merged main0af6efad522cba7192190833997d26f69333aefdinto the branch as12282c5f850212011689f5ba24b793a73bd2cf3c, as the maintainer asked. On 2026-11-30 the branch conflicted with main again, and I merged mainfc5bd59376ad7f512335085cef0cdb291d511054into it as3a4b5d8fde0387f0beec5ba0ed7793ef3f961137. EagleBearerYS requested this separate stacked PR. The results under Tested are from3a4b5d8fdeunless a sentence names another commit or date. I built the merged tree52eeaa315ad0before committing it and ran the tests from that build after the commit; the commit has that tree.The merge of 2026-11-26 conflicted in four files. Main had taken in #7395, which this branch had carried as part of the dependency chain, so its hunks left this PR's diff: against main the PR has changed 9 files instead of 15 since then. In
ResourceMaterializer.cpp, main's #25850 (one read per pointer for indirect image table descriptors) and the chain'sreadEntrylambda from #9633 changed the same loop. I kept main's pointer slot table and its duplicate check in the record loop and moved main's contiguousreadWordsread into the lambda; thecontinuethat followed it in main's loop is areturnthere. Entries thatChaseClosurereads through the lambda do not pass through the slot table;ChaseClosurekeeps its own set of known pointers. All fourpointer_chasefixtures hold records with equal pointers, so I expect the duplicate path and the chase to run together in those tests; I did not instrument that. That file merged without a conflict on 2026-11-30, and this PR's change to it is the same as before.The merge of 2026-11-30 also conflicted in four files. Main now contains #8939 as well (merged 2026-11-26). Its last non-merge commit in main is
5eb49d1893, the head this branch already carried, so its hunks leave this PR's diff: against main the PR still changes 9 files, now +1065 -76 instead of +1480 -59. InResourceTracker.cppone hunk conflicted, in the table-column offset match: I kept the chain's fixed-offset V# arm from #9749 and put main's #23778 change,MatchMaskedOffset(SplitImmediateAddend(offset, addend), ...), into theelse ifthat follows that arm. Main's eight other commits on that file since0af6efad52merged without a conflict. InImageTable.cppandagc_driver_image_table_tests.cmake, main had movednested_image_table_shared_scanbehind #8939's tests; I took main's order and kept this branch's test code and its ten registrations before it. The fourth file isShaderDiskCache.hpp, described below.I recognize the surviving IR shapes
(x >> s) & mand(x & m) >> s, with constantsfrom 1 to 31 and constantm, and skip that low word together with its paired high word. I leavePointerFreeWordand the high-word predicate unchanged. I covers_bfe_u32with offset 4 and width 12 after folding. The predicate does not recognize a mask without a shift or a survivingv_readfirstlanewrapper. A bit-field high word paired with a record-read low word stays refused.I record the limitation in shader technical debt: the skipped pair contributes no candidate, so other arms must still supply valid record reads. A real pointer produced by the skipped expression can match an existing full 64-bit table entry; otherwise the existing image-table fault path throws at runtime. I do not implement general resource discovery through arithmetic-derived pointers.
I retain three synthetic fixtures:
agc_driver_pointer_phi_bit_field_table,agc_driver_pointer_phi_mask_shift_tableandagc_driver_pointer_phi_scalar_bfe_table. They check sampled results, nonzero and zero-low-word outside-snapshot faults, suppressed output on fault and unchanged shader identity. I give their records the fixed guest address0x7f0000001000, so a zero low word remains non-null. Because that guest address is not mapped in the host test process, the guarded host-memory copy of the table span for change detection is skipped in these three fixtures; they never asserted on it, and the recompiler reads records through the request's memory regions. I use the guest records address to decide whether the low-address null diagnostic is allowed, preserving the upstream fixture correction.At
c7767c2c690I had moved the recompiler disk-cacheFormatVersionfrom #9749's 97 to 104. Main had 90 at731bf99863, and the maintainer's merge resolved that conflict to 91. Main had 96 at0af6efad52, and my merge of 2026-11-26 set 97, main plus one, as that earlier merge did. Main has 98 atfc5bd59376, and my merge of 2026-11-30 sets 99, again main plus one. Today's overlap check lists that line as conflicting with eleven open PRs (#7085, #16472, #16631, #16812, #16814, #22602, #22628, #22690, #22692, #22703, #28176). In the dependency chain #9457, #9633 and #9749 hold 98, 99 and 100 at their current heads, so 99 collides with #9633. I have not scanned the other open PR heads.Tested
I built the selected executable targets and their runtime dependencies in Release with
BUILD_TESTING=ON, MinGW-w64 and Ninja. I tested on Windows 11, build 26300, NVIDIA GeForce RTX 4080, driver 621.24. On 2026-11-30 I compared mainfc5bd59376ad7f512335085cef0cdb291d511054with the PR head3a4b5d8fde0387f0beec5ba0ed7793ef3f961137on the same machine. I have not tested a newer main, Linux, macOS or an AMD GPU.I used the focused selection
image_table|sampler_table|pointer_|nested_|disk_cache|agc_shader, serial CTest-V,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer. Every binary the selection needs was built on both trees this time, so no registration was omitted.fc5bd59376ad3a4b5d8fde03I passed all 145 common names on both trees and all 10 additional PR names: the three bit-field fixtures and the chain's
pointer_hop,pointer_chase,pointer_chase_split,pointer_chase_words,pointer_chase_edited,pointer_vsharp_fixedandpointer_vsharp_fixed_offsettables. I also ran the PR tree's tenpointer_phinames with--repeat until-fail:3: all ten passed three times, includinglane_and,lane_notand all three bit-field fixtures. The three bit-field fixtures are absent from the baseline selection; the other sevenpointer_phinames are in main now and pass there too. The focus logs contain 55 instance validation-layer insertions on main and 65 on the PR; the repeat contains 30. I found zeroVUID-,SYNC-HAZARDand missing-requested-layer diagnostics, and no failed or not-run test. I observed one internal Python unittest skip (OK (skipped=1)) on each focus side; CTest reports that registration Passed, so I do not count its skipped assertion as executed.I did not repeat the separate cache selection (
disk_cache|shader_cache|ShaderDiskCache|cache_format|DiskCache|format_versionwithout the globalANYPS5_NO_SHADER_CACHE) onb6b2b39ee1,12282c5f85or3a4b5d8fde. On the earlier tree032d1e04c084its 11 eligible names out of 20 passed; those are CPU/source/cache-writer checks without Vulkan loader output.Five test binaries were unavailable on both trees on 2026-11-18, 11-19 and 11-26:
agc_shader_replay.exe,agc_shader_control_flow_tests.exe,agc_shader_mode_register_tests.exe,agc_shader_disk_cache_tests.exeandagc_shader_memory_tests.exe. On 2026-11-18 Windows Defender had quarantined these five binary families across the two builds on this machine; on 11-19 and 11-26 each failed its post-link step withobjcopy ... Invalid argument, and I did not check the cause. On 2026-11-30 all five linked on both trees at the first attempt. I did not change the build scripts, and I do not know what changed. Their 68 focus registrations per tree (two replay/dependency names, four control-flow names, one mode-register name, 18 disk-cache names and 43 memory names) are part of the counts above and passed, withANYPS5_NO_SHADER_CACHE=1like the rest of the selection. So the registrationagc_shader_disk_cache, which runsagc_shader_disk_cache_testswithout arguments and with it the pointer-chase cache round-trip this PR keeps intests/ShaderDiskCache.cpp, ran and passed on this head. It had not run on032d1e04c084,b6b2b39ee1or12282c5f85, where that binary was missing. This is focused coverage: I did not run the full GPU, cache or non-GPU suites on3a4b5d8fde, and I make no CI or title-performance claim.For historical context, at
00c509b294I removed only my tracker change, rebuilt and saw all three bit-field fixtures fail withGetImageResource dword 0 is not a valid runtime value; I restored the file byte-exact, rebuilt and passed them three times. That negative control was not repeated on032d1e04c084,b6b2b39ee1,12282c5f85or3a4b5d8fde. The previously published22534f4915had passed only eight of tenpointer_phinames: the inheritedlane_andandlane_notfixtures rejected a low-address null-pointer diagnostic on MinGW. The updated dependency chain corrects that fixture expectation while retaining fault, untouched-output and artifact-ID checks; both pass in the focused and repeated runs on3a4b5d8fde. My earlier all-GPU and non-GPU results belong to their historical heads and do not establish coverage of this head.On 2026-11-30 I reran the overlap check on
3a4b5d8fdeagainst main1b8f79a5b5; it probed the 2,146 other open PRs. It reported line conflicts with 12 of them: the eleven on theFormatVersionline named above, and #21776 inControlFlowInfo.hpp. Four of the eleven also conflict in the image-table test registrations (#16472, #16631, #16812, #16814), and #16812 and #16814 inImageTable.cpp,ResourceTracker.cppandShaderDiskCache.cppas well; by their titles these four work on pointer-keyed chases and V# reads, the area of the dependency chain, and I have not read their diffs. The check failed closed: it could not complete 60 further PR comparisons on files this branch shares with them, the dependencies #9457, #9633 and #9749 among them, because those PRs conflict with main. On 2026-11-18 I had compared the tracker and image-table fixture across the open PR heads scanned then and found the bit-field predicate and its three test cases only in this PR at those paths; I have not repeated that comparison.Checklist
main; no other open PR implements the same functionsThe branch includes main
fc5bd59376through my merge of 2026-11-30; main has moved on since. It also contains the commits of the open dependency #9749, and the overlap check above is incomplete, so I leave this box open.NotImplemented_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)365f2b551fbf9ee85806586fb754c094d0f68015(#9749 has since moved todf176da31d; this branch does not include that head)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T20:22:27Z.
Review: COMMENTED
Reviewed — no blocking findings
The full 13-file change at
292a5e46124c59dff30a7310c4d46af777180b8chas no blocking source finding; approval is deferred until the required hosted jobs finish.What I ran
Reviewed every changed file and relevant surrounding code at head
292a5e46124c59dff30a7310c4d46af777180b8c, against currentmain5bae1a4bc2cffc66c13e37ce8e63ae48b1b5dd1e. The PR head includes its declared parent #9749 at99d77ab33ac027055af2b3a8fd257a8f8c44c5ff; the PR itself merges cleanly onto the current base in the stack preview. I did not configure or build.Environment: Debian 12, x86_64, Python 3.11.2, Git 2.39.5. Commands run:
The author reports matched Windows 11 / RTX 4080 main-versus-PR validation-layer test runs and a tracker-restoration negative control; those results were not independently run here.
Results
Commands and unedited check output
Negative control
The author reports that replacing the tracker with the #9749 version made the three new positive bit-field cases fail, and that the PR version passes them. I did not run this control locally.
Findings
Blocking
None found in the reviewed head.
Non-blocking
The new CTest registrations do not inherit the existing image-table test's
FAIL_REGULAR_EXPRESSIONforVUID-,SYNC-HAZARD-and a missing requested validation layer. This means a future run of those individual cases could report success despite such log output. The author reports manually checking all six run logs for these messages, so this does not contradict the reported run; consider applying the same failure expression to the new registrations.Sources
Not verified
I did not run a local C++ build, CTest, Vulkan validation, the Windows/macOS/Linux hosted jobs, or a physical-console run. The author-reported GPU and negative-control results remain unverified by me. Required hosted Windows, Linux relinker and macOS relinker jobs were pending at the final check refresh.
To get this to a good state
No blocking code change is required from this review. Once the pending hosted jobs finish, I will refresh the head and checks; if the head is unchanged, I will reassess approval against those results. Applying the same CTest validation failure pattern to the new cases would make future CI results more protective.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T03:54:10Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected tracker code skips recognized bit-field low-word Phi arms and leaves high-word handling unchanged; a formal approval is not justified because one changed file was excluded and I did not run checks.
What I ran
Reviewed the prepared diff and targeted source at head
6fa0009da34e42884c25d976053a6877336de4e; no build or tests were run here. The description reports author-run builds and tests, which I did not independently verify.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I read the prepared
description.md,commits.md,manifest.json, and relevant portions ofdiff.patch, plus targeted ranges ofResourceTracker.cpp. Of the 15 changed repository files, onlyResourceTracker.cppwas read directly;ShaderMemory.cppwas excluded from the review folder, and the other changed files were not read directly. I did not verify the author-reported test results, GPU behavior, or the excluded file.To get this to a good state
Nothing is required. Optional: review
ShaderMemory.cppand run the relevant checks before seeking formal approval.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T18:27:53Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected diff adds bit-field low-word recognition and test coverage; this review is incomplete because several changed files were not read and reported GPU test runs include failures.
What I ran
Inspected prepared diff and description for head
22534f49155696bef02c4ffc899fe9036b2b6d8a. No tests run in this review.Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
The description reports two focused test failures and two GPU test failures on the PR head, while attributing other failures to platform or environment conditions. Please document how the two head-specific failures relate to this change.
Not verified
The files read were
review/description.md,review/commits.md,review/manifest.json, andreview/diff.patch. I inspected relevant hunks inResourceTracker.cpp,Recompiler.cpp,ShaderDiskCache.cpp,ShaderDiskCache.hpp,SpirvImageEmitter.cpp, anddocs/dev/debt/shader.md. Changed test files and other manifest entries were not read; full text for at least one changed file is excluded as too large. The reported build and tests were not independently run. No repository-pinned permalinks or validator output were available.To get this to a good state
Nothing is required. Optional: clarify the two PR-head test failures and inspect the remaining changed files before treating this review as complete.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T12:22:08Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
c7767c2c6906a3a507259591db02b44cbc063908using the prepared diff and pinned repository reader. No build or tests were run during this review.Results
Findings
Blocking
None.
Non-blocking
Not verified
ShaderMemory.cppwas read through the pinned reader; its full text was excluded from the prepared review folder because it is too large. The review did not rerun build or tests, independently validate the reported version scan, inspect excluded files, or verify behavior on other operating systems, GPUs, firmware, or console hardware. The author reports partial focused Windows 11/NVIDIA RTX 4080 coverage and identifies quarantined binaries and omitted suites in the PR description.To get this to a good state
Nothing is required. Optional: rerun the focused checks on the merge candidate and refresh the cache format version coordination at merge time.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T09:34:27Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
b6b2b39ee134313bbdcfef3966a9a22d30b0e603usingrepo_read.pyagainst the prepared diff and pinned repository. No commands or tests were run. The author-reported focused test results are not runs performed by this review.Results
Findings
Blocking
None.
Non-blocking
ResourceTracker.cpp:2028:BitFieldWordaccepts anyBitwiseAnd32operand as a mask, including a non-constant operand. That is broader than the documented(x >> s) & mshape with constantm; consider requiring the mask operand to be immediate so unsupported low-word expressions remain refused.Not verified
ShaderMemory.cppis excluded from the review folder because it is too large; its changed ranges were not read. All other changed files were included in the folder, but this review focused on the core tracker/materializer/cache implementation and relevant fixture code rather than reading every changed file in full.core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp; implementation files read:core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp,core/shader/recompiler/Optimization/src/ResourceTracker.cpp,core/shader/recompiler/ShaderDiskCache.cpp, andcore/shader/recompiler/ImageTableAbi.hpp. Prepared documents read:review/description.md,review/commits.md,review/manifest.json, and relevant ranges ofreview/diff.patch. The remaining changed files were not read.To get this to a good state
Nothing is required. The mask-operand restriction is optional feedback.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T11:35:33Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code and the reported focused runs support merging, with the stated coverage limits.
What I ran
Reviewed head
12282c5f850212011689f5ba24b793a73bd2cf3c. I read the prepared description, commit list, diff, manifest, and all nine changed files at the pinned head;repo_read.pywas not available as a runnable command in this review interface. No tests were run by me. The author reports focused Windows 11/MinGW-w64/Ninja CTest runs, including repeated pointer-Phi fixtures; cache round-trip tests and several binaries were not run at this head.Results
Findings
Blocking
None.
Non-blocking
ResourceTracker.cpp:1605accepts only a maximum chase depth, whileResourceMaterializer.cpp:1157applies every chase site at every depth. This can over-scan the declared chase graph when branches have different lengths, though it remains bounded by the depth limit and the table record limit. Consider recording which chase sites are reachable at each depth and applying only those.FormatVersion97 overlaps with open PRs, including dependency PR #8939, and that the overlap check could not compare 54 PRs. This is an integration coordination point; consider choosing a non-colliding cache format version when resolving the dependency chain.Not verified
No tests were run by me. The author-reported coverage excludes cache round-trip execution at this head and several failed post-link test binaries; full GPU, cache, non-GPU suites, Linux/macOS, AMD GPU, and physical-console behavior were not verified. The reported PR overlap scan is incomplete. No files were excluded by the review manifest; all nine files marked reviewed were read.
To get this to a good state
Nothing is required. The two points above are optional follow-up feedback.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T08:54:56Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review supports merging, with partial focused coverage reported by the author.
What I ran
Reviewed head
3a4b5d8fde0387f0beec5ba0ed7793ef3f961137. No build or tests were run. I read the prepared diff and targeted recompiler code throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
ResourceTracker.cpp:1121:BitFieldWorddeliberately skips a matching low-word arm and its paired high word. The described limitation that the skipped arm adds no capture candidate is consistent with the implementation; retain that limitation in technical debt and user-facing documentation.Not verified
I read all nine changed files listed in the review manifest:
ShaderDiskCache.cpp,agc_driver_image_table_tests.cmake,ImageTable.cpp,ControlFlowInfo.hpp,ResourceMaterializer.cpp,ResourceTracker.cpp,ShaderDiskCache.cpp(recompiler),ShaderDiskCache.hpp, anddocs/dev/debt/shader.md. No changed files were excluded from the prepared diff. I did not run a build, tests, or the negative control, and did not verify behavior on physical console hardware or other operating systems/GPUs. The author’s report describes partial focused coverage and unrun cache tests on this head.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T09:04:51Z.
Review: COMMENTED
Actionable comments posted: 6
Architecture findings (3)
Advisory architecture findings (3)
a437e8bb-adc0-40da-975c-77e5c6bec511Reviewing files that changed from the base of the PR and between
fc5bd59376and3a4b5d8fde.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppdocs/dev/debt/shader.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:45:27Z.
Review: COMMENTED
The trial merge onto
c1601e56d5conflicts in the image-table test registration. Please preserve the controls for bit-field extraction, mask/shift equivalence, and a distinct immediate for the high word through the disk-cache round trip. They cover separate ways the Phi planner can discard the wrong provenance. Move the direct shader debt edit into a fragment on the resolved head.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.