fix(shader): fold descriptor web paths that hold the lane index or texels #12132
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12132"
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 mrfelek on 2026-10-27T22:31:46Z.
What
Follow-up to #8077. A descriptor web path whose T# dwords are per-lane values left in the registers was not rebuilt, and the read stopped with "GetImageResource dword 0 is not a valid runtime value". There are two kinds: the lane index from
v_mbcnt, and arithmetic on texels from an image read. PPSA26344 compute shader 0x800037fe00 has a texel path into its waterfall loop, which #8077 does not fold.HoldsControlValuebecomesHoldsFoldableValueand also foldsLaneId,ImageReadand theImageSample*results. These paths select the first descriptor and record anInvalidDescriptorfault when a lane takes them, like the program counter, EXEC and lane mask paths.APS5_STRICT_DESCRIPTOR_WEBSstill throws.WebSelectornow takes the select in the latest block first.ENVIRONMENT.mdname the two new path kinds.Tested
ShaderMemory:verifyDescriptorWebLaneIndexFoldandverifyDescriptorWebSelectOrderfail without the change and pass with it.agc_driver_descriptor_web_faults: 4 new lane-index cases (first arm, second arm, folded path faults at the read, no fault with no lane enabled).ctest -R "agc_shader_|image_table|descriptor_web"40/40 pass, 0 VUID. The only log difference from #8077 alone is the expected fault of the folded case.NotImplemented, as on main.f759e165d9), Linux, GCC 13:ctest -R "agc_shader_|image_table|descriptor_web|request_serializer|agc_driver_graphics"passes, with the Vulkan tests (agc_driver_descriptor_web_faults, the image table tests,agc_shader_fusion) run on lavapipe.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)AI-assisted. Tested by me on my own machine.
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-02T18:37:13Z.
Review: APPROVED
Head
e77dbfd892merged onto currentmainb28bb77217(clean merge, local only): code read, red/green check and a run on two Windows GPUs with GCC 16.2.Windows 11 Home 10.0.26200, Ryzen 7 7700X, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release,BUILD_TESTING=ON.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -R '^(agc_shader_.*|.*image_table.*|.*descriptor_web.*)$',ANYPS5_GPUselecting the device (confirmed bySelected GPU):main10de:2c05)1002:164e)VUID-lines and no missing-layer line on either side.agc_shader_memoryandagc_driver_descriptor_web_faults: 3 of 3 on each GPU.ResourceTracker.cpptaken back frommainfails both tests withGetImageResource dword 0 is not a valid runtime value, the stop the description names.check_conventions.py --base mainpasses on the merge.Read through the change: the three new kinds in
HoldsFoldableValue(LaneId,ImageRead, theImageSample*results) take the existing fold, the first descriptor plus anInvalidDescriptorfault, andAPS5_STRICT_DESCRIPTOR_WEBSstill throws.WebSelectornow takes the selecting value from the latest block inBlockOrder, with the first one found kept on a tie as before, and the order map is built before it is first needed. The dead code pass afterSplitDescriptorPhisruns only when a web was folded. It erases instructions from their blocks without freeing them, so theIrValue*keys inm_splitFailuresandm_edgeSelectorscannot be reused by a new value. The debt entry andENVIRONMENT.mdname the two new kinds. I found nothing to change.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T21:49:08Z.
Review: APPROVED
Reviewed — approved
The fold for lane-index and texel descriptor web paths, the select-order fix and the dead code pass after a fold each make their own test pass, and each test fails when its part of the change is removed. Conventions, build and the focused Vulkan tests pass on lavapipe.
What I ran
Head
e77dbfd892d1b153ea1aa847a0cc3725d4680b46merged with--no-ffintomain9090972b7e91fd266819cbd77a8b058e177b5682(merged tree9312c56fd7653b413bf00b3b7ff91a01ff2bd953). Release build with GCC 14.2.0 on Debian 13, Vulkan through lavapipe (Mesa 26.1.6). No GPU.The bot also ran the selected tests and the Khronos validation comparison against
main.Results
git diff --checkcheck_conventions.pylibscheck_skips.py), 0 new failures, 0 timeouts; 7 failures that also fail onmain(agc_driver_division, the denormal-mode tests,unwrap_self,vector_constant_factor_tininess)main(757 tests)agc_shader_memoryagc_driver_descriptor_web_faults(ANYPS5_REQUIRE_VULKAN=1, no shader cache)agc_driver_descriptor_web_faults tail (merged tree)
The fault at
instruction=0xa8is the expected fault of the new folded lane-index case (LaneIndexSamplePc = 0xa8).Negative control
I tried three reverts, one at a time, and restored the merged file after each:
ResourceTracker.cpptaken frommain: both tests fail with the stop the description names: This confirms the red check in Superseabas's review.if (m_foldedWeb) DeadCodeEliminator{}.Eliminate(m_program);block:agc_shader_memoryfails withSrtWalker::EvaluateRuntimeSources failed to evaluate runtime sources: descriptor source 0 dword 0: Unreachable(null, null). This matches the commit's claim thatverifyDescriptorWebTexelFoldneeds the extra pass.if (lane == nullptr || index > laneOrder)replaced byif (lane == nullptr)):agc_shader_memoryfails withRecompile: value IR instruction definition does not dominate its use. This matches the select-order claim.agc_driver_descriptor_web_faultspasses in controls 2 and 3, as expected: its new cases only cover the lane-index path. After the last restore and rebuild, both tests pass again andgit status --porcelainis empty.Findings
Blocking
None.
Non-blocking
ImageGatherRawresults are not folded (core/shader/recompiler/Optimization/src/ResourceTracker.cpp:1461-1471).HoldsFoldableValuenow foldsImageReadand the threeImageSample*opcodes, but notImageGatherRawor the image atomics' returned values. A path whose T# dwords come from a gather still stops with "not a valid runtime value". It throws, so no rule is broken. However, the debt entry andENVIRONMENT.mdsay "texels" in general. Either addImageGatherRawto the list or say "image reads and samples" in the two docs.verifyDescriptorWebTexelFoldcovers onlyImageRead(image_load). Whether anImageSample*result reaches the fold through the ops thatHoldsFoldableValuerecurses into (IsRuntimeUniformOp,CompositeExtractU32x4) has no test. A case withimage_samplein that arm would pin it. This is optional.Not verified
BlockOrderindex always picks a dominated select. I checked it only for the tested two-block shape; a tuple whose selects sit in sibling blocks would reach the phi path instead.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T23:13:59Z.
Review: APPROVED
Re-checked — approved
The new commit
b5f1d6b44dchanges only docs. The debt entry and theAPS5_STRICT_DESCRIPTOR_WEBSrow now say "image read or sample result" instead of "texels", and they add that a path through a gather or through an image atomic's returned value still throws. This resolves my first non-blocking finding. The code is the same as ate77dbfd892, and it still builds and passes its tests on currentmain.What changed since my last review
b5f1d6b44d(docs only):docs/dev/debt/shader.mdanddocs/dev/ENVIRONMENT.md.git diff e77dbfd892..b5f1d6b44dtouches just these two lines. The first three commits are identical to the ones I reviewed.image_sampletest out, and offered to add it.What I ran
Head
b5f1d6b44d0c7a1b84af0294ce531c53a3a3b64dmerged with--no-ffintomain5cb015caaaaf83f8ee431414ee6a457b5b307d49(merged tree190318aa9f62115ea939dbcf6893d0afa7b8b1f2). Release build, GCC 14.2.0, Debian 13, Vulkan through lavapipe (Mesa 26.1.6). No GPU.The bot also built the merged tree, ran 2167 selected tests and compared the Khronos validation layer output with
main.git diff --checkcheck_conventions.pylibsmain(759 tests)agc_shader_memory(merged)agc_driver_descriptor_web_faults(merged, no shader cache)The bot listed two "new failures". It compared against an older
mainbaseline (096c45570f), so I checked both:agc_driver_image_sample_lod_clamp_shader_lanestill fails afterResourceTracker.cpp, the PR's only production file, is taken back frommain. The message is the same:thread 0 component 1 is 0.000000, expected 0.062500. So it comes frommain. One candidate is #12980 (min-LOD pinned level), merged after the baseline; I did not bisect.unwrap_self … test_new_output_inherits_the_destination_directory_groupfails atos.chown(..., -1, group)withEINVALin the sandbox. This is a test undertools/tests, and the PR touches no file undertools/, so the failure is not the PR's.Negative control: with
ResourceTracker.cppfrommain,agc_shader_memoryandagc_driver_descriptor_web_faultsboth fail again withGetImageResource dword 0 is not a valid runtime value … (LaneId). With the merged file back, both pass, andgit status --porcelainis empty.Previous findings
ImageGatherRawand image atomic results are not folded, but the docs said "texels". Both docs now say "image read or sample result", and the debt entry says that a path through a gather or through an image atomic's returned value still throws. This matches the opcode list inHoldsFoldableValue, which is unchanged.ImageSample*result into the T#. The author left it out and offered to add it. It was optional, and it still does not block.New findings
Blocking
None.
Non-blocking
None.
Not verified
e77dbfd892. The new commit changes only docs, so they still apply to the code.