Repository navigation
rdna2spirv: shrink and cap --mesh-compute Workgroup memory against --max-shared-memory - #8084
auswhalen999-debug wants to merge 2 commits into
Conversation
…max-shared-memory
|
Tested 11495d9 on Arch Linux, Python 3.14.10, CPU only: pass — new tests/semantic/test_ms_shared_memory_limit.py 4/4 OK. Negative control: base translator → 3 failures; restored, green again. GPU side (mesh workgroup cap on device) still open for a mesh-capable Windows runner. No game files. AI-assisted. |
|
Tested
The one NVIDIA failure, These fixtures' LDS fits well inside both devices' limits. So this shows that the new The default AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude Code). |
GonZiin
left a comment
There was a problem hiding this comment.
Reviewed 11495d9ef against dde82f27e. The mesh LDS cap, mesh LDS sizing, and compute LDS cap suites passed all 22 CPU tests on Linux (WSL2), Python 3.14.4. A separate hand-written mesh fixture confirmed the address regression below in the generated SPIR-V assembly. AI-assisted review.
| elif self.ms and MESH_COMPUTE: | ||
| room = (MAX_SHARED_BYTES - self.x_buf_bytes() - 4) // 4 | ||
| if self.lds_bound is None and self.lds_need and self.lds_dwords > room >= self.lds_need: | ||
| self.lds_dwords = self.lds_bound = self.lds_need |
There was a problem hiding this comment.
[P1] Preserve LDS addressing when shrinking to a non-power-of-two size. lds_bound only affects callers of lds_access(). ds_read_addtid_b32 and ds_write_addtid_b32, ds_add_*f32, and ds_cmpst_*f32 still call lds_ptr() directly and mask the dword index with lds_dwords - 1. I translated a synthetic ds_read_addtid_b32 mesh shader with 36 KiB declared LDS and a 48 KiB cap. For lane 0 with M0 set to 4108 bytes, the base commit selects dword 1027 (1027 & 0x3fff). The shrunk array emits 1027 & 0x23ff, which selects dword 3. This silently changes an in-bounds access. Please route these paths through bounds-checked addressing, or reject the shrink for programs using them until they are covered.
|
Tested Since the change is on the
Also ran the full suite (build.py + check.py, run_gpu_tests.py, native and with |
|
Tested 11495d9 on RX 5700 XT (RDNA1, gfx1010, RADV NAVI10), Mesa 26.3.1, Linux 6.18: pass
LLVM AI-assisted (Claude Code). |
Route ds_read_addtid_b32, ds_write_addtid_b32, ds_add_*f32, and ds_cmpst_*f32 through lds_load/lds_store/lds_access so shrinking %lds to a non-power-of-two size never masks dword indices with a non-power-of-two (lds_dwords - 1) bitmask. Assert power-of-two lds_dwords in lds_ptr() and add regression tests covering both in-bounds addressing (M0=4108 -> dword 1027 under a 36 KiB / 48 KiB cap) and out-of-bounds semantics with spirv-val.
|
Thanks for the great catch, @GonZiin! Fixed in
Verification (Windows 11, Python 3.13, SPIRV-Tools 2026.4, no game files):
|
|
AMD RDNA2 GPU-suite check of Same per-fixture results as main: 247 translated, 247 pass spirv-val; 222/241 passed, 17 skipped, 2 FAIL ( |
|
Tested
The semantic suite,
A limit of these runs: Compared with No game files. AI-assisted (Claude Code). |
Claimed in the coordination issue as: #8047 (comment)
What and why
Under
--mesh-compute, mesh shaders are emitted asGLComputeshaders whose total Workgroup storage (%lds+ wave64%x_buf+ 4-byte%ms_counts) is constrained by VulkanmaxComputeSharedMemorySize(48 KiB / 49,152 B on NVIDIA Pascal GPUs like the GTX 1070). Previously,fit_shared_memory()returned early unlessself.cswas set, andassemble()never enforcedMAX_SHARED_BYTESon--mesh-computeshaders, letting power-of-two LDS rounding exceed 48 KiB or emitting shaders that fail pipeline creation on 48 KiB devices.tools/rdna2spirv.py:g.lds_need = needon mesh shaders intranslate().Gen.fit_shared_memory()toself.ms and MESH_COMPUTE: when rounded%ldsexceeds(MAX_SHARED_BYTES - self.x_buf_bytes() - 4) // 4butself.lds_needfits, shrinkself.lds_dwordstoself.lds_needand enable bounds checks (self.lds_bound = self.lds_need).MAX_SHARED_BYTESguard inassemble()formsc(%lds + %x_buf + 4 B %ms_counts), raisingUnsupportedwith an explicit byte breakdown when a--mesh-computeshader still exceeds the limit. NativeMeshEXT(not MESH_COMPUTE) is untouched.tests/semantic/test_ms_shared_memory_limit.py:--max-shared-memory 49152) LDS shrinking with bounds checks andspirv-valvalidation, exact-limit pass vs 1-dword-over refusal, over-cap refusal with and without--wave64-emulate, exactmeta["lds_bytes"]reporting, and verifying nativeMeshEXTis unaffected.Tested
Hardware / environment: NVIDIA GeForce GTX 1070 (8 GB Pascal,
0x10de:0x1b81,maxComputeSharedMemorySize = 49152), driver NVIDIA 581.80 (Vulkan 1.4.312), Windows 11, Python 3.12.16, SPIRV-Tools 2026.4 (spirv-as/spirv-val).origin/main(dde82f27e):python -m compileall -q tools/rdna2spirv.py tests/semantic/test_ms_shared_memory_limit.py: exit0python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_ms_shared_memory_limit.py: exit0python -I tests/semantic/test_ms_shared_memory_limit.py -v: 4/4 OK (includingspirv-as+spirv-valvalidation of shrunken--mesh-computeshaders)python -m pytest tests/semantic/test_ms_shared_memory_limit.py tests/semantic/test_ms_lds_need.py tests/semantic/test_cs_shared_memory_limit.py tests/test_mesh_compute.py tests/test_mesh_compute_vs.py -q: 57 passed, 9 subtests passed.asmfixtures intest_ms_shared_memory_limit.pyand existing mesh-compute suites translate and passspirv-valcleanly with 0 regressions (no game shaders used).AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed. (No new RDNA2 ISA rule; extends existing--max-shared-memoryWorkgroup budget enforcement to--mesh-compute.)