rdna2spirv: route ds_add_f32, ds_cmpst_f32, and ds_*_addtid_b32 through lds_access bounds check #521
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/521"
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 ubiquitarianism/leonida. Originally posted by tahffo68hk-hash on 2026-11-24T06:52:31Z.
Summary
(AI-assisted) Fixes SHADER-LDS-BOUND-ACCESS: in ools/rdna2spirv.py, three LDS handlers still called self.lds_ptr() directly instead of routing through self.lds_load() / self.lds_store() / self.lds_access():
When self.lds_bound is active (SHADER-309: a compute shader's LDS array is sized to its RSRC2 LDS_SIZE allocation rather than a power-of-two wrapped buffer):
Imported from ubiquitarianism/leonida. Originally posted by thesubtleties on 2026-11-24T20:30:50Z.
CPU check of
205540176merged onto main3aa97542.The new tests check structure only, so I ran six value cases in
spirv_mini_interpwith a 384-dword bound:ds_add_rtn_f32,ds_cmpst_rtn_f32and the addtid pair, each at byte 512 and at 1536 (out of range). All six are right here and passspirv-val; with main's translator four are wrong (byte 512 wraps to 0). Worth adding as tests.lds_accessfinds its exit label dynamically, so passing it a CAS loop is fine.run_semantic_tests.py tests/semantic: 471 files / 6,172 tests, 0 failed.Not tested: wave64 emulation values, GPU, game corpus. AI-assisted (Claude Code)
Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-24T21:52:39Z.
Reviewed
20554017: the translator change intools/rdna2spirv.pyis solid — nolds_ptrcallers remain outsidelds_access, the 3 bounded-LDS tests intests/semantic/test_lds_bound_access.pypass here and fail onorigin/main(missingOpULessThan %bool, still masking with%c17f), all 28 othertest_lds*.pyfiles plustest_cs_shared_memory_limit.py(29 files) pass on both trees, nativespirv_mini_interpprobes (384-dword boundrsrc2=0x18088, unbounded0x40008,LDS_SIZE=0) confirm the OOB-drop/in-bounds fixes fords_add[_rtn]_f32,ds_cmpst[_rtn]_f32, andds_*_addtid_b32, realwave64-emulate(wave64=True, emulate=True) validates withspirv-as/spirv-val(includingx_roundand shrunkLDS_SIZE=100), andrun_compute_workgroupexecutes emulatedds_*_addtid_b32cleanly. One test bug to fix first:test_wave64_emulate_structure_validnever actually enables wave64 emulation (wave64=False, emulate=False, output identical tow64_emulate=False) because_make_cs_fssmomits theFSSMmagic and the assembly lacks a wave64 marker, and it doesn't assertlast_gen.emulateor the bounds check (so it also passes onmain). Addings_mov_b64 exec, -1, assertingrdna2spirv.translate.last_gen.emulate, and checking the bounds assertions makes it genuinely cover wave64 emulation (verified passing_check_cfgandspirv-valhere and failing onmain). Pre-existing side finding onmain(not this PR):rsrc2withTIDIG_COMP_CNT=3(e.g.0x1F888) emitsOpCompositeExtract %uint %lci 3on%v3uint, rejected byspirv-val. AI-assisted review.Recommendation: Fix first
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:56:53Z.
Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main
3ca0707: no new failure, Linux / Python 3.13.AI-assisted (Claude Code, Claude Opus 5.5)