Repository navigation
feat(shader): raise the sampler and sampled-pair limits past the 32-bit sampler masks - #10000
Conversation
|
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.
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.
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the exact head and traced the widened sampler masks through descriptor planning, materialization, disk-cache encoding/content keys, driver iteration and image-table replay. The capacity check limits shifts to 64 bits, the loops enumerate only set bits, and the cache format change covers the serialized element width. The added CPU and llvmpipe tests exercise >32-bit masks, border/de-gamma handling, refusal paths, 64 samplers/256 pairs and the 17-direct-sampler execution case. CI eligibility/intake/conventions/labels/report pass; hosted product jobs are skipped by path policy. I could not independently run the Vulkan/GPU suite here, and the PR explicitly lists the Ratchet & Clank replay as pending, so I am not treating a title unblock as verified. check_conventions.py and git diff --check pass locally. No blocking issue found in the reviewed implementation.
MarcZX10
left a comment
There was a problem hiding this comment.
Updating my earlier review: that approval covered the prior main tip, but the exact PR head is now 394 commits behind current main. tools/check_main_sync.py --base upstream/main --head refs/reviews/pr-10000 reports six touched files changed on both sides since merge base, including ShaderResources.cpp, ShaderMemory.cpp, ResourceMaterializer.cpp, Recompiler.hpp, ShaderDiskCache.cpp and the AGC CMake target; the merge is clean, but these areas need integration review against current behavior. Please refresh from current main, preserve the sampler-mask and cache-format changes alongside newer edits, then rerun the required focused shader/AGC tests on both current main and the refreshed change with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, and ANYPS5_REQUIRE_VULKAN=1 using ctest -V on the same machine/GPU. Compare the logs for newly introduced VUIDs and report GPU/driver/OS. I could not run those tests here: this checkout has no build directory and this host exposes no Vulkan tooling. The Ratchet & Clank replay remains explicitly pending in the PR body, so keep the title-unblock claim unverified until that run is reported. This request is for current-main integration and required validation, not PR volume.
|
A hardware data point next to lavapipe: AMD iGPU on Linux (RADV), head Setup
I didn't run a title. |
|
@Lander0606 thank you, a hardware run next to lavapipe is exactly what this needed, and |
|
@EagleBearerYS a second title for this PR: Ghostrunner (PPSA03685) compute shader 0x200c520000, replayed offline (
So for this shader #8939 is what clears #7459, and with this PR the next cap is @zaidhawk your Persona 3 Reload stop after #9068, #8070 and #9701 to #9703 is a chain of the same family ( AI-assisted: yes (Claude Code) |
|
@EagleBearerYS @frankea Persona 3 Reload (PPSA10872), as frankea suggested above. Its strip-mall compute shader 0x2014960000 goes through the same chain as Ghostrunner's, and with this PR it gets past the pair limit to a new Setup:
The new chain is deeper than the first. The address is a Phi of nested Phis (125 in the chain, with three The full refusal with this PRTo apply this PR on #9969's branch I renumbered the one conflicting line, Not covered: #8939 without the rest of the stack (so I can't say which PR of the stack clears the first refusal), a run in the title, other GPUs. |
…it sampler masks Ratchet & Clank: Rift Apart (PPSA01474) stops with "sampler resource limit exceeded": Tamalero's counts, with the caps lifted in a tracing copy, are 63 distinct sampler sources (60 columns of one per-lane image table, 3 direct S#s), 51 images and 112 sampled image/sampler pairs in one shader (boykopovar#9749 (comment)). With only the sampler cap lifted they stop next on the pair limit. This does not claim the title now runs. MaxSamplers was 32 because the image-to-sampler masks were 32-bit: the per-sampler masks of sampler heap elements and DescriptorBinding's imageSamplers, the image table's tableSamplerMasks, the per-image masks of direct sampler resources and ImageTableElement::samplers, and the driver's checks over them (filter min/max, forced degamma, border swizzle, non-seamless cube) and its sampler-source loops, which stopped at element 32. Direct samplers take two heap elements each, so the 32-bit element masks held only 16 of them. The masks are now 64-bit and the driver walks their set bits. MaxSamplers is 64: BindingAllocator already holds every shader to the runtime ABI's 64 sampler metadata entries (SamplerHeapCapacity), and the 64-element sampler heap holds 32 direct samplers, so a wider mask would not be reachable without a larger ShaderData. MaxSampledPairs is 256. The refusal texts are unchanged. FormatVersion is 49: serialized binding descriptors now hold 64-bit masks (45 to 48 are taken by open pull requests, so the number may move at merge). The --sampler-limits mode plans the Rift Apart shape (60 table sampler columns at distinct offsets of one per-lane record and 3 direct samplers, 51 images, 112 pairs) and checks each image table element's mask; it binds 20 direct samplers as 40 elements and checks an image paired only with elements 32 to 39, and 18 direct samplers beside an image table; and it checks the refusals past the limits: 65 samplers, 306 pairs and 33 direct samplers. The many direct samplers execution test binds 17 direct samplers on a device, the last at sampler element 32, and reads its border colour, its forced degamma and its border swizzle refusal. The selected-records pair limit tests sample each read through eight samplers so the pair limit is still reached before the image limit.
51a0116 to
12b8923
Compare
|
Thanks, @zaidhawk. A second title whose shader goes through the same chain, with each build compared, is useful: Persona 3 Reload (PPSA10872)'s 0x2014960000 gets past the pair limit with this PR on #9969's stack and stops on a deeper chain at 0x14724. It's in the Tested section now, as a replay, with that stop as the shader's next one. |
|
@frankea thanks for the Ghostrunner (PPSA03685) replay. The next cap it reached, If you have time, could you replay |
|
Tested on AMD under Windows, which the runs so far don't cover: Radeon RX 6600 XT (Navi 23, 0x73ff), AMD driver 32.0.21045.16010, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release.
Not checked with the validation layer: on this machine the Khronos layer (SDK 1.4.363) does not load in the test processes although AI-assisted: yes |
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 497 tests)Skipped (45)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
XairRrR
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
The widening of the image-to-sampler masks to 64 bits is correct and does what the PR says, but the two reworked selected-records pair-limit tests now take about 38 s each when run alone here, against 5–6 s on main, which is over the project's 30 s limit per test.
What I ran
Head 760a55029427f45d4bf438e855369b1b596f0b27, main 9090972b7e91fd266819cbd77a8b058e177b5682, merged tree df2c89e223ca19988f76b7a8b752c002ef709a8d (Release, GCC 14.2.0, Ninja, BUILD_TESTING=ON). Debian 13 VM, 32 vCPU Xeon Gold 6136, Vulkan through lavapipe (Mesa 26.1.6, LLVM 19), no GPU.
git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...760a55029427f45d4bf438e855369b1b596f0b27
python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "agc_shader_sampler_limits|agc_driver_many_direct_samplers|agc_shader_selected_records|agc_shader_disk_cache|agc_driver_image_sample_reduction|agc_driver_image_table$|agc_driver_bindless_images"
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j1 --output-on-failure -R "agc_shader_selected_records_(direct_)?pair_limit|agc_shader_sampler_limits"
time env ANYPS5_NO_SHADER_CACHE=1 build/tests/agc_shader_memory_tests --selected-records-pair-limit # twice, merged tree
# negative control: the 11 production files restored from main, then
ninja -C build -j32 -l32 agc_shader_memory_tests agc_driver_many_direct_samplers_tests
ctest --test-dir build -j4 --output-on-failure -R "agc_shader_sampler_limits|agc_driver_many_direct_samplers$|agc_shader_selected_records_(direct_)?pair_limit"
# timing baseline: main's ShaderMemory.cpp and production files, then
time env ANYPS5_NO_SHADER_CACHE=1 build/tests/agc_shader_memory_tests --selected-records-pair-limit
time env ANYPS5_NO_SHADER_CACHE=1 build/tests/agc_shader_memory_tests --selected-records-direct-pair-limit
# every file restored from the merged tree, targets rebuilt, git status --porcelain emptyResults
| Check | Result |
|---|---|
Merge into main |
Clean (done by the script) |
git diff --check |
No output |
check_conventions.py |
0 errors. 1 warning: the image-table entry in docs/dev/debt/shader.md is 1,068 characters (it is already over the limit on main, as the PR says) |
Build, libs |
OK (build.json) |
| Selected test run (build.json) | 2102 run, 0 new failures, 0 timeouts. The 7 known failures also fail on main |
| Validation layer (build.json) | Loaded in 757 of 758 tests. 0 tests with a new VUID-. layer_missing_in is empty |
| Focused set (12 tests) | 12/12 pass |
agc_shader_selected_records_pair_limit, alone |
37.4 s (ctest -j1). 39.2 s and 38.7 s with time, almost all of it user CPU on one thread |
agc_shader_selected_records_direct_pair_limit, alone |
37.7 s |
Same two tests, main's test file and production code |
5.4 s and 6.5 s |
agc_shader_sampler_limits |
15.2 s alone |
agc_driver_many_direct_samplers |
8.3 s, runs (lavapipe binds ≥ 33 samplers per stage) |
Timing of the pair-limit test on the merged tree (run alone, twice)
real 0m39.167s
user 0m38.742s
sys 0m0.372s
real 0m38.660s
user 0m38.343s
sys 0m0.312s
Negative control
I restored the 11 production files from main (Sampler.hpp/.cpp, ShaderResources.cpp, ShaderInfo.hpp, DescriptorBindingBuilder.hpp/.cpp, ResourceMaterializer.hpp/.cpp, Recompiler.hpp, ShaderDiskCache.hpp/.cpp) and kept the PR's tests. The test executables built.
agc_shader_sampler_limitsfails withsampler resource limit exceeded.agc_driver_many_direct_samplersfails withShaderRecompiler::Recompile: prepared sampler mask capacity exceeded.- The two selected-records pair-limit tests still pass. They take their limit from
MaxSampledPairs, so they follow whichever value the build has, which is expected.
After restoring the merged files and rebuilding, git status --porcelain was empty. This matches the description's "Red" claim.
Findings
Blocking
- The selected-records pair-limit tests now take about 38 s, over the 30 s per-test rule. See
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:4628-4629in the merged tree (at head).- Why they are slower: with
MaxSampledPairs = 256and 8 samplers per read, each test now plans and compiles 32 selected reads × 8 samplers (256 pairs) plus the reads one past the limit. Before, it was 32 reads × 2 samplers. - Numbers: run alone here,
agc_shader_selected_records_pair_limittakes 37.4 s andagc_shader_selected_records_direct_pair_limit37.7 s. That is almost entirely single-threaded user time (38.7 s user for 39.2 s wall).main's versions take 5.4 s and 6.5 s on the same machine. That is about 7× slower, in line with Lander0606's 0.8 s → 4.8 s on the 860M. - The rule: CONTRIBUTING.md asks that each test finish in 30 s on the CI runners and that a test that gets close be split or shrunk, not given a longer timeout. Under parallel ctest on the runners these will be at or over that.
- Suggested fix: shrink or split them. For example, check the "fits at the limit" plan and the "one past merges" plan in separate test cases. Or check the merge with fewer reads by lowering the pair count with direct samplers. Or compile only the merged request and not the at-limit one. Then report their times.
- Why they are slower: with
Non-blocking
- Outdated first commit message: commit
12b89239c792still saysFormatVersion is 49and that the test "checks the refusals past the limits: 65 samplers, 306 pairs and 33 direct samplers".8a7c32652309removed those refusal checks, and the tree hasFormatVersion = 52. If the PR is squash-merged, the message should match the final change. - Possible planning cost to check (a question, not a defect I showed): the Rift Apart-shaped plan in
agc_shader_sampler_limits(51 images, 63 samplers, 112 pairs) takes about 15 s on this machine. The pair-limit tests grow about 7× for 4× the pairs. It would be worth saying whether per-shader preparation cost grows faster than linearly in sampled pairs, since raising the cap lets real shaders reach those sizes.
Things I checked that are fine:
- Every 32-bit sampler mask I found is now 64-bit, or proven to stay within 64 bits:
DescriptorBindingBuilder.cpp:575and:672;ResourceMaterializer.cpp:1888and:1927;ShaderResources.cpp:5125and:5381;- the four
Sampler.cpphelpers.
- Shifts stay below 64:
- the element-mask check at
DescriptorBindingBuilder.cpp:574compares against 64; MaxSamplers≤ 64 is enforced by thestatic_assertatResourceMaterializer.cpp:37;BindingAllocator.cpp:103caps samplers atSamplerHeapCapacity.
- the element-mask check at
- The new set-bit loops visit elements in ascending order. So the early
breakonsampler >= sizeis equivalent to the old bound, and the throwing helpers keep their out-of-rangeRequire. - The content key writes two words per mask in both
VisitContentKeyandAppendContentKey, andFormatVersionis bumped for the serialized width. - The per-sampler specialization ranges (
FoldOffsetBase,UnnormalizedBaseLevelBase,MirrorUnnormalizedBaseinPipelineSpecialization.hpp:48-51) are 64 wide, so 64 samplers still fit. - The new debt entry names refusal texts that exist:
BindingAllocator.cpp:163,ResourceTracker.cpp:2339and:2467. - The checklist lines (Depends on, Fixes, Unblocks, GPUs tested, AI-assisted) are present.
Earlier reviews:
- I confirm MarcZX10's last approval on the substance: no new VUIDs here either, on a newer
main. - oneandonlydean's request to drop the refusal assertions has been done.
- The MoltenVK skip added after jotitadev's review is in
ManyDirectSamplers.cpp(maxPerStageDescriptorSamplers/maxDescriptorSetSamplers< 33 skips).
Not verified
- Test times on GitHub's runners. My timings come from a Xeon Gold 6136 VM. Hosts in the NVIDIA bot's runs did not flag these tests over 30 s.
- Hardware GPUs (lavapipe only), the title claims (Rift Apart, Ghostrunner, Persona 3 Reload, My First Gran Turismo) and the description's micro-benchmark numbers.
- Where inside planning or compilation the pair-limit tests spend their time: no profiler is available here.
To get this to a good state
- Bring
agc_shader_selected_records_pair_limitandagc_shader_selected_records_direct_pair_limitwell under 30 s, for example by splitting the at-limit and past-limit cases or reducing what is compiled, and report their times onmainand on the change. - Optionally reword or squash the first commit's message so it matches the final tree (
FormatVersion52, no refusal checks).
The selected-records pair-limit tests check the plan at the limit, the plan one past it, and the merged table's snapshot. They compiled the merged request too, whose result they never read: past the 256-pair limit it holds 264 image samples, and that compile made each test take about 12 s on GitHub's Linux runner. The pair tests now take the capture alone. The image-limit tests still compile their merged request.
|
@XairRrR thanks for the timings. The two pair-limit tests are fixed in ba833f4. Where the time went: not the planning. These tests never read the compiled result, only the plans and the merged table's snapshot, but they compiled the merged request anyway. Past the 256-pair limit that request holds 264 image samples, and validating and optimizing that module with SPIRV-Tools, which Linux builds enable, was the time. On GitHub's runners at 760a550, each test took:
The fix: the pair tests now take the capture alone, and every check they make is unchanged. The image-limit tests still compile their merged request. On GitHub's runners, 10 runs (run):
Your planning question: planning at these sizes is cheap. With SPIRV-Tools off, each pair test takes under 0.5 s with its two plans and the compile, and The first commit's message: you're right that 12b8923 still describes the first version. PRs here land with merge commits, so it would land as written. Rewording it would mean rewriting the pushed branch, so I've left it: 8a7c326's message says what it removed, and the description has the final state. Could you take another look? |
XairRrR
left a comment
There was a problem hiding this comment.
Re-checked — approved
The new test-only commit ba833f42c0 stops the two selected-records pair-limit tests from compiling the merged request. They now take about 0.1 s each here, down from about 38 s, so my one blocking finding is resolved.
What changed since my last review
- One new commit,
ba833f42c0(test(shader): check the pair-limit merge without compiling it). It touches onlycore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp.- It adds
CaptureTable, which runs theShaderMemory::Capturestep thatCompileTablealready runs, without theRecompilecall after it. - The two pair-limit cases (
pairs == true) now use it to get the merged table's snapshot. The image-limit cases still callCompileTable(...).capture. - The rest of the PR's commits are unchanged. delta.patch shows commits 1 to 3 as
=.
- It adds
- The author's reply gives the cause (SPIRV-Tools validating and optimizing the 264-sample module), answers my planning-cost question, and explains why the first commit message was not reworded.
- The description has a new Tested bullet for
ba833f42c0.
What I ran
Head ba833f42c0f43142fbec50d0ee0ef8214c5faa29, main 5cb015caaaaf83f8ee431414ee6a457b5b307d49, merged tree fe395e2f0abc68a97fa7527ac862747d68937f07 (Release, GCC 14.2.0, Ninja, BUILD_TESTING=ON). Debian 13 VM, 32 vCPU Xeon Gold 6136, Vulkan through lavapipe (Mesa 26.1.6, LLVM 19), no GPU.
git show ba833f42c0f43142fbec50d0ee0ef8214c5faa29
git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...ba833f42c0f43142fbec50d0ee0ef8214c5faa29
python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j1 --output-on-failure -R "agc_shader_selected_records|agc_shader_sampler_limits|agc_driver_many_direct_samplers$"
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j1 --output-on-failure -R "agc_driver_image_sample_lod_clamp_shader_lane$|unwrap_self_UnwrapTest_test_new_output_inherits"
# the 11 production files restored from main, then
ninja -C build -j32 -l32 agc_driver_image_sample_lod_clamp_tests agc_shader_memory_tests agc_driver_many_direct_samplers_tests
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j1 --output-on-failure -R "agc_driver_image_sample_lod_clamp_shader_lane$"
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j4 --output-on-failure -R "agc_shader_sampler_limits|agc_driver_many_direct_samplers$|agc_shader_selected_records_(direct_)?pair_limit"
# merged files restored, git status --porcelain empty, targets rebuilt
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j4 --output-on-failure -R "agc_shader_sampler_limits|agc_driver_many_direct_samplers$|agc_shader_selected_records"Results
| Check | Result |
|---|---|
git diff --check |
No output |
check_conventions.py |
0 errors. The same single warning as before: the image-table debt entry in docs/dev/debt/shader.md is 1,068 characters, already over the limit on main |
Build, libs (build.json) |
OK |
| Selected tests (build.json) | 2238 run. 0 timeouts. Two failures are listed as new; neither comes from this PR (see below) |
| Validation layer (build.json) | Loaded in 759 of 760 tests. layer_missing_in is empty. 0 tests with a new VUID- |
agc_shader_selected_records_pair_limit, alone |
0.13 s (it was 37.4 s at 760a550294) |
agc_shader_selected_records_direct_pair_limit, alone |
0.10 s (it was 37.7 s) |
agc_shader_selected_records_image_limit / _direct_image_limit |
6.69 s / 5.39 s, pass |
agc_shader_sampler_limits |
16.3 s alone, pass |
agc_driver_many_direct_samplers |
7.6 s, pass |
The two failures build.json lists as new are from main:
agc_driver_image_sample_lod_clamp_shader_lanefails with the same message (thread 0 component 1 is 0.000000, expected 0.062500) after the PR's 11 production files are restored frommainand the test rebuilt. The test came intomainthrough #12980, after the failure baseline096c45570f.unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_groupfails onos.chownwithEINVALin the sandbox's/tmp. It is atools/test this PR does not touch, added tomainafter the baseline.
Negative control
I restored the 11 production files from main and kept the PR's tests:
agc_shader_sampler_limitsfails withsampler resource limit exceeded.agc_driver_many_direct_samplersfails withShaderRecompiler::Recompile: prepared sampler mask capacity exceeded.- The two pair-limit tests pass, as before. They take their limit from
MaxSampledPairs.
After restoring the merged files, git status --porcelain was empty. I rebuilt the targets, and the 6 tests pass.
The new commit removes only the compile from the pair cases. Every require they make is unchanged. The snapshot they check comes from the same ShaderMemory::Capture call that CompileTable makes before it compiles. See CaptureTable and its use. The image-limit cases still compile their merged request, so the compile path is still covered.
Previous findings
- Pair-limit tests about 38 s, over the 30 s rule (blocking): Resolved. They take 0.13 s and 0.10 s alone here, in line with the author's 0.05 to 0.14 s on GitHub's Linux runner (author-reported).
- Outdated message on the first commit (non-blocking): No longer applies. The author points out that PRs land with merge commits, so the history keeps
8a7c326523, which says what it removed. The tree and the description describe the final state. I accept that. - Planning cost per sampled pair (question): Resolved. The author attributes the time to SPIRV-Tools working on the compiled module, not to planning. That fits what I see: removing only the compile took the pair tests from about 38 s to about 0.1 s.
agc_shader_sampler_limitsstill takes 16 s here because it compiles. That is under the limit, and the author reports 2.9 to 5.9 s on GitHub's runners.
New findings
Blocking
None.
Non-blocking
None.
Not verified
- Test times on GitHub's runners. The author reports them; mine come from a Xeon Gold 6136 VM.
- Hardware GPUs: I ran on lavapipe only.
- The title claims (Rift Apart, Ghostrunner, Persona 3 Reload, My First Gran Turismo).
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 516 tests)Skipped (45)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (12, not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 510 tests)Skipped (54)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
Bumps ShaderDiskCache FormatVersion to 53. Main landed boykopovar#10000 with format 52, which this branch also used for its own cache format change; both sides set the same line, so the merge kept 52 silently, and caches written by main would load under this format.
… refusals ShaderInfo::MaxImages goes from 64 to 128. Nothing that holds per-image data is narrower: the ImageBase, MipCountBase, CompareBase and StoreQuantizeBase specialization ranges reach 1663, 8447, 49919 and 12799 at 128 images, below the next range at 4096, 12288, 57344 and 16384; the runtime ShaderData image array holds 256; and no mask is indexed by image. Direct sampled images stay bound to the 64-element typed heaps, so images past 64 come through image tables. The tracker's "image resource limit exceeded" and the binding builder's "runtime image count exceeds the static capacity" now name the count and the limit, as in "(129 of 128)". FormatVersion goes to 51: #10000 is at 49 and #9969 at 50. The selected-record limit test is sized for 128 images: 256 heap records, the direct T#s and samplers past the 130 key words, and the two-heap split scaled from the limit (40 and 30 at 64, 80 and 60 at 128).
The conflict in core/libs/prx/libSceAgcDriver/CMakeLists.txt from #12862's split is resolved with tools/agc_test_split.py resolve, which moves this PR's test registrations into tests/cmake/.
…at, 63 yabanana's #7223 now takes 51, the number this PR had, and 52-62 are held by the open PRs: #10000 52, #8939 53, #10489 54, #9457 55, #9633 56, #9749 57, #10193 58, #9790 59, #9969 60, #10846 61, #7642 62. So this PR takes 63 and a cache written by #7223's recompiler is not read as this one's.
What
With #9749, Ratchet & Clank: Rift Apart (PPSA01474) gets past
LoadAddressU32@pc=0x13bc0. It then stops onShaderRecompiler::Recompile: sampler resource limit exceeded, in compute 0x116bb61900 in game and in the captured requests 0x116bb67b00 and 0x116bb5e100. Tamalero counted the shaders' resources with the caps lifted (comment):Sixty of the samplers are indirect columns of one per-lane table, which differ in chase depth and in the S#'s offset in the record. The other three are direct S#s. No sharing gets them under 32, and the pairs are over 64 as well.
Why 32:
MaxSamplers = 32is the width of the image-to-sampler masks, which arestd::uint32_twith1u << element.DescriptorBindingBuilder's sampler masks,DescriptorBinding::imageSamplersandtableSamplerMasks.Sampler.cpp's filter-minmax, degamma, border-swizzle and non-seamless-cube checks, which loopelement < 32u, andShaderResources.cpp's sampler-source loops.The change:
std::uint64_tin the recompiler, the serialized artifact and the driver. The driver's per-image loops walk set bits instead of 32 elements.MaxSamplers: 32→64. That'sRuntimeAbi::SamplerHeapCapacity, theShaderDatasampler metadataBindingAllocatoralready caps every shader at.MaxSampledPairs: 64→256. Nothing sizes an array by it.static_assertguards the resource-indexed shift, and the element-mask capacity check compares against 64 with its old text.FormatVersionto 52, since serializedimageSamplerswidens.The next limit, stated in the shader debt file:
ShaderDataholds 64 sampler metadata elements, and each direct sampler takes two of them (the original and a point copy). So a shader can have at most 64 samplers in all, and at most 32 direct ones ("shader sampler pairs exceed runtime heap capacity"). Rift Apart fits by one. More would need a largerShaderData, a runtime-ABI change with a per-draw cost, and wider masks.Cost: each mask is 8 bytes instead of 4, and the content key holds one more word per image. In a synthetic micro-benchmark of the driver's per-image loops (
g++ -O3, 64 images per draw, the old and new loop bodies), the common two-bit masks went from about 4.7 µs to about 0.2 µs per draw, because the new loops visit only set bits. Fully set 32-bit masks were unchanged within noise. This is not a driver run.Overlap:
FormatVersion:mainis at 51 since fix(agc): render layered mesh targets within device limits #6959 (JJenkx). Ours take one number each: feat(shader): raise the sampler and sampled-pair limits past the 32-bit sampler masks #10000 52, feat(shader): raise the image limit to 128 and name the counts in its refusals #10489 54, feat(agc): look up table images at run time through a device image table on the GPU heap (APS5_GPU_PATH) #7642 62, feat(shader): read samplers through nested and pointer-keyed descriptor tables #7395 63, fix(shader): take lane-mask arms and a merged high word in a pointer-keyed record pointer #8939 66, fix(shader): follow pointer hops and fixed-offset V# reads behind a record pointer #9457 67, fix(shader): follow a conditional pointer chase through a V# behind a pointer-keyed record pointer #9633 70, fix(shader): plan several T#s read through one pointer-loaded V#, keeping the V# real for their other uses #9790 71, fix(shader): read a chased pointer's high word at its own offset #9749 72 and fix(shader): index a pointer-loaded V#'s T# array by a word read from the same buffer #9969 73. The other open PRs seen changing it hold 50 (feat(agc): GPU descriptor heap on VK_EXT_descriptor_heap (APS5_GPU_HEAP) #9508, fix(shader): serve ds_ordered_count in wave launch order #12944), 51 (feat(shader): resolve nested image tables through runtime pointers #7223, fix(agc): preserve proven base formatted buffer read extents #14944), 58 (fix(shader): skip a bit-field low word in a pointer-keyed table's Phi #14853), 65 (perf(agc): bound instance-indexed guest buffers by the draw's instance range #14032), 68 (fix(shader): narrow a goto junction Phi to the arm its branch allows #14636) and 69 (feat(shader): flatten oversized 1D image arrays to 2D #14871). So the conflict is the one line, plus the shader debt entries those PRs add next to the image-table entry this one edits. Keep both, and whichever lands second takes the next free number.FormatVersion, it conflicts inDescriptorBindingBuilder::Populate, where it addsAtomicImageKindandimageAtomic64on the lines next to this PR'sstd::uint64_tmask, and in one line of the AGC driver's debt file. Keep both.set_tests_propertiesline in the AGC driver'sCMakeLists.txt. fix(shader): bound the bytes the recompiler's result memos hold #9989 went first, and this PR's merge ofmain85f8e11 keeps both PRs' names.main, none of these files conflicts.Tested
test/9749-sampler-masks(b340d22, this change on fix(shader): read a chased pointer's high word at its own offset #9749's head b2d4afc) (comment):sampler resource limit exceededat fix(shader): read a chased pointer's high word at its own offset #9749's head (0x116bb67b00, 0x116bb5e100, and 0x116bb5ad00, the in-game stop) plan with this change. They then stop evaluating runtime sources whose guest memory thepreparerequests don't carry, which is the replay's limit, not a refusal.AGC driver: invalid shader memory read address) and at 1,170 s on compute 0x116bb75900 (runtime image descriptor is invalid). Those are shaders that now get further, stopping on the values they resolve, not on a limit this PR sets. They're being traced on fix(shader): read a chased pointer's high word at its own offset #9749.agc_shader_sampler_limits(tests/ShaderMemory.cpp, beside fix(shader): keep a shader's selected image-table records within the image and pair limits #7527's selected-records tests):agc_driver_many_direct_samplers(new,tests/execution/ManyDirectSamplers.cpp, on lavapipe): 17 direct samplers bound as 33 sampler elements, with the last one at element 32.main's product files, both fail 20/20:sampler resource limit exceededandprepared sampler mask capacity exceeded. Green: 20/20 each.MaxSampledPairs. They now sample each read through 8 samplers, so they reach 256 pairs within the 64-image limit. All four pass.main's product code. The reds above come from reverting the product files alone on a cloud Linux machine.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandANYPS5_NO_SHADER_CACHE=1on llvmpipe (LLVM 20.1.2), GitHub's Linux runner. The run includesagc_driver_many_direct_samplers,agc_driver_image_tableandagc_driver_bindless_images.main's tree and 5 with the change, which adds a test.VUID-VkDeviceCreateInfo-pNext-pNext, so the change adds noVUID-message.agc_driver_sgpr_pattern_fill_keystiming flake under--parallel 4.sampler resource limit exceededin Tamalero's runs above; its next stops are listed there.main0db47b2. The only conflict wasShaderDiskCache.hpp'sFormatVersionline:mainmoved to 45 (fix(shader): normalize offset perspective barycentrics after interpolation #7831), and this branch keeps its 49. On GitHub's runners (run), the new tests and the shader, image-sample and disk-cache sets (19 tests) pass 10 runs in a row on Linux. On Windows the set has 21, with two Windows-only disk-cache tests: they build, 19 pass 10 runs in a row, and the other 2, which need a Vulkan device, skip. The libc and libkernel suites pass on both, run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.check_conventions.py: passes. The one warning is the image-table debt entry's length: it's already over the limit onmain(1,067 characters) and is 1,068 here. No comment lines are added.sampler,selected_records,image_sampleanddisk_cachetests, three runs each with and without the Khronos layer. The base passes 18 of 18 and this PR 20 of 20 in every run.agc_driver_many_direct_samplersruns there, with no skip. Under the layer neither side logs aVUID-line.agc_shader_replay --preparewithANYPS5_NO_SHADER_CACHE=1on the request the driver dumped, RTX 4090, Windows 11; replay only, no title run. Every build ismain513ca7e with fix(shader): link table callees that together exceed s_call_b64 range #9068, fix(shader): link a table call whose V# is a slice of an s_load_dwordx8 or s_load_dwordx16 #8070 and fix(shader): find strongly connected components without recursion #9701 to refactor(shader): walk each construct when checking the structured constructs #9703.GetImageResourcerefusal and stops onsampler resource limit exceeded; fix(shader): index a pointer-loaded V#'s T# array by a word read from the same buffer #9969's stack alone stops there too.image resource limit exceeded, the 64-image cap (MaxImages).ANYPS5_NO_SHADER_CACHE=1; replay only, no title or GPU run. Onmain0db47b2 with fix(shader): link table callees that together exceed s_call_b64 range #9068, fix(shader): link a table call whose V# is a slice of an s_load_dwordx8 or s_load_dwordx16 #8070 and refactor(shader): walk each construct when checking the structured constructs #9703, with fix(shader): take lane-mask arms and a merged high word in a pointer-keyed record pointer #8939 (9162d9d) and this PR (51a0116), it gets pastsampler resource limit exceededand stops on another image load,LoadAddressU32@pc=0x0002ef78, whose pointer Phi has an arm read at a fixed offset of a buffer whose V# is loaded from memory. With fix(shader): take lane-mask arms and a merged high word in a pointer-keyed record pointer #8939 alone it stops on the sampler limit.agc_shader_replay --prepareof the request the driver dumped for it, RTX 5090, Windows 11, WinLibs GCC 15.2.0, Release,ANYPS5_NO_SHADER_CACHE=1, one run per build; replay only, no title run. The base ismain0db47b2 with fix(shader): link table callees that together exceed s_call_b64 range #9068 and refactor(shader): walk each construct when checking the structured constructs #9703.GetImageResource dword 0 is not a valid runtime valueatLoadAddressU32@pc=0x000036f8. With fix(shader): index a pointer-loaded V#'s T# array by a word read from the same buffer #9969's branch (the stack from feat(shader): resolve nested image tables through runtime pointers #7223 through fix(shader): index a pointer-loaded V#'s T# array by a word read from the same buffer #9969) it gets past that and stops onsampled image/sampler pair limit exceeded.FormatVersionrenumbered to 51 for the stack; the replays run without the shader cache), it gets past the pair limit and stops on a deeperGetImageResourcechain atLoadAddressU32@pc=0x00014724, through a buffer whose V# is itself read through a pointer at0x00013a4c. That's the shader's next stop, not this PR's.test/9749-sampler-masks(b340d22): one 600 s run from a cold shader cache withAPS5_DUMP_IR=all. Nosampler resource limit exceededline, nowhat()or terminate and no stop line: it ran the whole 600 s. 7840 IR blocks were dumped. The highest shader pc is 0x1f2c8, and 980 block lines are at or past 0x13bc0. This covers that branch, not this PR's current head.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,mainb84322d against this PR's head 12b8923 merged onto it,ctest -R "agc_shader_memory|agc_shader_selected_records|agc_shader_bindless|agc_shader_disk_cache|image_sample|sampler|agc_driver_image_table|agc_driver_bindless_images":main30 of 30 pass; this PR 32 of 32, the newagc_driver_many_direct_samplersandagc_shader_sampler_limitsincluded. The run didn't request the validation layer (correction). The-9fromvkCreateInstancewith the layer requested (Windows (AMD RX 6600 XT): with VK_LAYER_KHRONOS_validation requested, test processes fail at vkCreateInstance with -9, so the required validation runs are impossible #10663) came from a leftoverVK_DRIVER_FILESin the shell, and the layer works on that machine; its run is the next bullet.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,main2fade7e against this PR's head d6061d4 merged onto it. Each test ran on its own withVK_KHRONOS_VALIDATION_LOG_FILENAMEset, and the layer's log file shows it loaded in every test that creates a Vulkan instance: 18 onmainand 19 with this PR.main30 of 30 pass and this PR 32 of 32, the newagc_driver_many_direct_samplersandagc_shader_sampler_limitsincluded. Neither arm has aVUID-message.mainc9b2660. The only conflict wasFormatVersion:mainmoved to 47 (fix(shader): answer image_get_resinfo on any T# dimension #7550), and this PR goes from 49 to 52. Its own diff is otherwise unchanged. On GitHub's runners, 10 runs (run) of the sampler, selected-record, image-sample, disk-cache and shader-memory tests (^.*sampler,^.*selected_records,^.*image_sample,^.*disk_cache,agc_shader_memory), 21 tests on Linux, and the 10 other shader tests built from the changed files: Linux: 31 run, 31 pass, 0 skip, 0 fail. Windows: 33 run, 21 pass, 12 skip (no Vulkan device), 0 fail. The libc and libkernel suites pass on both, run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main16ff208 (run).main's feat(shader): support 64-bit image atomics through keyed image tables #10440 records each element's 64-bit image atomics on the line before the sampler mask this PR widens to 64 bits; the merge keeps both, and this PR's changed lines are the same.FormatVersiononmainis still 47. The sampler, selected-record, disk-cache and image-table tests pass 10 runs in a row. Linux: 26 run, 26 pass, 0 skip, 0 fail. Windows: 28 run, 22 pass, 6 skip (theagc_driver_image_tabletests, no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.test/9749-null-storage(fix(shader): read a chased pointer's high word at its own offset #9749 and fix(agc): bind a written TYPE 0 or 1 static image slot as a null storage image #10906). Without this PR that branch stops at 214 s onsampler resource limit exceeded; with it, the run gets past fix(agc): bind a written TYPE 0 or 1 static image slot as a null storage image #10906's 1,300 s stop and runs to 2,632 s, where a different compute shader, 0x116bb6ef00, stops onGetImageResource dword 0 is not a valid runtime value. That stop is outside this PR.main85f8e11 (run).main's fix(shader): bound the bytes the recompiler's result memos hold #9989 adds its three result-memo budget tests to the Windowsset_tests_propertiesline incore/libs/prx/libSceAgcDriver/CMakeLists.txtwhere this PR addsagc_shader_sampler_limits; the merge keeps all four.FormatVersiononmainis still 47, and this PR's other changed lines are the same. Theagc_shader_tests with the tests built from the files the merge changes pass 10 runs in a row. Linux: 320 run, 310 pass, 10 skip (seven AGC tests on lavapipe and three video-out tests with no display or Vulkan device), 0 fail. Windows: 346 run, 259 pass, 87 skip (84 AGC tests and the same three video-out tests, no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (145 and 211) and on Windows (174 and 232). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main0c5401d, and two test-only commits (run).mainmovedFormatVersionto 48, the one conflict; this PR stays 52, which no other open PR uses (see Overlap). Its other changed lines are the same.agc_shader_sampler_limits' "65 samplers, 306 pairs and 33 direct samplers are refused" block andagc_driver_many_direct_samplers' opaque-black-border refusal. The widened-mask and 64-sampler cases and the point-clamp control stay.agc_driver_many_direct_samplersskip on a device that binds fewer than 33 samplers per stage or per set. @jotitadev's run on an Apple M2 Max with MoltenVK (review) showed MoltenVK reports 16 samplers per stage, somain's per-stage check refuses the test's 33 sampler elements with or without this PR.agc_driver_image_table,agc_driver_many_direct_samplersandagc_driver_sample_order; no Vulkan device), 0 fail.exec_arguments,guest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_webfail at their setup in the verify's Windows build (FileNotFoundErrorstarting the title, or copying the libraries they load), and pass inmain's own Windows job at 1829def (job). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main94fe1b5 (run).mainnow has fix(agc): sample cube descriptors with fewer than six slices as six faces #11507 (hugodearaujo's short-cube sampling), which takesFormatVersion49 (b9f4f65); that line was the one conflict, and this PR keeps its 52 (see What). fix(agc): sample cube descriptors with fewer than six slices as six faces #11507 also adds anImageResourcefield,sampledOnly, whichShaderDiskCache.cppencodes without a conflict. This PR's diff overmainis the same apart from theFormatVersionline's old value. The sampler-limit, image-table and sample-order tests with the disk-cache, bindless and shader-memory tests and fix(agc): sample cube descriptors with fewer than six slices as six faces #11507'sagc_driver_image_sample_short_cuberan 10 times with no failure. Linux: 26 run, 26 pass, 0 skip, 0 fail. Windows: 28 run, 24 pass, 4 skip (the Vulkan device tests), 0 fail. Suites: libc and libkernel pass on Linux (166 and 265). On Windows libc passes (194), and libkernel passes 284 of 287:exec_arguments,guest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_webfail at their setup in the verify's Windows build (FileNotFoundErrorstarting the title, or copying the libraries they load), withmain's code too, and pass inmain's own Windows job at 1829def (job). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.agc_shader_replay --materialize; Windows 11, RTX 3080 (driver 616.92). It covers CPU preparation of the capture only: no Vulkan pipeline was created or dispatched.main08a10d2 it fails withsampler resource limit exceeded.main(a clean merge), it prepares and materializes 5,573,305 SPIR-V words.VK_LAYER_KHRONOS_validation,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1,agc_shader_bindless, the fouragc_shader_selected_records_*limit tests,agc_driver_bindless_images,agc_driver_image_sample_reductionandagc_driver_image_tablepass on both sides, and this PR'sagc_shader_sampler_limitsandagc_driver_many_direct_samplerspass. No VUID errors on either side.main0836dfd (run, on 75d57e9, which has the same tree). build(agc): register each AGC test executable in its own CMake fragment #12862 movedlibSceAgcDriver's test registrations intotests/cmake/; the conflict inCMakeLists.txtis resolved withtools/agc_test_split.py resolve, which moves this PR's registration ofagc_shader_sampler_limitsintotests/cmake/agc_shader_memory_tests.cmake(+3 −2). Nothing else conflicted. Apart from the move, this PR's diff is unchanged. With-DBUILD_TESTING=ON,ctest -Ngives 3077 tests:main's 3075 plus its 2 tests (agc_driver_many_direct_samplerscomes from the execution-test glob), each listed once. The 9 tests of this PR's verify set pass 10 runs in a row. Linux: 9 run, 9 pass, 0 skip, 0 fail. Windows: 9 run, 7 pass, 2 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (199 and 308) and on Windows (226 and 330). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main88e804b (run).mainnow has Ondra97's fix(shader): split scalar-address descriptor phis #7694 (scalar-address descriptor Phis), which addsDescriptorSource::requiredBlocksto the shader plan encoding, and JJenkx's fix(agc): render layered mesh targets within device limits #6959, which movesFormatVersionto 51. The one conflict wasFormatVersioninShaderDiskCache.hpp:mainmoved to 51, and this PR keeps 52 (see Overlap). Git merged the rest without conflicts, including this PR'sagc_shader_sampler_limitsregistration beside fix(shader): split scalar-address descriptor phis #7694'sagc_shader_descriptor_phisinagc_shader_memory_tests.cmake. This PR's diff overmainis the same apart from theFormatVersionline's old value. The sampler-limit, selected-record, disk-cache and shader-memory tests, withagc_driver_image_sample_reductionandagc_driver_many_direct_samplers, pass 10 runs in a row. Linux: 11 run, 11 pass, 0 skip, 0 fail. Windows: 13 run, 11 pass, 2 skip (agc_driver_image_sample_reductionandagc_driver_many_direct_samplers; no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.agc_driver_image_sample_reductionandagc_driver_many_direct_samplers; no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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)FormatVersion: no other open PR uses 52 (see Overlap)sampler resource limit exceededafter fix(shader): read a chased pointer's high word at its own offset #9749 (Tamalero's runs and oneandonlydean's 600 s run under Tested); its next stops are listed there; Ghostrunner (PPSA03685) Ghostrunner (PPSA03685) #7320: compute shader 0x200c520000 pastsampler resource limit exceededwith fix(shader): take lane-mask arms and a merged high word in a pointer-keyed record pointer #8939 and fix(shader): index a pointer-loaded V#'s T# array by a word read from the same buffer #9969, in frankea's replay (its next stop is the 64-image limit); My First Gran Turismo (PPSA24156): compute program 0x1258c12300 pastsampler resource limit exceededin Rengundom's replay (CPU preparation only)