fix(shader): keep an unbounded pixel LDS array in a storage buffer #7888
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7888"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-19T12:27:58Z.
What
A pixel shader whose local data share address has no compile-time bound keeps the full 8192-dword array. On NVIDIA proprietary drivers that array, stored as a SPIR-V
Functionvariable, does not finish past about 4 GiB of private memory over every resident invocation (RTX 5090 on 617.42: 4096 dwords completes, 6144 times out; 4090 measured similarly). The array is not shrunk. Abovemin(4096, 4 GiB / (SMs × warps/SM × subgroup × 4))it moves to a storage buffer, one 8192-dword region per invocation, and an address at or past 8192 still reads 0 and does not store. Other drivers keepFunction;largePixelFunctionLdsBufferis set only forVK_DRIVER_ID_NVIDIA_PROPRIETARY.Each subgroup takes one slot from a pool sized to
min(2 GiB, maxStorageBufferRange), retained until device teardown. A draw that needs more slots than the pool has sets a sticky overflow flag, andWaitIdlethrows instead of wrapping, dropping the write, or recycling slots (a full-screen 1920×1080 wave32 draw needs far more than 2047 slots and therefore throws by design). The header is mapped host-visible/coherent soCheckPixelFunctionLdscan read that flag without a GPU readback; allocation prefers a device-local host-visible type when the driver exposes one so the pool can stay in VRAM on discrete GPUs.This does not change the wave32 bounded draw in #7708.
Tested
Windows 11, NVIDIA GeForce RTX 5090, driver 617.42, WinLibs GCC 15.2.0, Release.
APS5_DUMP_FRAMESunset.With
ANYPS5_NO_SHADER_CACHE=1, and again with the shader cache:agc_driver_pixel_lds_limit_tests: dword 8000 and dword 8191 read back the stored values, dword 8192 reads 0, 2048 pixels, exit 0. The run prints[gpu] pixel function LDS pool: 2047 subgroups, 2047 MiB, stride 32 lanes. Overflow case asserts theWaitIdlethrow when the pool is exhausted.agc_driver_pixel_lds: all four stages,pixel LDS tests passed: 12 draws, 24576 pixels, 73728 LDS results, exit 0. No device-lost and novkQueueSubmitfailure.agc_shader_memory_testsexit 0, including the check that an address with no bound stays 8192 dwords.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)Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T14:09:01Z.
AMD and Intel Windows data:
agc_driver_pixel_lds_limitpasses with this PR on an AMD RX 9070 XT and an Intel UHD 770, so the storage-buffer path for the unbounded pixel LDS array runs on both.Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head834d52805merged intomain85029a00f.agc_driver_pixel_lds_limitThere is no run without the change: the test reads
RecompileResult::functionLdsBuffer, which this PR adds, so the test alone does not build onmain.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T15:44:19Z.
On AMD/RADV this PR breaks the existing
agc_driver_pixel_ldstest. It passes onmainand fails 3/3 with the PR merged.Merged onto
main43a2abaf7(clean merge). AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release,ANYPS5_REQUIRE_VULKAN=1.ctest -R '^agc_driver_pixel_lds$'mainpixel LDS tests passed: 12 draws, 24576 pixels, 73728 LDS results)With the PR, the wave64 bounded, wave64 unbounded and wave32 bounded stages all finish. The wave32 unbounded stage, the one that now goes through the new buffer, fails:
Device lines from the same run:
So on RADV the pool is sized for 64-lane subgroups, and a wave32 pixel program does not get 32-lane subgroups: only compute and mesh do. On the RTX 5090 in the description, the host subgroup and the guest wave are both 32 lanes, so the two cannot differ. My guess, not verified: two guest wave32s that share one 64-lane host subgroup address the same pool slot, or the slot index or lane offset assumes the guest wave size. That would fit only the wave32 unbounded stage failing. lavapipe skips this test, so CI cannot show it.
The full suite with the PR otherwise matches
main: the same two failures,agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784), plus this one. The PR's newagc_driver_pixel_lds_limitpasses on RADV.GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38; lavapipe (skips)
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-19T17:47:38Z.
The wave32 unbounded miss on RADV matches the lane index.
EmitSubgroupLocalInvocationIdmasks a wave32 program on a wider host subgroup down to 32 lanes, so both halves of a 64-lane fragment subgroup wrote the same 32 regions. The pool stride was already the host subgroup size (64 on that 7900 XT). The region index for that case is now the rawSubgroupLocalInvocationId, so lane 32 is a different region from lane 0. One slot is still elected for the whole subgroup.This machine's fragment subgroup is 32 lanes, so the two halves never share a subgroup here. After
80bf3630d,agc_driver_pixel_ldsandagc_driver_pixel_lds_limitstill pass on an RTX 5090, driver 617.42, Windows 11,ANYPS5_NO_SHADER_CACHE=1. The RADV wave32 unbounded stage is the run that can confirm the fix.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T18:02:26Z.
Review: CHANGES_REQUESTED
Thanks for the fix and for the RADV wave32 follow-up. Reviewed by reading the diff; the head has only Conventions CI.
Draw.cpp:161:vkCmdFillBufferzeroes bytes 0-7 (counter and overflow flag) at the start of every draw. A draw that overflowed sets the flag, and the next draw clears it beforeWaitIdlereads it, soCheckPixelFunctionLdsonly catches an overflow in the last draw before the wait. The overflowing draw has already written slot 0 for the excess subgroups. Keep the flag sticky (reset it only where it is checked) or check it per submit.Draw.cpp:162-163: the barrier hassrcStageMask = TRANSFER | HOST, so the fill is not ordered after earlier draws' fragment shaders in the same command buffer. Those can still be taking slots and writing their regions while the counter is reset to 0, and the next draw hands out the same slots. It needs a barrier fromFRAGMENT_SHADERshader writes to the transfer write (or a counter that is not reset while draws are in flight).Draw.cpp:112-116: this allocates up to 2 GiB host-visible/coherent memory on every driver, kept untilReleasePixelFunctionLds. The bug described is NVIDIA 617.42Functionarrays, so scope the buffer path to that driver (vendor/driver ID), as docs/dev for memory handling asks for driver workarounds that retain memory, or state the bound and show peak RSS before/after on a draw that takes the buffer path. "Freed at device teardown" is not a bound. Please also say whether host-visible memory is the right type here (on discrete GPUs it can end up in system RAM).PixelLdsLimit.cpphas no overflow case (a draw needing more slots than the pool has, assertingWaitIdlethrows), and it skips when the host subgroup is < 32. Please add the overflow check and re-runagc_driver_pixel_ldson RADV after80bf3630d(the earlier AMD/Intel runs are on834d52805).Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-19T18:17:23Z.
3acd3c4bdtakes the pool notes.The per-draw fill now zeroes only the slot counter, and only after a barrier from earlier fragment-shader access. The overflow flag stays set until
CheckPixelFunctionLds, which runs fromWaitIdleafter the device is idle and then clears it. Slots are reused between draws. One draw that needs more subgroups than the pool holds still throws: on this 5090 that is 2047 subgroups, so a 1920x1080 draw does.The storage buffer is now emitted only for NVIDIA's proprietary driver, which is the driver where a
Functionarray of 6144 or more dwords does not finish. Other drivers keep theFunctionarray, so they do not allocate the pool. The RADV wave32 unbounded stage then stays on the path that already passed onmain.On this RTX 5090, driver 617.42, Windows 11,
ANYPS5_NO_SHADER_CACHE=1:agc_driver_pixel_ldspassed all four stages, andagc_driver_pixel_lds_limitpassed the 64x32 readback and then a 256x256 draw, which threwpixel function LDS subgroup slots exhausted.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T18:41:47Z.
Rebase handoff, with one PR-own failure confirmed — rebased onto current
main(all commits, authorship unchanged). One test conflict unioned.The finding:
agc_shader_memoryfails with "new requests did not use serialization version 37" — and it fails identically on your own unrebased head, so it is the branch's own state: the serializer bump to v37 (or whichever version this PR's encoder changes require) did not land in the tree the test sees. Everything else is green apart from the four knownmainregressions (#5444 Mesa, #7584 BDA, #7766, #7784); conventions pass.To pick it up:
Head is
5f4f31f57.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-19T18:54:29Z.
Merged current main. Request version 37 is already the stencil operation export, so the pixel function LDS flag is version 38.
agc_shader_memoryandrequest_serializer_testspassed here after that. The expected prefix is the full 12-characterNVNQQSYAAAA=.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-19T21:58:31Z.
The review notes are in the commits after the request.
Local runs of head
0af52c0a0:agc_driver_pixel_ldsandagc_driver_pixel_lds_limitpassed. The limit run printed the 2047-subgroup pool, dword 8000 and 8191, and the overflow throw.Linux RADV was not run.
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T07:26:11Z.
Closing the loop on the finding from my handoff: the
agc_shader_memoryfailure ("new requests did not use serialization version 37") is fixed on0af52c0a0— the version-38 serialization resolves it. Verified on Linux (CachyOS, AMD RX 9070 XT / RADV):agc_shader_memory_testspasses on the new head (capture, strict validation and deterministic replay).Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-20T09:44:09Z.
Rebased onto current
main(request serializer is already at 38 for mesh barycentrics, so the pixel function LDS flag is version 39; fixture prefixNVNQQScAAAA=).Review items from the earlier pass are in
8ed61fcc8/ head:vkCmdFillBufferclears only the slot counter (4 bytes);CheckPixelFunctionLdsclears the flag afterWaitIdlereads it.PixelLdsLimitasserts the overflow throw.FRAGMENT_SHADER→TRANSFER.VK_DRIVER_ID_NVIDIA_PROPRIETARY(largePixelFunctionLdsBuffer).Local after rebase:
request_serializer_testspassed; conventions clean aside from the pre-existing debt-length warning on the lengthened LDS entry.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-20T09:56:48Z.
Follow-up after actually running the suite on this tip (
874659b20+ fixture fix):request_serializerpassedagc_shader_memoryfailed until the v39 trailer was accounted for in legacy downgrade fixtures / unsupported-version probe (NVNQQSgAAAA== 40); now passedagc_driver_pixel_ldspassed (RTX 3080)agc_driver_pixel_lds_limitpassed (RTX 3080), including the overflow throw pathSafe to re-request review on this head.
Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-20T11:29:40Z.
RTX 5080 data (Windows, same driver as the failing 4090 in #7708), plus one validation finding on this PR.
NVIDIA GeForce RTX 5080 (
10de:2c02, subgroups of 32), driver 617.42 (32.0.16.1742), Windows 11 Pro 26300, i9-14900K, WinLibs GCC 15.2.0 r7, Release,BUILD_TESTING=ON, every execution test built:agc_driver_pixel_ldsagc_driver_pixel_lds_limitmain1d4164552ANYPS5_REQUIRE_VULKAN=1)ebfc3f4ca, clean)No
[device-fault]and novkWaitForFenceserror in any run, so the device loss doesn't reproduce on Blackwell here either.With
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(layer 1.4.363),mainreports noVUID-, but this PR adds one on the wave64 unbounded stage and on both limit-test shaders:That is the slot broadcast in
SpirvBufferAccess.cpp, whose lanesourcecomes fromOpGroupNonUniformBallotFindLSB. Before SPIR-V 1.5,OpGroupNonUniformBroadcastneeds a constant lane. Since the ballot is ofOpGroupNonUniformElect, which picks the lowest active invocation,OpGroupNonUniformBroadcastFirstoflocalshould give the same slot without the dynamic lane.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-20T14:30:43Z.
Tested at
ebfc3f4ca. The head moved to69ee247b2while this ran; the only change is the slot broadcast (OpGroupNonUniformBallot+FindLSB+OpGroupNonUniformBroadcastreplaced byOpGroupNonUniformBroadcastFirst), so the gate finding below is unaffected, but the runs were not repeated on the new head.Independent NVIDIA run on Windows. The PR's tests pass. The negative control does not reproduce the
Function-array failure on this card and driver.Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 (
10de:2786, subgroup 32), driver 596.21, Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2.0 r7, Release, full build. Headebfc3f4camerged ontomain1d4164552(clean; #7849 was stacked on top for an unrelated run, and the two PRs share no files).request_serializer,agc_shader_memory,agc_driver_pixel_lds,agc_driver_pixel_lds_limit(CTest,ANYPS5_NO_SHADER_CACHE=1)agc_driver_pixel_lds,agc_driver_pixel_lds_limitwith the shader cachepixel LDS limit overflow passedin every limit runPool line, the same in every run:
[gpu] pixel function LDS pool: 2047 subgroups, 2047 MiB, stride 32 lanes.Negative control: I kept the PR and forced
target.largePixelFunctionLdsBuffer = falseinVulkanDevice::buildTarget, then ran under--timeout 60.agc_driver_pixel_lds_limitpasses 3/3 in 1-3 s on the 8192-dwordFunctionarray. The pool line does not appear, and the test'sfunctionLdsBuffer == falsecheck holds.agc_driver_pixel_ldspasses 3/3.Functionpath that read back every pixel. 256x256 passes 3/3 and 1024x1024 passes 3/3.vkQueueSubmitfailure.On this Ada card with 596.21, the gate therefore changes a draw that works into one that throws
pixel function LDS subgroup slots exhaustedonce it needs more than 2047 subgroups. The 256x256 draw in the limit test does exactly that. The failure in the description was measured on driver 617.42, and the gate covers everyVK_DRIVER_ID_NVIDIA_PROPRIETARYdevice. Could it be bounded by the driver version or architecture where the failure was measured? If not, could the description say it applies to all NVIDIA drivers?Also checked:
-j1 -R '^agc_driver_': 601/604 pass. The three failures matchmain:image_array_window_past_layer_limitdoes not build (MinGWalignas(65536)), andpass_input_hazardfails with the same message onmain1d4164552. The third,pm4_replay_tool, failed because of my shell's PATH and passes on a rerun.-j8load passes when rerun serially.check_conventions.py: 0 errors. One warning: the debt entry atdocs/dev/debt/shader.md:145is 1832 characters.git diff --checkis clean.mainagainst the PR: no stop line and novkQueueSubmitfailure on either side. No title reached the buffer path.Not checked:
VUID-VkShaderModuleCreateInfo-pCode-08737OpGroupNonUniformBroadcastfinding.main(d50ec76da; the merge is clean).Written with Claude Code assistance (validation by a subagent, reviewed in this session).
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-20T16:59:09Z.
The RADV run of the current head,
69ee247b2, built as-is (it no longer merges cleanly withmain6bef96df7: the only conflict is inRequestSerializerTests.cpp, so I tested the branch on its own base,8a7ba4beb).AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release,
ANYPS5_REQUIRE_VULKAN=1. The device reportssubgroup=64, and wave32 subgroups only for compute and mesh.As submitted (the buffer is limited to NVIDIA's driver, so RADV keeps the
Functionarray):agc_driver_pixel_lds: passes 3 of 3, all four stages, including the wave32 unbounded stage that failed here before.agc_driver_pixel_lds_limit: passes 3 of 3.request_serializerandagc_shader_memorypass.With the buffer forced on RADV, to exercise the lane index fix on a 64-lane fragment subgroup: the only local change is
target.largePixelFunctionLdsBuffer = true;inVulkanDevice::buildTarget. The pool line shows the buffer path is used:agc_driver_pixel_lds: passes 3 of 3, all four stages. The wave32 unbounded stage, which returnedexpected 0 got 65536before the lane index change, is now correct.agc_driver_pixel_lds_limit: passes 3 of 3, includingpixel LDS limit overflow passed.With the Khronos validation layer (
ANYPS5_NO_SHADER_CACHE=1), both tests in both configurations add no VUID: nopCode-08737from the slot broadcast, and the only message isVkDeviceCreateInfo-pNext-pNext, which my older 1.3.275 layer prints for every device because it doesn't knowmaintenance8.So the 64-lane case works on AMD hardware too. On the question about the NVIDIA-only gate: on this card the buffer path is correct, but I haven't checked whether the
Functionarray has any limit on RADV that the buffer would avoid.GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T19:14:29Z.
Rebase handoff with a serializer-version collision resolved to v40, one fixture byte left — rebased onto current
main(a9cfea22f, all commits, authorship unchanged). This needed real format work; here's the map.The collision:
mainand this PR both took serialization version 39 for different features —main's merged-hull PR writesmergedHullat v39, your series writeslargePixelFunctionLdsBufferat v39. Same number, incompatible blobs (the pattern of #6503/#7642). The handoff moves your feature to v40 following that precedent:main's landedmergedHullkeeps 39,largePixelFunctionLdsBufferreads at>= 40u, the writer emits 40, the version cap is 40, and the tests' version bytes, prefix strings ("NVNQQSgAAAA=" is now the current-version prefix — base64-decodes with version byte 0x28), unsupported-version list (now NVNQQSkAAAA= = 41), the merged-hull positional check (- 53u, one byte for the LDS flag) and the legacy-downgrade erase (- 53u) are all moved accordingly.What still fails, and it's one byte somewhere:
agc_shader_memoryandrequest_serializerboth fail withRequestSerializer: unexpected trailing data— one constructed fixture still carries a stale byte count relative to the v40 layout. I've pinned: round-trips are symmetric (write and read both end with the LDS bool), all hardcoded legacy blobs are pre-v21 (no trailing check), the merged-hull positional check and the version-30..38 downgrade loop are corrected — the remaining mismatch is in one of the hand-built fixtures in the serializer section ofShaderMemory.cpp(between the version-40 prefix check and the version-18 blob), and you'll find the exact byte far faster than a rebase can — the fixtures are yours.Everything else is green: 1716/1721 — the three known current-
mainfailures on this stack (#7784 guest-memory, tessellation pending Mesa 26.2.6,image_array_window_past_layer_limitflagged on #6772) plus the two serializer fixtures above.To pick it up:
Head is ``.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T21:54:48Z.
@mazen320 I read the head
69ee247b2against the earlier review notes: the sticky flag, the fragment-to-transfer barrier, the NVIDIA-only scope and the documented full-screen limit are in. Two things in the draw path still need a change:Draw.cpp:2147: inrecordDraw,PreparePixelFunctionLdsruns only when the pass is not continued, butBindPixelFunctionLds(:2169) runs every time.StartDrawPass(:2099) continues the previous pass unless the draw captures, reads its target or is GPU/mesh indirect, and a pixel-LDS draw is none of those, although it records a fill and two barriers outside a pass. If the first such draw on a device continues a pass,pool.setis still null and the bind throwspixel function LDS buffer was not prepared. Later continued draws skip the counter reset, so slots add up across the pass. AddingPixelFunctionLdsSubgroup(shaders) != 0uto the begin-forcing argument would fix both.PixelLdsLimit.cppdoes one draw perWaitIdle, so a case with two draws into the same target would cover it.SpirvBufferAccess.cpp(EmitPixelFunctionLdsBase): an exhausted subgroup takes slot 0 (OpSelect(exhausted, 0, acquired)), so it shares slot 0's region with the subgroup that owns it. The flag is read only inVulkanDevice::WaitIdle, which an asynchronous flip does not call (Presentation.cpp:113waits only for a synchronous flip), so the frames before the next idle render with the shared slot. Please either check the flag where submissions retire, or reword the debt note, which says the draw throws "instead of wrapping or dropping the write".Still open from the earlier notes: the pool takes the first
HOST_VISIBLE | HOST_COHERENTtype (Context::MemoryType), which on NVIDIA is usually system memory, for 2 GiB that fragment shaders read and write. Only the 16-byte header is read by the host. Was a device-local pool with a separate host-visible header considered, and what does a large-LDS draw cost on the 5090 with the current type?Smaller: arrays from 4097 to 6143 dwords move to the buffer path too (
PixelFunctionStorageDwords= 4096), while the measured failure starts at 6144. Is there a size between the two that was measured?The branch also needs the serializer-version rebase (v39 is taken on
main; blawesom's handoff resolves it to v40).Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T06:48:40Z.
Rebased onto current
main(serializer is at 41 forfloat32DenormPreserve, so the pixel LDS flag is version 42; fixture prefixNVNQQSoAAAA=, unsupportedNVNQQSsAAAA=).Dean’s pass-begin note:
StartDrawPassnow forces a new pass whenPixelFunctionLdsSubgroup(shaders) != 0, so the slot fill is not skipped on a continued pass while the set is still bound.Local tip
c60b91c46(RTX 3080):request_serializerpassedagc_shader_memorypassedagc_driver_pixel_ldspassedagc_driver_pixel_lds_limitpassedImported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T11:03:10Z.
Rebased onto current
mainagain.maintook serialization version 42 for pixelsampleOrder, so the pixel LDS trailer flag is now version 43 (prefixNVNQQSsAAAA=, unsupportedNVNQQSwAAAA=).Local tip (RTX 3080):
request_serializer,agc_shader_memory,agc_driver_pixel_lds,agc_driver_pixel_lds_limitall passed.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T12:01:53Z.
@oneandonlydean Remaining notes from your last pass:
RetirePresents(when a present fence retires) as well asWaitIdle, and the debt note matches that (shared slot until the check throws, not "throws instead of wrapping").PixelLdsLimitdraws twice into the same target beforeWaitIdle.HOST_VISIBLE|HOST_COHERENTtype so that header can be mapped without a separate device-local body. A device-local body plus host-visible header was not measured; on discrete NVIDIA the current type is usually system memory for the full ~2 GiB. Cost of a large-LDS draw on the 5090 with this type was not measured here.Rebased onto current
main. Tipc5db72049on RTX 3080 (ANYPS5_NO_SHADER_CACHE=1):request_serializer,agc_shader_memory,agc_driver_pixel_lds, andagc_driver_pixel_lds_limit(including two draws + overflow) passed.Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-21T14:44:55Z.
RTX 4090 (Ada) check at head
c5db72049, merged ontomain2c4b116da(clean). #7708 is fixed here. One concern is left, and it also answers @oneandonlydean's question about sizes between 4096 and 6144: the size at which theFunctionarray fails depends on the GPU's size, and on the largest NVIDIA cards it is below 4096.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,ctest --test-dir build -R <test> -V. Validation runs addVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan-ValidationLayersvulkan-sdk-1.4.363.0) with implicit layers disabled; the loader log shows the layer inserted, and no log haswas not found but was requested by env var VK_INSTANCE_LAYERS.main2c4b116daagc_driver_pixel_ldswrite invaliddevice fault,vkWaitForFences graphics: Vulkan result -4agc_driver_pixel_lds, validationVUID-VUID-agc_driver_pixel_lds_limit, validationmainVUID-,pixel function LDS pool: 2047 subgroups, 2047 MiB, stride 32 lanes, overflow throwlds|shader_memory|request_serializer, validationVUID-VUID-Threshold. On this card the limit follows 4 GiB of private memory over every invocation the GPU can hold at once. The driver reports 128 SMs of 48 warps through
VK_NV_shader_sm_builtins, so 196608 invocations. Run alone onmainae7ad5ff9, the unbounded pixel draw passed with itsFunctionarray cut to 5456 dwords and lost the device at 5472. 5456 × 4 × 196608 is just under 4 GiB, and 5472 × 4 × 196608 is just over it. So on a 4090 an array from 5472 to 6143 dwords fails too, and the buffer path is needed below 6144.The same budget gives 4112 dwords for a 5090 (170 SMs, assuming 48 warps per SM there too), which fits 4096 completing and 6144 timing out there. A card with more SMs crosses 4 GiB below 4096: an RTX PRO 6000 Blackwell (188 SMs) at 3718 dwords. Other private arrays in the same program lower the limit further. So
PixelFunctionStorageDwords = 4096can still lose the device on the largest cards. A threshold ofmin(4096, 4 GiB / (shaderSMCount × shaderWarpsPerSM × subgroupSize) / 4)fromVkPhysicalDeviceShaderSMBuiltinsPropertiesNVwould cover them. Only the 4090 numbers are measured; the 5090 and RTX PRO 6000 numbers are computed from published SM counts.BUILD_TESTING=ONAI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T15:02:34Z.
Implemented the SM-budget threshold Max measured on the 4090.
pixelFunctionStorageDwordsismin(4096, 4 GiB / (shaderSMCount × shaderWarpsPerSM × subgroupSize × 4))whenVK_NV_shader_sm_builtinsis present on NVIDIA proprietary (else 4096). Serializer version 44 carries the dword count; tip0a8ea6cc1.Local RTX 3080 (
ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1):request_serializer,agc_shader_memory,agc_driver_pixel_lds,agc_driver_pixel_lds_limitpassed.Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-21T16:02:08Z.
RTX 4090 retest of
0a8ea6cc1, merged ontomaincecb540a6(clean), same setup as my run above:agc_driver_pixel_lds: 10 of 10 pass, and 5 of 5 under the validation layer with 0VUID-.agc_driver_pixel_lds_limit, validation: 3 of 3 pass, 0VUID-.lds|shader_memory|request_serializer, validation: 21 pass, 0VUID-.request_serializerandagc_shader_memorypass.On this card the budget works out to 4 GiB / (128 × 48 × 32 × 4) = 5461 dwords, so the threshold stays at 4096 and the 4090 takes the same path as before; only cards with more than about 170 SMs get a lower one. The dword count is part of the request and the cache key, so a shader cached on one card is not reused on a card with a different threshold.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T16:11:52Z.
Thanks for the retest. Agreed on the 4090 staying at 4096 (5461 budget), and on the cache key carrying the dword count so cards with different thresholds do not share variants.
Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-22T15:32:55Z.
@mazen320 #9185 adds a condition to the same
libraryKeysearly return as this PR:|| FragmentInterlock(shaders)afterSplitsAlternateAlpha(state), which keeps a pipeline whose fragment shader uses an interlock out of graphics pipeline libraries. The two conditions are independent, and the merged line keeps both:Neither PR depends on the other, so I'd propose no
Depends onin either and that the one that merges second rebases onto the first. If #7888 lands first, I'll rebase #9185 and keep your condition. Is that OK with you?Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-22T15:35:27Z.
@janzezno Agreed — independent conditions, no
Depends oneither way. Whichever of #7888 / #9185 merges second rebases and keeps bothSplitsAlternateAlpha/FragmentInterlock/functionLdsBufferon thelibraryKeysearly return. If #7888 lands first, your rebase plan looks right.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T15:50:41Z.
Review: CHANGES_REQUESTED
Thanks, the sticky flag, the
FRAGMENT_SHADER→TRANSFERbarrier, the NVIDIA-only scope, the documented full-screen limit and the overflow case inPixelLdsLimit.cppall look right ind2844b496. One point is left:Draw.cpp:129-143(PreparePixelFunctionLds): the memory type is nowDEVICE_LOCAL|HOST_VISIBLE|HOST_COHERENTwhenever one exists, and the allocation is up tomin(2 GiB, maxStorageBufferRange). On NVIDIA without Resizable BAR that type lives in the 256 MiB BAR heap, sovkAllocateMemoryfails withVK_ERROR_OUT_OF_DEVICE_MEMORYandCheckthrows; the previous host-visible type is never tried. Please fall back to the plain host-visible/coherent type when the device-local one fails to allocate (or only pick it when its heap is at leastbytes), and keep the failed buffer state clean as the existing failure path does.agc_driver_pixel_ldsandagc_driver_pixel_lds_limiton an NVIDIA card after that change; the runs listed in the thread predated2824e28d(the memory-type commit), and the overflow case only runs on the buffer path, which neither lavapipe CI nor RADV exercises.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T16:27:58Z.
Review: CHANGES_REQUESTED
The full Build on the exact head fails on Windows:
agc_shader_memory(run 39983298976) exits withRequestSerializer: unexpected trailing data.maindoes not fail it.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp: version 45 appends 5 bytes (largePixelFunctionLdsBufferbool +pixelFunctionStorageDwordsu32) after the fused-arithmetic flag, so every legacy fixture has to drop 5 more bytes. The fixtures that only addresize(size() - sizeof(std::uint32_t))drop 4 and leave one byte behind, whichDeserializerejects for version >= 21. CompareorderedVersion32(:5259-5261, resize + 2pop_backbefore the require) withversion32(:5295-5298, resize + 3pop_backfor the same tail layout);orderedVersion34,version36,version35and thelegacyBytesloop at:5407-5410need the same check. Rerunagc_shader_memoryon the final head, as the last runs in the thread were of the two pixel LDS tests only.