feat(shader): implement compute LDS beyond the device's shared memory limit #1776
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1776"
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 Celegans12 on 2026-10-08T18:54:29Z.
What
A compute shader whose LDS exceeds the host's shared-memory limit could produce an oversized Vulkan
Workgrouparray. This moves the whole LDS, including its atomic lock dword, into a coherent storage buffer with a separate slice for each workgroup. Programs that fit keep using shared memory.The driver sizes and binds that buffer from the dispatch dimensions, rejects ranges above
maxStorageBufferRange, and reads indirect dimensions on the CPU for spilled programs. LDS barriers and atomics use the corresponding storage-buffer memory semantics.Full-result serialization preserves
workgroupMemoryDwords, with a nonzero round-trip fixture and a 312-byte LinuxRecompileResultassertion. Production disk entries already persistShaderInfo::sharedMemoryBytes, from which the stride is reconstructed; the disk format is unchanged.Tested
Windows 11/MinGW-w64 GCC 15.2.0 and Linux GCC 13.3, based on
main256b8ed4: configure-DBUILD_TESTING=ON, full build,libsand registration pass. Tested merge:b5b072c8.EINVAL; this coverage remains missing.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T19:18:38Z.
Linux results on two real GPUs with different shared-memory limits, since this was tested on Windows and lavapipe. Everything passes here, including the new
agc_driver_lds_beyond_device_limit.Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
BUILD_TESTING=ON. PR head merged ontomain29e533ac.maxComputeSharedMemorySizectest -R agc_driver -j1CPU tests (
-E agc_driver): 283 / 284. The one failure isguest_dynamic_loader(subprocess aborted), which fails the same way onmain29e533ac.Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-09T01:01:43Z.
Linux run on AMD, since the description lists it as not tested: Ubuntu 24.04.5 (kernel 6.8), GCC 13.3, Release, AMD Radeon RX 7600 (RADV NAVI33, Mesa 25.2.8). This PR's head
5cad357b, merged ontomainf1451396. Full ctest: 495/495 pass, with the GPU tests running on the RX 7600 (none skipped). That includes the newagc_driver_lds_beyond_device_limit.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T05:57:49Z.
Review: CHANGES_REQUESTED
Thanks for the work and the Linux/AMD/NVIDIA runs. This one doesn't build on current
main:core/shader/recompiler/ShaderDiskCache.cpp:69:static_assert(sizeof(RecompileResult) == 296 ...)fails because of the newRecompileResult::workgroupMemoryDwords(Recompiler.hpp). Rebase onmain, update the asserted size, and say in the PR whetherEncodeResult/DecodeResultneed the field (it is derived fromShaderInfo::sharedMemoryBytesinmaterializeResult, so a decoded result probably needs it set too, otherwise a decoded result binds no set 1).agc_validate_programaborted with0xc0000409. It doesn't touch LDS, so it may be a flake, but it has to be green.ctestafter the rebase and put the newagc_driver_lds_beyond_device_limittime in Tested (a cold-pipeline run on lavapipe counts against the 120 s CI timeout).Once it builds and is green, the rest looks fine to me.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:59:54Z.
Review: APPROVED
Checked on RADV and lavapipe: the PR merged onto current
main, AGC/AgcDriver ctest 338/338, includingagc_driver_lds_beyond_device_limitandagc_shader_disk_cache. With the device-memory LDS selection forced off the new test fails, so it pins the change. Consecutive dispatches sharing the buffer are ordered by the pre-dispatch barrier. Thanks to @fisherjoey and @johnmaia for the NVIDIA and AMD runs.Pushed on top, docs only:
docs/dev/TechnicalDebt.md: a Functional line for the storage-buffer LDS (not measured on hardware, slower than shared memory, indirect group counts read on the CPU).docs/dev/ARCHITECTURE.md: a bullet under the shader pipeline for descriptor set 1 and the per-workgroup slice.Merging once CI is green.