Skip to content

feat(shader): plan 128 samplers per shader, keeping 32 direct - #23409

Open
frankea wants to merge 10 commits into
boykopovar:mainfrom
frankea:feat/shader-sampler-index-masks
Open

frankea wants to merge 10 commits into
boykopovar:mainfrom
frankea:feat/shader-sampler-index-masks

Conversation

@frankea

@frankea frankea commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

A shader can now plan up to 128 samplers (ShaderInfo::MaxSamplers, was 64). At most 32 of them can be direct (two elements each in the 64-element sampler heap), and the pair limit stays at 256.

The cap was not set by a real resource. BindingAllocator checked info.samplers.size() against RuntimeAbi::SamplerHeapCapacity, but that heap only holds direct samplers. Table samplers go through the sampler table, and the compact ShaderData the driver uses (IrBindingLayout::ShaderDataDwords) carries image metadata only. The fixed RuntimeAbi::ShaderData.samplers[64] array is used only by layout static_asserts. Two things did depend on 64:

  • the masks indexed by sampler, namely an image table element's direct samplers (ImageTableElement::samplers, filled by ResolveImageTables, read by DescriptorBindingBuilder::Populate), which were one uint64_t;
  • the per-sampler specialization constant ranges. FoldOffsetBase and MirrorUnnormalizedBase were 64 IDs wide, so sampler 70's fold offset would have used the ID of sampler 6's base-level switch, and its mirror axes image 6's minimum LOD. (UnnormalizedBaseLevelBase was already 128 wide and SamplerLodBiasBase ran up to FmaskFormatBase.)

Changes:

  • SamplerMask (ShaderInfo.hpp): (MaxSamplers + 63) / 64 words with Set, Test and ForEach. ImageTableElement::samplers and ResolveImageTables' directSamplers use it. Populate walks its set bits into the 64-bit heap-element mask.
  • Masks indexed by sampler heap element stay 64-bit, because the heap has 64 elements: DescriptorBinding::imageSamplers, tableSamplerMasks, and the Require*/ForcesDegammaOn checks in Sampler.cpp. Prepare keeps its own 64-element refusal.
  • BindingAllocator no longer compares the sampler count with the heap capacity. Direct samplers are still refused past 32 by the heap check (shader sampler pairs exceed runtime heap capacity).
  • Specialization IDs: every per-sampler range is now 128 wide. The four per-sampler ranges that were 64 wide on main move into the free block after StorageReadBase (58560, which main gave its own 128-wide range in fix(shader): read an image the same shader stores to through its storage binding #26593): FoldOffsetBase 57344 -> 58688, MirrorUnnormalizedBase 57536 -> 58816, SamplerLodBiasBase 57728 -> 58944 and GatherLodBiasBase 57856 -> 59072 (ends at 59200, below ImageComponentBase 65536). GatherLodBase stays at 57792 and now runs up to GatherImageMinLodBase 57920. UnnormalizedBaseLevelBase (57408, already 128 wide), MinLodBase and the per-image Gather, FMASK and volume ranges keep their main IDs. The static_assert chain in DescriptorBindingBuilder.cpp follows the new ID order.
  • ShaderDiskCache::FormatVersion 100 -> 101 (main's value is 100), because cached SPIR-V carries the old IDs.
  • The fragment docs/dev/debt/changes/feat-shader-sampler-index-masks.md changes the docs/dev/debt/shader.md entry to give the new limits and drop the claim that ShaderData sets the cap.

This follows #10000 (64 samplers, 64-bit masks) one step further. It is a separate topic from the descriptor Phi in #7459.

Why 65 is needed: Ghostrunner (PPSA03685) compute shader 0x200c520000 (104K dwords once #8070/#9068 link its table calls). With #8939 it gets past the #7459 refusal and then plans 65 samplers: 4 direct S# and 61 table sampler columns read from three record buffers. Each column reads its S# at a different offset in the block it selects, so none of them can be merged.

Tested

macOS 27.0 on an Apple M5 Max, x86_64 Release build under Rosetta, MoltenVK (local build) with VK_LAYER_KHRONOS_validation 1.4.363.0. Windows 11 on an RTX 4090 (NVIDIA 621.14), WinLibs GCC 15.2.0, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V. main is d89f265 plus only the test commit (7821592, cherry-picked onto it on the Windows machine); the branch is dcde46c + 7821592 on d89f265.

New tests (synthetic RDNA2 programs, no title data):

  • agc_shader_sampler_limits (ShaderMemory.cpp --sampler-limits) adds:
    • 61 table samplers and 4 direct samplers (resources 61 to 64), and 124 + 4 (resources 124 to 127). Each shape is planned, encoded and decoded through ShaderDiskCache::EncodePlan/DecodePlan with no change, compiled, and bound with every image table element paired with its direct sampler's heap elements.
    • 129 samplers refused with sampler resource limit exceeded.
    • 33 direct samplers refused with shader sampler pairs exceed runtime heap capacity.
  • agc_shader_device_profile: 65 direct samplers are now refused by the heap check. 128 samplers with 32 direct fill the 64-element heap, with the same runtime layout as one image.
  • agc_driver_many_table_samplers (new execution test): one compute program with 124 table samplers (S# columns of a record table keyed by a run-time value) and 4 direct samplers, all sampling one image table texel per lane. It checks:
    • the 126 point-clamp samples sum to 126 texels;
    • outside the image, table sampler 64 (wrap) reads the lane's texel and direct sampler 127 (opaque black border) reads its border;
    • the clamp control reads the edge texel there;
    • the image table element is paired with the 8 direct heap elements.
      It skips on devices that bind fewer than 32 samplers per stage, and on lavapipe, where a reviewer measured lane 8 summing 0 through the point-clamp samplers (expected 1039.5) with no VUID while RADV on GCN5, RDNA2 and RDNA3 passes.
Test main + tests this PR
4090 agc_shader_sampler_limits fails 4/4 (3 plain, 1 with the layer): sampler resource limit exceeded passes 4/4
4090 agc_driver_many_table_samplers fails 4/4: ShaderRecompiler::Recompile: sampler resource limit exceeded passes 4/4: 126 point samples, sampler 64 wraps, sampler 127 border, clamp control
4090 regression set (94 ctest entries matching ^agc_.*(sampler, image_table, table_, descriptor, shader_memory, shader_selected, shader_image_limits, shader_bindless, device_profile, disk_cache, image_limits), once with the layer) 92/94, the two failures above 94/94
4090 validation layer inserted in all 49 tests that load Vulkan (55 instances), 0 was not found, 0 VUID- layer inserted in all 49 tests that load Vulkan (55 instances), 0 was not found, 0 VUID-
Mac agc_shader_sampler_limits fails, same message passes
Mac agc_driver_many_table_samplers fails skipped (MoltenVK binds 16 samplers per stage)
Mac regression set (22 agc_shader_* ctest entries; image table, variants, reuse, cache, packed, array views, compute table calls, image sample reduction, disk cache, device profile) 21/22 (sampler limits); execution tests pass 22/22; execution tests pass

The two new tests use a literal 128 samplers, not ShaderInfo::MaxSamplers, so the main build runs the same programs.

agc_shader_device_profile changes its expectation in the feature commit (65 direct samplers are now refused by the heap check, not the metadata check), so it has no main control; it passes on both machines with this PR. On the Mac both trees log the same VUID-vkCreateDescriptorSetLayout-support-09582 lines in the image table tests (MoltenVK maxPerSetDescriptors 1212 against the image table layout); the change adds none.

After merging main c8f72e9 (1ccf597, which includes the layout above and FormatVersion 96), Mac x86_64 Release with the layer: agc_shader_sampler_limits and agc_shader_device_profile pass, agc_driver_many_table_samplers skips (16 samplers per stage), and 88/88 ctest entries matching lod_clamp, image_limits, gather, unnormalized, lod_bias, mirror, fold or agc_shader_ pass. The 14 agc_driver_image_table and agc_driver_image_table_packed* entries exit 0 on both this tree and a main c8f72e9 build and log the same VUID-vkCreateDescriptorSetLayout-support-09582 counts (20 in agc_driver_image_table, 2 in each packed entry, none in unmeasured), so ctest marks 13 of them failed on both. The measurements above this paragraph are from the earlier head.

After merging main ef7dc44 (a023bcf) and moving FormatVersion to 97 because main reached 96 on its own (5943745), Mac x86_64 Release with the layer: 121 ctest entries matching the patterns above plus sampler, image_table, disk_cache and device_profile, with every test executable rebuilt, give 102 passed, 6 skipped (agc_driver_many_table_samplers and agc_driver_many_direct_samplers among them) and the same 13 image table entries failed on the ctest VUID regex as before, with the same per-entry VUID-vkCreateDescriptorSetLayout-support-09582 counts. agc_shader_disk_cache, agc_shader_sampler_limits and agc_shader_device_profile pass. Without the layer 120 of 121 pass; agc_driver_image_table_reuse_records crashes under plain ctest (3 of 3 runs) after printing its pass line, in vkDestroyBuffer under Graphics::DestroyDeferredObjects during VulkanDevice teardown; it passes when run directly (8 of 8), under ctest -V and in the run with the layer. This PR does not touch that teardown, and no main build at this hash was run for comparison. The Windows machine was not rerun for this merge.

After merging main e0ef706 (0dca74e): main's #26593 placed StorageReadBase at 58560, the ID the earlier head used for FoldOffsetBase, so the four moved bases shift up by 128 to the values in What, and FormatVersion goes to 99 because main reached 98. CI passes on this head. On the Mac agc_driver_many_table_samplers still skips (16 samplers per stage); the other measurements in this section are from the earlier heads named in each paragraph.

After merging main 5dded95 (2d28425): main 308cf5f moved FormatVersion to 100, so it goes to 101 here. main did not touch PipelineSpecialization.hpp, so the ranges in What are unchanged. On the Mac (x86_64 Release, MoltenVK), none of the 110 ctest entries matching ^agc_shader_|lod_clamp|lod_bias|mirror|fold|unnormalized|gather|sampler fails. agc_driver_many_table_samplers, agc_driver_many_direct_samplers and agc_driver_oversized_descriptor_sets skip because MoltenVK binds fewer than 32 samplers per stage, sparse_heap_import_mirror skips, and 6 entries have no executable in this build. The 128-sampler execution test still needs a GPU that binds 32 or more samplers per stage.

Head 2d28425 on Windows 11 26200, RTX 4090, NVIDIA 621.14, WinLibs GCC 15.2.0, Release, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V -j 4: all 160 ctest entries matching ^agc_shader_|lod_clamp|lod_bias|mirror|fold|unnormalized|gather|sampler|image_table|disk_cache|device_profile plus oversized_descriptor_sets pass, once without the layer and 3 times with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363.0) and VK_LOADER_DEBUG=layer. In each of the 3 layer runs the loader inserts the layer in all 64 entries that load Vulkan (67 instances), with 0 was not found, 0 VUID- and 0 SYNC-HAZARD lines. agc_driver_many_table_samplers runs on this GPU (it skips on MoltenVK) and passes 4/4: 128 samplers (124 through the record table, 4 direct as 8 sampler elements), table sampler 64 wraps to the lane's texel, direct sampler 127 reads its opaque black border, and the clamp control reads the edge texel. agc_driver_many_direct_samplers and agc_driver_oversized_descriptor_sets pass 4/4.

Control on the same machine: main dd0fec2 with only ManyTableSamplers.cpp from this head added. agc_driver_many_table_samplers fails 4/4 (1 plain, 3 with the layer) with ShaderRecompiler::Recompile: sampler resource limit exceeded. agc_driver_many_direct_samplers, which this PR does not change, passes 4/4 there as well. The layer is inserted in both entries in each layer run, with 0 VUID- lines.

Ghostrunner request replay (agc_shader_replay --prepare, ANYPS5_NO_SHADER_CACHE=1, Mac x86_64 Release):

Tree Result
main 973026d GetImageResource dword 0 refusal at pc 0x51884 (the #7459 chain)
main + this PR same refusal, 20 s
main + #8939 sampler resource limit exceeded
main + #8939 + this PR prepared: 12420660 SPIR-V words, 50-57 s

Title run on the 4090 (main 973026d + #8939 5eb49d1 + this PR, PlayGo absent, no input). The shader is no longer refused. At its first use it is recompiled in 1.3 s to 10,335,484 SPIR-V words (1,297 captured regions), and the driver logs creating a pipeline for 10335484 SPIR-V words. Presentation stops (the title bar FPS counter stays at 590 frames from t+30 s on), and at 146 s Unreal aborts with GameThread timed out waiting for RenderThread after 120.00 secs. The thread dump shows NVIDIA driver (nvoglv64) compiler threads busy. There is no VK_ERROR_DEVICE_LOST / Vulkan result -4, so the #5951 device loss does not come back in this run. One queue 0x20 WAIT_REG_MEM_64 timed out after 1 s during the stall.

Not claimed: this PR does not unblock Ghostrunner. It gets past this shader only together with #8939, which is on main since 2026-11-26, and the title then stops on the size of the module: 10-12M SPIR-V words from a 104K-dword shader, about 100-120 words per guest dword. That is the next thing to look at (#13538 reports a 2.5M-word module in Ratchet & Clank: Rift Apart).

Seen while testing, not changed here: on MoltenVK (maxPerStageDescriptorSamplers 16) a shader whose direct sampler elements plus sampler-table elements pass 16 samples wrong without a refusal. main does the same: the test built there (60 table + 4 direct samplers, 63 point samples) lands 15 of the 63 samples on MoltenVK and all 63 on the 4090. With 128 samplers on the Mac (8 direct elements + 12 sampler-table elements) lanes 32-63 lose one sample. That is why the execution test skips below 32 samplers per stage.

Checklist

Summary by CodeRabbit

  • New Features
    • Shader processing now supports up to 128 samplers, including larger combinations of table-backed and direct samplers.
    • Table-backed samplers can make use of available descriptor capacity more efficiently, while direct sampler allocations remain subject to runtime heap limits.
    • Expanded support includes configurations with 124 table-backed samplers and 4 direct samplers, along with improved handling of image and sampler bindings.

Masks indexed by sampler (an image table element's direct samplers) become a 128-bit SamplerMask; masks indexed by sampler heap element stay 64-bit. The binding allocator no longer holds the sampler count to the 64-element sampler heap; direct samplers stay limited by its two-elements-per-sampler check. The per-sampler specialization constant ranges are 128 IDs wide.
@tablefrogpillow

Copy link
Copy Markdown
Contributor

Real-AMD coverage — the 128-sampler plan works on GCN5, RDNA2 and RDNA3, but it fails deterministically on lavapipe. agc_driver_many_table_samplers, head 7821592067, Khronos validation 1.4.363, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:

GPU arch result
RX Vega 56 (RADV VEGA10, gfx900, Wave64) GCN5 Pass, 0 VUID
Ryzen 7000 iGPU (RADV RAPHAEL, gfx1036) RDNA2 Pass
RX 7900 GRE (RADV NAVI31, gfx1100) RDNA3 Pass, 0 VUID
lavapipe (Mesa, LLVM 21.1.8) SW Fail (2/2 runs)

On Vega the test reports the full plan correctly (128 samplers = 124 through the record table + 4 direct as 8 elements; table sampler 64 wraps, direct sampler 127 reads its opaque-black border, clamping S#s read the edge texel). On lavapipe it fails deterministically: many table samplers: lane 8 summed 0.000000 through the point-clamp samplers, expected 1039.500000 — a wrong result, no VUID.

It is not a descriptor-limit issue: lavapipe reports maxPerStageDescriptorSamplers = 1,015,808 (far above the 128 planned). So it reads as a lavapipe software-driver quirk with the 128-entry sampler-table binding, not something the PR does wrong — it's correct on all real hardware here plus your Apple/NVIDIA runs. Flagging because lavapipe is a common local/CI Vulkan backend (and the visible CI checks here don't run this GPU test), so anyone running it on lavapipe will hit the failure — might be worth a lavapipe skip-guard or a known-quirk note.

AI-assisted: yes

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 14964 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp L37
PR 19096 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp L24-32
PR 20130 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 20248 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L2153-2154
PR 22690 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 22692 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 22703 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 27670 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp L37
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29042 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29066 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29067 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29076 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29084 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29087 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29095 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29118 core/shader/recompiler/ShaderDiskCache.hpp L20

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.

Pull request Shared files not compared
PR 5609 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
PR 5925 core/shader/recompiler/ShaderDiskCache.hpp
PR 6280 core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6924 core/shader/recompiler/ShaderDiskCache.hpp
PR 7085 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7689 core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9633 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9790 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9852 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
PR 9969 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 10359 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10867 core/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 11551 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 12324 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12944 core/shader/recompiler/ShaderDiskCache.hpp
PR 13928 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 13929 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14032 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14853 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14944 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 15343 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 15548 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 15555 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 16571 core/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cpp
PR 16935 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/PipelineSpecialization.hpp
PR 16953 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
PR 17056 core/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 17611 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 18106 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 18107 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 20030 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
PR 20111 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20153 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20518 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 21199 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 21240 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 21745 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 21763 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 21970 core/shader/recompiler/ShaderDiskCache.hpp
PR 21971 core/shader/recompiler/ShaderDiskCache.hpp
PR 22071 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22251 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22328 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22424 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 22439 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22628 core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 22647 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22675 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23242 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 23553 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 23811 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 24704 core/shader/recompiler/ShaderDiskCache.hpp
PR 24781 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 25010 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 25489 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 26012 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 26766 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 27847 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 28142 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28176 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28228 core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28372 core/shader/recompiler/ShaderDiskCache.hpp
PR 28376 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 28384 core/shader/recompiler/ShaderDiskCache.hpp
PR 28387 core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 28400 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 28469 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 28470 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28487 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28488 core/shader/recompiler/ShaderDiskCache.hpp
PR 28586 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 28590 core/shader/recompiler/PipelineSpecialization.hpp
PR 28668 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 28673 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28808 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 29037 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 29089 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 29106 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 29107 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 29119 core/shader/recompiler/PipelineSpecialization.hpp
PR 29120 core/shader/recompiler/PipelineSpecialization.hpp
PR 29121 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp
PR 29123 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp
core/shader/recompiler/Optimization/src/BindingAllocator.cpp
core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/PipelineSpecialization.hpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the review supports merging, and the author’s reported test results are noted separately from checks run here.

What I ran

Reviewed head 78215920672a678990398ee13c2d660b23ceb90a. No build or tests were run. I inspected the prepared diff and changed code through repo_read.py.

Files read: description.md, commits.md, manifest.json, diff.patch, ShaderDeviceProfile.cpp, the changed section of ShaderMemory.cpp, ManyTableSamplers.cpp, ShaderInfo.hpp, BindingAllocator.cpp, DescriptorBindingBuilder.cpp, ResourceMaterializer.cpp, PipelineSpecialization.hpp, and shader.md. files.json was not available as a review document; list_files confirmed the changed-file inventory. All 11 files marked reviewed in the manifest were inspected; ShaderMemory.cpp was read through the reader because its full text was excluded from the review folder.

Results

Check Result Note
Diff and changed-code review passed No concrete defect found
Build and tests not run Reported results are author-supplied
Remaining file contents not applicable All reviewed files were inspected

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports successful tests on Windows with an RTX 4090 and on macOS with MoltenVK, including validation-layer runs. Those results were not independently reproduced. Hardware behavior and the changed test execution were not run in this review.

To get this to a good state

Nothing is required.

@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Ran the regression set from the Tested section with the Khronos validation layer on Linux and an NVIDIA GPU (the Tested section has the RTX 4090 on Windows only), plus the negative check with main's recompiler sources and the PR's tests.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 7821592067 merged onto main ded746ea12 with --no-ff, clean merge. Main baseline is a Release build of ded746ea12 on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_.*(sampler|image_table|table_|descriptor|shader_memory|shader_selected|shader_image_limits|shader_bindless|device_profile|disk_cache|image_limits).*$' -V
main ded746ea12 this PR
Result 86 of 86 passed 87 of 87 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 55 56
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

agc_driver_many_table_samplers is new in this PR and does not exist on main; it runs (no skip) and passes with 128 samplers (124 through the record table, 4 direct as 8 sampler elements); outside the image, table sampler 64 wraps to the lane's texel and direct sampler 127 reads its opaque black border. agc_shader_sampler_limits and agc_shader_device_profile pass with the PR's new cases, and the rest of the set passes on both sides. Main has 86 entries for this pattern here, not 94, because main moved since d89f26516c. Every Vulkan test selected the RTX 4090.

Negative check: with the seven changed files under core/shader/recompiler/ reverted to main and the PR's tests kept, agc_driver_many_table_samplers fails with ShaderRecompiler::Recompile: sampler resource limit exceeded, and so does agc_shader_sampler_limits (sampler resource limit exceeded), as in the Tested section.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@xXPBSXx

xXPBSXx commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

This pull request merges cleanly with main b40a0d6 (no text conflict, merge-tree exit 0), but main plus this branch does not build. The statements below are measured for that hash; the six Gather constants and the head of this branch (7821592) are unchanged on main 34bd032.

core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp lines 30, 31 and 32 fail with static assertion failed. The 128-wide per-sampler specialization ranges here (FoldOffsetBase 57344, UnnormalizedBaseLevelBase 57472, MirrorUnnormalizedBase 57600, MinLodBase 57728, SamplerLodBiasBase 57856) overlap the Gather ranges that main now has in PipelineSpecialization.hpp (GatherLodBase 57792, GatherLodBiasBase 57856, GatherImageMinLodBase 57920, FmaskFormatBase 58048, VolumeGatherBase 58176, GatherImageShapeBase 58432). For example SamplerLodBiasBase and GatherLodBiasBase are both 57856. The branch head 7821592 predates those bases. I built it merged with #8939 on main b40a0d6; the overlap is between this branch's constants and main's Gather constants, and no file of #8939 is involved.

A rebase needs the Gather bases moved above the new ranges. One layout that satisfies every static_assert and stays below ImageComponentBase 65536: GatherLodBase 57984, GatherLodBiasBase 58112, GatherImageMinLodBase 58240, FmaskFormatBase 58368, VolumeGatherBase 58496, GatherImageShapeBase 58752. The disk cache FormatVersion has to go above main's value as well.

With the six Gather bases moved as proposed (a local change, not part of this pull request), a local tree of main b40a0d6 plus #8939 no longer stops at "sampler resource limit exceeded" for PPSA03685 in 2 of 2 runs; it then stops at a later, different point.

AI-assisted (Claude Code).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 20, 2026
…ndex-masks

Move the 64-wide per-sampler specialization ranges (FoldOffsetBase, MirrorUnnormalizedBase, SamplerLodBiasBase, GatherLodBiasBase) above GatherImageShapeBase so every per-sampler range is 128 wide next to main's Gather ranges, and bump ShaderDiskCache::FormatVersion to 96.
@frankea

frankea commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks to both of you. The branch now has main merged with the overlap fixed, and the many-table-samplers test skips on lavapipe.

Specialization IDs: the static_asserts at DescriptorBindingBuilder.cpp:30-32 were right to fail. I kept main's IDs where I could instead of moving all six Gather bases up. Once MaxSamplers is 128, every per-sampler range has to be 128 wide. On main, FoldOffsetBase (57344), MirrorUnnormalizedBase (57536), SamplerLodBiasBase (57728) and GatherLodBiasBase (57856) are 64 wide and blocked by their neighbours, so those four move to the free block after GatherImageShapeBase: 58560, 58688, 58816 and 58944, ending at 59072, below ImageComponentBase 65536. GatherLodBase stays at 57792 and fills the 128 IDs up to GatherImageMinLodBase 57920. UnnormalizedBaseLevelBase (57408, already 128 wide), MinLodBase, GatherImageMinLodBase, FmaskFormatBase, VolumeGatherBase and GatherImageShapeBase keep main's values. GatherLodBiasBase is the one #12790 base that moves, because no 128-wide range fits at 57856 under GatherImageMinLodBase. The static_assert chain now follows the new ID order, and ShaderDiskCache::FormatVersion goes from main's 95 to 96. The layout you proposed also satisfies every assert; this one moves fewer of the IDs main already uses.

lavapipe: thanks for the GCN5/RDNA2/RDNA3 runs. agc_driver_many_table_samplers now calls main's SkipOnLlvmpipe helper with the failure you measured: lane 8 sums 0 through the point-clamp samplers, expected 1039.5. That follows the GlobalAtomicCsub, HostWriteShadowedUnit and CoherentAtomicLoads skips. I have not reproduced it myself or found the cause on lavapipe's side, so the skip records only what fails and does not claim a reason.

Pushed as 1ccf597, which merges main c8f72e9. I tested it only on the Mac, an x86_64 Release build using MoltenVK and the validation layer. agc_shader_sampler_limits and agc_shader_device_profile pass. agc_driver_many_table_samplers skips because MoltenVK binds 16 samplers per stage. 88/88 entries pass for lod_clamp, image_limits, gather, unnormalized, lod_bias, mirror, fold and agc_shader_*. The image table entries log the same MoltenVK VUID-vkCreateDescriptorSetLayout-support-09582 counts as a main build. The PR body now has the new IDs and the cache format.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

Reviewed head 1ccf597e7c47732af75daf661731b9fc1d45e967 against base main; no merged-preview check or test command was run. Read the prepared diff and targeted source context through repo_read.py.

Results

Check Result Note
Diff and source review passed Sampler mask and specialization ranges inspected
Tests not run Author-reported results are not independently verified
Changed-file coverage not run One oversized changed test source was excluded

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp was excluded from the review bundle because it was too large; only its changed hunk was read through repo_read.py. No tests or builds were run. Reported platform results and runtime behavior were not independently verified.

Files read: core/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cpp, core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp (changed range only), core/libs/prx/libSceAgcDriver/tests/execution/ManyTableSamplers.cpp, core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp, core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp, core/shader/recompiler/Optimization/src/BindingAllocator.cpp, core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp, core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp, core/shader/recompiler/PipelineSpecialization.hpp, core/shader/recompiler/ShaderDiskCache.hpp, and relevant CMake test-registration lines. docs/dev/debt/shader.md was not read from the repository. No files listed as excluded by rule in files.json were available to inspect; that list was not present in the review bundle.

To get this to a good state

Nothing is required. Optional: run the focused sampler-limit and many-table-sampler tests on the pinned head.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@frankea #24781 also moves ShaderDiskCache FormatVersion from 96 to 97. Git merges the two bumps silently, so CI will not catch it: whichever of the two lands second needs 98, or caches written by one layout would be accepted by the other. #22690 bumps it too (to 100) and will show a text conflict.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The sampler limit, mask, and specialization ID changes appear consistent with the inspected code; no blocking defect was verified. The change and targeted source context were reviewed at head 5943745842a649e4a88950141ed8ef6062cb4fba.

What I ran

Read the prepared diff and source through repo_read.py; no tests or builds were run. The author reports platform test results in the PR description; these were not run by this review.

Results

Check Result Note
Diff and targeted source review passed No concrete defect found
Tests and build not run Author-reported results only

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp was excluded from the review folder due to size, and its full text was not read. No tests, builds, runtime behavior, or author-reported results were independently verified.

Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch, core/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cpp, core/libs/prx/libSceAgcDriver/tests/execution/ManyTableSamplers.cpp, core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp, core/shader/recompiler/Optimization/src/BindingAllocator.cpp, core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp, core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp, core/shader/recompiler/PipelineSpecialization.hpp, and core/shader/recompiler/ShaderDiskCache.hpp. The remaining changed file docs/dev/debt/shader.md and the excluded ShaderMemory.cpp were not read in full.

To get this to a good state

Nothing is required.

@Helldiverr

Copy link
Copy Markdown
Contributor

GPU test run: passes on AMD RDNA4 with no VUID- errors; the new test fails on main, and three mutations are caught

Base: main efc6f9c3ba. This PR's head 5943745842 merged onto it cleanly as 9e98bbccc5. Line numbers below are from head 5943745842. Upstream main has since moved to f9ed23b951; none of its 12 new commits touch a file this PR changes.

Existing runs: tablefrogpillow ran GCN5, RDNA2 and RDNA3 at 7821592067 and found the lavapipe failure that 1ccf597e7c now skips. domx4q ran Linux NVIDIA at 7821592067. The author ran an RTX 4090 on Windows and an M5 Max. This run adds AMD's Windows driver, a discrete RDNA4 card, the current head with the FormatVersion 97 commit, a negative control and three mutations.

Code:

  • ShaderInfo.hpp:18 raises MaxSamplers to 128. SamplerMask (:47) holds two 64-bit words; Set (:51) uses words.at, so an index past 127 throws instead of wrapping.
  • ResourceTracker.cpp:2583 still refuses past MaxSamplers with sampler resource limit exceeded.
  • BindingAllocator.cpp:103 no longer counts samplers against the runtime metadata capacity. Direct samplers are still held to the 64-element sampler heap at :164 (shader sampler pairs exceed runtime heap capacity), so at most 32 are direct.
  • ResourceMaterializer.cpp:2056 and DescriptorBindingBuilder.cpp:824 build and walk the per-image sampler masks as SamplerMask. Masks indexed by sampler heap element stay 64-bit.
  • PipelineSpecialization.hpp:52-59 moves the four per-sampler ranges (FoldOffsetBase 58560, MirrorUnnormalizedBase 58688, SamplerLodBiasBase 58816, GatherLodBiasBase 58944) to 128 IDs each above GatherImageShapeBase. The static_assert chain at DescriptorBindingBuilder.cpp:25-36 is rewritten to match and ends below ImageComponentBase.
  • ShaderDiskCache.hpp:16 raises FormatVersion to 97.
  • The PR edits the entry in docs/dev/debt/shader.md directly. TechnicalDebt.md#fragments says a pull request does not edit the debt files and adds a fragment under docs/dev/debt/changes/ instead. tools/check_conventions.py --base efc6f9c3ba --head 5943745842 does not flag this; it reports only the three template-heading errors it gives without --body.

Negative control: I added the PR's ManyTableSamplers.cpp unchanged to main efc6f9c3ba, then rebuilt and ran it. agc_driver_many_table_samplers failed with ShaderRecompiler::Recompile: sampler resource limit exceeded.

Mutations (on the merge, one at a time, each reverted):

  • MaxSamplers = 64 at ShaderInfo.hpp:18: the test failed with ShaderRecompiler::Recompile: sampler resource limit exceeded.
  • SamplerMask::Set (ShaderInfo.hpp:51) ignoring samplers 64 and above: the test failed with many table samplers: the image table element is not paired with the elements of direct samplers 124 to 127.
  • Restoring || info.samplers.size() > RuntimeAbi::SamplerHeapCapacity at BindingAllocator.cpp:103: the test failed with shader binding layout exceeds runtime metadata capacity.

GPU:

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_.*(sampler|image_table|lod_bias|lod_clamp|gather|unnormalized|mirror|fold)|^agc_shader_device_profile$' -V
Test main head run 1 head run 2 head run 3
agc_driver_image_gather_lod Passed 0.31 s Passed 0.34 s Passed 0.27 s Passed 0.26 s
agc_driver_image_gather_one_dimensional Passed 0.30 s Passed 0.28 s Passed 0.24 s Passed 0.25 s
agc_driver_image_gather_one_dimensional_array Passed 0.34 s Passed 0.26 s Passed 0.25 s Passed 0.25 s
agc_driver_image_gather_volume Passed 0.59 s Passed 0.54 s Passed 0.46 s Passed 0.41 s
agc_driver_image_packed_horizontal_gather Passed 1.28 s Passed 0.29 s Passed 0.25 s Passed 0.24 s
agc_driver_image_sample_lod_bias_sum Passed 0.34 s Passed 0.28 s Passed 0.26 s Passed 0.25 s
agc_driver_image_sample_lod_clamp Passed 0.45 s Passed 0.34 s Passed 0.31 s Passed 0.34 s
agc_driver_image_sample_lod_clamp_shader_lane Passed 0.45 s Passed 0.35 s Passed 0.40 s Passed 0.34 s
agc_driver_image_sample_shared_sampler Passed 0.33 s Passed 0.28 s Passed 0.25 s Passed 0.25 s
agc_driver_image_sample_unnormalized Passed 1.26 s Passed 0.90 s Passed 0.84 s Passed 0.86 s
agc_driver_image_sample_vcc_sampler Passed 0.33 s Passed 0.27 s Passed 0.25 s Passed 0.23 s
agc_driver_image_sint8_gather_constant_all_bits Passed 0.36 s Passed 0.23 s Passed 0.29 s Passed 0.25 s
agc_driver_image_sint8_gather_constant_one Passed 1.37 s Passed 0.26 s Passed 0.26 s Passed 0.26 s
agc_driver_image_table Passed 1.35 s Passed 0.93 s Passed 0.82 s Passed 0.83 s
agc_driver_image_table_array_views Passed 1.60 s Passed 0.30 s Passed 0.26 s Passed 0.26 s
agc_driver_image_table_cache Passed 0.10 s Passed 0.07 s Passed 0.04 s Passed 0.05 s
agc_driver_image_table_cache_bounds Passed 2.51 s Passed 1.06 s Passed 0.94 s Passed 0.96 s
agc_driver_image_table_packed Passed 0.98 s Passed 1.04 s Passed 0.66 s Passed 0.62 s
agc_driver_image_table_packed_by Passed 2.31 s Passed 0.66 s Passed 0.72 s Passed 0.71 s
agc_driver_image_table_packed_empty Passed 0.40 s Passed 0.32 s Passed 0.43 s Passed 0.32 s
agc_driver_image_table_packed_guards Passed 0.51 s Passed 0.34 s Passed 0.55 s Passed 0.33 s
agc_driver_image_table_packed_isolated Passed 1.08 s Passed 0.40 s Passed 0.37 s Passed 0.39 s
agc_driver_image_table_packed_load_mip Passed 2.97 s Passed 0.67 s Passed 0.81 s Passed 0.65 s
agc_driver_image_table_packed_load_mip_sgn Passed 2.80 s Passed 0.74 s Passed 0.66 s Passed 0.66 s
agc_driver_image_table_packed_load_sgn Passed 2.81 s Passed 0.68 s Passed 0.72 s Passed 0.69 s
agc_driver_image_table_packed_mips Passed 1.29 s Passed 1.16 s Passed 1.03 s Passed 0.93 s
agc_driver_image_table_packed_mixed Passed 1.14 s Passed 0.33 s Passed 0.41 s Passed 0.35 s
agc_driver_image_table_packed_rejected Passed 0.53 s Passed 0.45 s Passed 0.37 s Passed 0.41 s
agc_driver_image_table_packed_stores Passed 2.35 s Passed 0.83 s Passed 1.01 s Passed 0.91 s
agc_driver_image_table_packed_unmeasured Passed 0.31 s Passed 0.23 s Passed 0.26 s Passed 0.23 s
agc_driver_image_table_reuse Passed 1.50 s Passed 0.49 s Passed 0.41 s Passed 0.44 s
agc_driver_image_table_reuse_draw_pipeline Passed 0.62 s Passed 0.44 s Passed 0.44 s Passed 0.45 s
agc_driver_image_table_reuse_plan_verify Passed 0.54 s Passed 0.40 s Passed 0.45 s Passed 0.50 s
agc_driver_image_table_reuse_records Passed 0.34 s Passed 0.30 s Passed 0.28 s Passed 0.31 s
agc_driver_image_table_reuse_records_narrow Passed 0.35 s Passed 0.27 s Passed 0.29 s Passed 0.28 s
agc_driver_image_table_reuse_retaken_cleared_depth_surface Passed 0.43 s Passed 0.38 s Passed 0.28 s Passed 0.32 s
agc_driver_image_table_reuse_retaken_depth_surface Passed 0.33 s Passed 0.38 s Passed 0.29 s Passed 0.29 s
agc_driver_image_table_reuse_retaken_mirrored_depth_surface Passed 0.38 s Passed 0.34 s Passed 0.31 s Passed 0.29 s
agc_driver_image_table_reuse_retired_depth_surface Passed 0.36 s Passed 0.29 s Passed 0.31 s Passed 0.29 s
agc_driver_image_table_variants Passed 0.51 s Passed 0.46 s Passed 0.41 s Passed 0.41 s
agc_driver_image_table_vouch_queued_draws Passed 0.34 s Passed 0.33 s Passed 0.32 s Passed 0.33 s
agc_driver_image_table_vouched_lookups Passed 0.70 s Passed 0.61 s Passed 0.60 s Passed 0.60 s
agc_driver_many_direct_samplers Passed 1.48 s Passed 0.45 s Passed 0.38 s Passed 0.37 s
agc_driver_many_table_samplers not on main Passed 13.12 s Passed 0.71 s Passed 0.66 s
agc_driver_nested_image_table Passed 0.72 s Passed 0.39 s Passed 0.45 s Passed 0.38 s
agc_driver_nested_image_table_budget Passed 0.36 s Passed 0.35 s Passed 0.35 s Passed 0.34 s
agc_driver_nested_image_table_large Passed 0.44 s Passed 0.27 s Passed 0.28 s Passed 0.27 s
agc_driver_nested_sampler_table Passed 0.51 s Passed 0.36 s Passed 0.34 s Passed 0.33 s
agc_driver_pointer_phi_sampler_table Passed 0.61 s Passed 0.36 s Passed 0.43 s Passed 0.33 s
agc_driver_resident_heap_mirror Passed 1.93 s Passed 0.61 s Passed 0.66 s Passed 0.59 s
agc_driver_resident_heap_mirror_no_publish Passed 0.54 s Passed 0.47 s Passed 0.48 s Passed 0.46 s
agc_driver_sparse_heap_import_mirror Passed 1.12 s Passed 0.29 s Passed 0.28 s Passed 0.26 s
agc_shader_device_profile Passed 0.07 s Passed 0.07 s Passed 0.02 s Passed 0.02 s
  • agc_driver_many_table_samplers is new, so main has no run of it. On every head run it printed 128 samplers (124 through the record table, 4 direct as 8 sampler elements), with table sampler 64 wrapping and direct sampler 127 reading its opaque black border.
  • Every test opens a device, and each selected the R9700 (subgroup=64).
  • agc_shader_sampler_limits is not included, and with it the PR's new 128-sampler cases in ShaderMemory.cpp. It runs from agc_shader_memory_tests.exe, which on this host is removed right after the link, so the post-link objcopy fails with Invalid argument.
  • The main run and head run 1 were each the first after a rebuild, so their times include a cold start (13.12 s for the new test on run 1, then 0.71 s and 0.66 s). This is not a speed claim.

Validation:

  • Insert instance layer "VK_LAYER_KHRONOS_validation" appears 52 times in the main log and 53 times in each head log, once per test.
  • was not found but was requested by env var VK_INSTANCE_LAYERS appears in no log.
  • VUID- lines: 0 on main, and 0, 0 and 0 on the three head runs. The negative-control and mutation logs also have none.

Other open PRs:

Host:

  • GPU: AMD Radeon AI PRO R9700 (gfx1201, 1002:7551), driver 32.0.31044.16, Vulkan 1.4.349
  • Validation layer: Khronos 1.4.363 (LunarG SDK)
  • CPU and OS: Ryzen 9 9950X3D, Windows 11 Pro 26300
  • Build: WinLibs GCC 15.2, Release
  • Commits: head 5943745842, merged onto main efc6f9c3ba as 9e98bbccc5

AI-assisted: yes

@xXPBSXx

xXPBSXx commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Data for PPSA03685 with #8939 and this change merged locally onto main. It is data for one title and does not show that the title works.

Base main 4f2aade; #8939 at 3a24890 (its head is now 9e5960f, a merge of main into the branch, which was not tested); #23409 at 5943745. Merging #8939 into main conflicted only in core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmake and core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, where the side of main was kept; #23409 merged on top of it without a conflict. Nothing was pushed.

Offline replay (agc_shader_replay, Windows, CPU only, one process per arm, same main) of the prepare request of the compute shader 0x200c520000 that PPSA03685 recorded on 2026-11-24: with #8939 alone it ends with rc 1 after 37 s, resource analysis failed: sampler resource limit exceeded; with #8939 and this change, --prepare returns rc 0 after 2 min 43 s, prepared: 12373337 SPIR-V words, no message.

Two runs of the title with a local experiment build of main + #8939 + this change (commit 8b2c095ae374, not pushed; Windows; NVIDIA GeForce RTX 4080 SUPER; empty shader-cache directory; no system fonts; no bot; limit 600 seconds): neither error log contains resource limit (0 lines in each) or GetImageResource; both end after 4 min 6 s and 3 min 48 s with FATAL: unhandled exception 0xc0000005 (line 502 of the first log, line 1418 of the second) and the title's message GameThread timed out waiting for RenderThread after 120.00 secs (lines 516 and 1432).

Not shown: whether the game runs after that message, the pipeline build (--materialize is not possible with the recording), another GPU, Linux, macOS, and a run with system fonts.

AI-assisted (Claude Code).

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Sampler Capacity

Layer / File(s) Summary
Sampler capacity and masks
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ShaderInfo.hpp, core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp, core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
ShaderInfo::MaxSamplers increases to 128. ImageTableElement stores sampler membership in SamplerMask, and ResolveImageTables sets sampler indices through that type.
Binding and specialization integration
core/shader/recompiler/Optimization/src/BindingAllocator.cpp, core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp, core/shader/recompiler/PipelineSpecialization.hpp, core/shader/recompiler/ShaderDiskCache.hpp
Binding allocation checks sampler capacity for non-table samplers. Descriptor binding iterates sampler masks, specialization-range assertions and selected base values change, and ShaderDiskCache::FormatVersion increments to 101.
Sampler planning and execution coverage
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp, core/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cpp, core/libs/prx/libSceAgcDriver/tests/execution/ManyTableSamplers.cpp, docs/dev/debt/changes/feat-shader-sampler-index-masks.md
Tests cover plans and bindings with up to 124 table samplers plus four direct samplers, allocation at the sampler heap capacity, and execution with 128 samplers. The change note records sampler and image/sampler-pair limits.

Suggested reviewers: eaglebearerys, oneandonlydean, celegans12, muhmuhkuh

Change: Feature

Merge Risk: Minimal · up to 2d284

This change raises the planned sampler limit to 128, keeps direct samplers at 32, and bumps the shader cache version. Inspection found no concrete defects in the mask handling, binding allocation or specialization ranges. It is ready to merge.

Security architecture risk: Minimal · up to 2d284

The shader recompiler can plan up to 128 samplers without increasing the 32-direct-sampler limit. The cache rejects incompatible artifacts and the recompiler can rebuild them, so an upgrade may require recompilation but does not require an operator to clear the cache.

Security review details

Security Blast Radius

  • observed — Guest shader input can request more distinct sampler identities in a single compilation. That change does not raise the direct sampler heap limit: the allocator rejects more than 64 heap elements, equivalent to 32 direct samplers.

Trust Boundaries and Controls

  • observed — At descriptor construction, Populate checks the sampler lookup index and builds heap masks only from element positions after enforcing the 64-element bound. The wider logical index does not become a host descriptor offset on this path.

Dependencies

  • observed — Prebuilt cache compatibility depends on the generated compiler source identity, not the loose-entry format number. The build manifest hashes recompiler headers, including PipelineSpecialization.hpp, so the changed IDs feed that identity.

Data and control flow

  • observed — ResolveImageTables records direct-sampler membership in shader-index space. Populate translates those indices through a per-sampler lookup into heap-element masks; shader indices above 63 are not used as shifts into a 64-bit heap mask.

Resilience and Maintainability Implications

  • observed — The remaining direct-heap check runs against a candidate layout before BindingAllocator replaces the stored layout and marks it complete. A refusal at that check does not publish the candidate bindings.
  • inferred — Different compiler source identities separate loose-cache destinations across the two builds. Within a destination, the existing writer publishes via a temporary-file rename, and readers reject incompatible or incomplete entries. Recovery is recompilation, not a guarantee of a warm cache or preservation of queued writes after interruption.

Rollout and rollback

  • inferred — The running build controls compatibility: ShaderDiskCache checks loose entries at load, and CachePack checks compiler source identity when opening a pack. Neither upgrade nor rollback requires manual cache deletion. If operators want prebuilt hits, they need a pack for the running build; otherwise a miss falls back to compilation. Rollback does not guarantee that older cache entries are still available.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b8dc6fe-818a-4edb-a98e-da99c773a48d
Commits

Reviewing files that changed from the base of the PR and between 0dca74e and 2d28425.

Files selected for processing: 2

  • core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
  • core/shader/recompiler/ShaderDiskCache.hpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@frankea

frankea commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

On the debt file: correct, the PR edited the entry in docs/dev/debt/shader.md in place. bccfeb0 and 53d7372 restore that file to main and add docs/dev/debt/changes/feat-shader-sampler-index-masks.md with a ## change A shader plans at most 64 [samplers] operation carrying the new entry. python3 tools/debt_fold.py --check reports no error for it (the two errors it prints are in other fragments, docs-libkernel-pro-measured-1360.md and fix-kernel-sys-title-workaround-bit-limit.md), and tools/check_conventions.py --base origin/main passes. The code is unchanged, so no test was rerun for these commits.

On #22628: also correct, and the checklist here was out of date. #22628 at 0c47c60 now puts BufferKeepsDestinationBase at 58560, the same ID as this PR's FoldOffsetBase, and its static_assert gives it ImageBase / BufferWords IDs from there, over FoldOffsetBase and MirrorUnnormalizedBase. Both PRs are open; whichever lands second has to move its range, and the free block from 59072 up to ImageComponentBase (65536) holds either. #22583 sets FormatVersion = 97, the same number as this PR (#22628 sets 99); whichever of the two lands second needs a new number.

AI-assisted: yes (Claude Code)

@frankea

frankea commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Up to the shader this matches the RTX 4090 run in the description: with #8939 and this PR the replay prepares the module (12,373,337 words here, close to the 12,420,660 the Mac replay gave on another main and #8939 head), and the title logs no resource limit refusal. The end differs. In the 4090 run the title stopped on GameThread timed out waiting for RenderThread after 120.00 secs while the driver's compiler threads were still busy with the 10,335,484-word pipeline, and the description does not report an exception. Your two logs show FATAL: unhandled exception 0xc0000005 14 lines before that message. That access violation was not looked into here, so its cause is not known; nothing in this PR was run against it.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this change; the inspected sampler widening and table-to-direct mask conversion look consistent, with execution test registration still unverified.

What I ran

Reviewed head 53d73726d06d50d658c1a994c70f41abe5909cc7 using the prepared diff and repository reader. No build or tests were run.

Results

Check Result Note
Diff and targeted source review passed Core changes inspected
Build and tests not run Author reports runs; not independently verified
Execution test registration not run No registration match found in the inspected test directory

Findings

Blocking

None.

Non-blocking

  • Please confirm the new ManyTableSamplers.cpp execution test is included by the build/test configuration. The source is present, but a content search in the tests directory found no reference to ManyTableSamplers.

Not verified

core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp is listed as excluded from the review bundle because it is too large; only targeted ranges were read through the repository reader. The execution test registration path and actual build/test results were not verified. Other changed files marked reviewed in manifest.json were read in targeted ranges; the new debt fragment, ShaderDeviceProfile.cpp, ManyTableSamplers.cpp, ShaderInfo.hpp, BindingAllocator.cpp, DescriptorBindingBuilder.cpp, ResourceMaterializer.cpp, PipelineSpecialization.hpp, and ShaderDiskCache.hpp were inspected.

To get this to a good state

Nothing is required. Optional: confirm the execution test registration.

@xXPBSXx

xXPBSXx commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

On the 0xc0000005 in the two logs of the earlier comment: it is the guest's own abort. In the first log the line FATAL: unhandled exception 0xc0000005 (line 502) is followed by rip ... libc.prx.guest.prx+0x141b0 (line 503), read of 0xffffffffffffffff (line 504) and guest abort() (int 0x45) (line 505); the second log has the same four lines at 1418 to 1421. The title's message GameThread timed out waiting for RenderThread after 120.00 secs is printed as the contents of register r12 in the same block (lines 516 and 1432), so lines 502 to 505 are the guest's abort carrying that message.

This is a reading of those lines only: it says nothing about why the render thread did not answer within 120 seconds, and nothing was run against the exception.

AI-assisted (Claude Code).

@xXPBSXx

xXPBSXx commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

A count for the compute shader of PPSA03685 that stopped at the sampler limit in the earlier comment. Base main e55b89a (the merge of #8939), without this pull request, plus a local diagnostic in AddSampler in core/shader/recompiler/Optimization/src/ResourceTracker.cpp (not committed, not pushed) that prints every new sampler source and, at the limit, returns the last sampler instead of ending the analysis, so that the count can go on. A replay of the prepare request of the shader 0x200c520000 with agc_shader_replay (Windows, CPU only, one run, 74.6 s) printed 65 distinct sampler sources: 61 are columns of a descriptor table and 4 are direct samplers. The first source past the limit of 64 (ShaderInfo::MaxSamplers, ShaderInfo.hpp:16) is source 123, a table column, so the shader is 1 above the limit; this pull request plans 128 samplers and keeps 32 direct, and 65 and 4 are within both.

The log has 136 lines: each of the first 64 sources appears twice (two passes of the analysis) and source 123 appears 8 times (4 program counters, 2 passes). The chain of the four dwords of a source is ReadConst(GetSrtResource, Immediate) four times in 134 lines and Immediate four times in 2 lines; no chain contains a Phi. Nothing is shown about what comes after the sampler count.

AI-assisted (Claude Code).

@frankea

frankea commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

That settles the earlier difference: the 0xc0000005 is the guest's own abort() carrying the GameThread timed out waiting for RenderThread message, so your run ends the same way as the RTX 4090 run in the description, not on a separate crash. The sampler count matches the description too: 65 sampler sources in 0x200c520000, 4 of them direct and 61 table columns, one past main's 64 and within this PR's 128 samplers and 32 direct. Nothing was rerun here for this note.
AI-assisted: yes (Claude Code)

…ndex-masks

# Conflicts:
#	core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
#	core/shader/recompiler/ShaderDiskCache.hpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

The change supports up to 128 planned samplers while keeping direct samplers within the 64 element heap; I found no verified defect, but did not run the checks needed to justify approval.

What I ran

Reviewed head 0dca74e2768b89b75d9003c2a40bf4c7dd10957f. I read all 10 changed files, including the added lines of ShaderMemory.cpp through repo_read.py. No commands or tests were run; hardware and CI results in the description are author reported.

Results

Check Result Note
Source review passed All changed files read
Tests not run Hardware results are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds, tests, and runtime behavior were not independently verified. The review bundle excluded the full ShaderMemory.cpp text, but I read its changed lines from the pinned repository head. No other changed files were excluded from review.

To get this to a good state

Nothing is required. The author reported test results are useful context, but were not independently rerun.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 29, 2026
@xXPBSXx

xXPBSXx commented Dec 1, 2026

Copy link
Copy Markdown
Contributor
  • On a local, unpushed tree of main 4f2aade plus fix(shader): take lane-mask arms and a merged high word in a pointer-keyed record pointer #8939 and this PR at 5943745, PPSA03685 gets past the sampler limit and reaches compute shader 0x200c520000 (10,299,427 and 10,300,893 SPIR-V words in two title runs, recompile 2.7 s and 2.4 s). The log then prints creating a pipeline for it, never a matching created a pipeline, and the title's own watchdog ends the run: GameThread timed out waiting for RenderThread after 120.00 secs (title runs on 2026-12-01, 07:36 and 16:05 UTC).
  • Replaying the captured pipeline (41,204,045 bytes) offline, without the title, built with SPIRV-Tools on: on 2026-12-01, on an RTX 4080 SUPER (Windows driver 32.0.16.1074, Vulkan 1.4.341) two runs (17:06 and 17:11 UTC) hit a 300 s limit with no result and one run (17:45 UTC) crashed after 882 s with an access violation inside nvgpucomp64.dll; on an RX 6400 (driver 32.0.21033.3005, Vulkan 1.4.315) one run (18:01 UTC) returned Vulkan result -1 from vkCreateComputePipelines after 359 s. No run produced a pipeline.
  • Not shown: why it fails (shader size or structure), whether it would finish given more time, whether splitting the shader helps, or what a PS5 does. The replay exit codes were not recorded, and the capture tool's size limits were raised locally only to write the dump. This is a measurement for the title record, not a request for a change to this PR.

AI-assisted (Claude Code).

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Dec 2, 2026
@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Dec 2, 2026
@ycbuzi

ycbuzi commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Tested 0dca74e276 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 2 tests failed out of 7499; 99% tests passed, 3 tests failed out of 7499. 2 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7499; 100% tests passed, 0 tests failed out of 7499. run

GPU (software Vulkan): 5 GPU tests (AGC, shader recompiler) passed twice on Mesa lavapipe (Mesa 25.2.8-0ubuntu0.24.04.5 (LLVM 20.1.2)) on a GitHub-hosted Ubuntu 24.04 runner, with the Khronos validation layer on and the shader cache off, alongside main fc294cbbb5: no Vulkan validation message appears that main does not also produce. run

Not covered: GPU hardware. lavapipe runs Vulkan on the CPU, so this says nothing about how real GPU drivers handle the changed paths.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@Plyxen Plyxen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the diff at 0dca74e276. Windows 11, GCC 15.2, merged into main at cf556db18c3 together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • agc_driver_many_table_samplers, agc_shader_device_profile and the 43 tests of agc_shader_memory_tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (same tree and tests, the changed files of those PRs put back to main's): the first two fail on both GPUs (agc_shader_device_profile: "unexpected profile validation error").

Not checked: a title.

AI-assisted: yes (Claude Code)

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch widens resource-index masks to 128 bits while keeping direct heap-element occupancy at 64 bits. The execution fixture checks table sampler 64 and direct sampler 127 with distinct results. That fixture explicitly skips llvmpipe because of a known wrong readback there. Please report the hardware execution separately from the paired shader-memory controls, which are queued locally and can verify the planning limits without exercising that hardware readback.

AI-assisted: yes.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Dec 5, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

Reviewed head 2d284254b049b709dd1d2dde9f2b69783e927c60. I read the prepared description, commits, manifest, diff, and files.json, plus the available changed-file texts. I checked the reader usage with python3 repo_read.py --help; its first source read succeeded, but later reads failed because it could not write reads.jsonl in the read-only workspace. No tests or builds were run.

Results

Check Result Note
Prepared review materials passed Read description, commits, manifest, diff, and file list
Changed-file review not run One full file was excluded; pinned reader could not continue
Tests and build not run No tests or compilation attempted

Negative control

Not run; no tests were run.

Findings

Blocking

None verified in the changed code inspected.

Non-blocking

None.

Sources

Not verified

The full text of core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp was excluded from the review folder. I inspected its changed hunks in the diff, but could not read targeted source context at the pinned head because the reader could not append its log. No behavior beyond the inspected hunks is verified. The other 10 changed files were available in full; I inspected relevant sections rather than reading each file line by line.

To get this to a good state

Nothing is required. Optional: complete a targeted review of ShaderMemory.cpp when the pinned reader can operate with its read log enabled.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Dec 5, 2026
@frankea

frankea commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

The hardware execution is already reported apart from the shader-level checks in the PR body: the agc_driver_many_table_samplers row is RTX 4090 only (fails 4/4 on main with sampler resource limit exceeded, passes 4/4 on the head with sampler 64 wrapping and sampler 127 at its border color), and the validation layer results are a separate row. The test skips on the M5 Max because MoltenVK binds 16 samplers per stage, and on lavapipe because of the wrong readback a reviewer measured there. Plyxen's review above adds an RTX 5080 and a Radeon iGPU, with the control failing on both.

A lavapipe run of the shader-memory and sampler-limit tests checks the planning limits only, and I will label it that way if I add one.

AI-assisted: yes (Claude Code)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants