feat(shader): enumerate bindless material keys behind a mask or a shifted selector #5820
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5820"
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 simonbronk on 2026-10-14T12:27:20Z.
What
Onimusha: Way of the Sword (PPSA27836 01.000.001) has compute programs that read a T# from a 32768-entry table with 48-byte records, keyed through a material record:
TryMakeTableImagerecognised the material read only as a directReadConstBufferatreadfirstlane(i) * stride + offset. Here the selector is scaled by a shift and the key is masked, so the table fell back to binding every entry and the dispatch stopped:Now a
ShiftLeftLogical32selector gives the stride1 << n, and aBitwiseAnd32with an immediate around the material read is recorded asselectorMask, whichresolveTableImageapplies to each enumerated key. The shader still computes the key itself, so the masked value it searches for is the one enumerated.selectorMaskis in the disk-cache plan encoding (format version 32). A debt entry lists what is still not recognised.This carries #5620's two commits (records wider than 32 bytes), which this title also needs. Once #5620 is merged, a rebase drops them.
Tested
main0b97f8b9fwith #5620:ctest -j 8on the RTX 5070: 1142/1142 pass;ctest -R "agc|shader|video_out"on the AMD iGPU: all pass except the three tests of #5271, which fail the same way onmainon this GPU.agc_shader_memorygains a case inverifyBindlessTable: the material program withs_lshl_b32for the selector ands_and_b32 0x7fffon the key, with material keys0x8001and0xffff8003. The plan records stride 16 and mask0x7fff, the mapping holds keys 1 and 3, and it compiles. Withmain'sResourceTracker.cppandResourceMaterializer.cppit fails (the shifted selector and the key mask were not recorded).mainplus the start-up fixes in #5769, #5620, #5550, andShaderInfo::MaxImagesandRuntimeAbi::SampledHeapCapacityraised to 128 locally (#5720's limit stops it earlier otherwise). The compute program above prepares; the title stops next at a 1D T# in the same table sampled through a 2D-arrayimage_sample_l.python tools/check_conventions.py --base upstream/main: passes.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 — not applicable.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T12:46:30Z.
Rebased onto
maincee9841b6(after #5089 was reverted in #5824); the disk-cache format version is 32.Tested again on Windows 11 Pro 26200 (RTX 5070 and the AMD gfx1036 iGPU): everything passes except
agc_shader_memory: #5188'sverifyUniformTableImage(merged since) fails with the carried #5620 commits alone too; reported on #5620. This PR's own masked-material case passes.check_main_sync: a Windows code-page issue in the tool's own test, unrelated to this change.main.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T14:19:21Z.
Review: CHANGES_REQUESTED
The head does not build, so the new test and the rest of the suite could not run:
core/shader/recompiler/ShaderDiskCache.cpp:110:static_assert(sizeof(DescriptorSource) == 104, ...)fails.selectorMaskmakesIndirectImage36 bytes (that assert at line 111 is updated, this one is not), soDescriptorSourcegrows too; update it together with the encoder.ee9506603, a third commit that changesResourceTracker.cppandShaderDiskCache). The two carried commits are the old ones and the branch conflicts withmain. Once #5620 is merged, rebase ontomainso only your commit stays, and re-run the tests after the rebase.ShaderMemory.cpp:1132-1134: the new comment block; the repo keeps code comments for technical debt only.The approach (shift gives stride
1 << n, an immediate AND recorded asselectorMaskand applied to each enumerated key) looks right to me; I'll review the rest with the build once it compiles.Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T14:46:12Z.
@adriadam10 thanks, fixed in
727387252:ShaderDiskCache.cpp:110:sizeof(DescriptorSource)is 112 with the 36-byteIndirectImage(the optional grows to 40 and the struct pads to 8). The encoder already wroteselectorMask, so only the assert changes.FormatVersionstays 32, which also covers #5620'sentryStride.mainf3434892bwith #5620's current head:fdbd6938b,3093460c9andee9506603cherry-picked, authorship kept, then this commit. The debt entry now sits next to the MODE entry onmain.Tested on Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release:
ctest -j 8on the RTX 5070: all pass exceptcheck_main_sync, which fails on a Windows code page and is unrelated.agc_shader_memory, including the masked-material case and #5188'sverifyUniformTableImage, now passes with #5620's third commit;ctest -R "agc|shader|video_out"on the AMD gfx1036 iGPU: all pass except the three tests of #5271, as onmainthere;tools/check_conventions.py: passes.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T19:12:07Z.
Closing as superseded. #5620 was closed in favour of
d9e47d1e9and34525fdf7(#757, #758), which this PR built on. Onmained835aa76, Onimusha (PPSA27836) runs without this PR and shows none of the bindless or material-key errors it fixed (runs on #5720). @adriadam10 thanks for the review.Pull request closed