shader: lower bounded 64-bit LDS exchange across group barrier in gfx2hlsl #2337
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2345"
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 R0Y00/Xbox2Windows. Originally posted by Vladimir-Human on 2026-11-25T13:05:22Z.
Refs #2274, #1541.
Summary
Extend
check_lds_exchangeandStage.lowerintools/startup/gfx2hlsl.py(building on #2327) to support bounded 64-bit group-shared LDS exchanges (ds_write_b64andds_read_b64) acrosss_barrierin 1D compute groups:ds_write_b64 addr, v[d0:d1] [offset:k](RDNA 2 DS opcode0x4d): requires straight-line full entryEXEC, unchangedv0, a single VGPR address fromv_lshlrev_b32 addr, 3, v0, a contiguous 2-VGPR data pairv[d0:d1]inv0..v255, 4-byte alignedoffset, andoffset + group[0] * 8 <= lds_words * 4(COMPUTE_PGM_RSRC2.GRANULATED_LDS_SIZEin 128-dword / 512-byte units per LLVM 15AMDGPUUsage).ds_read_b64 v[r0:r1], addr [offset:k](RDNA 2 DS opcode0x76): requires matching 64-bit fill width (mixedb32/b64exchanges stay refused), completeds_waitcnt lgkmcnt(0)befores_barrierand after each read, an exactv[r0:r1]pair, and a literal (v_mov_b32) or literal-masked (v_and_b32) byte address proving[a + offset, a + offset + 8)stays 4-byte aligned inside[first, first + group[0] * 8).a = (address + offset) >> 2before updating destination registers so overlapping destinations such asds_read_b64 v[8:9], v8 offset:16preserve the address while reading little-endianlds[a]/lds[a + 1u].tests/startup_compute_lds_b64_check.py(offline bounds/width/pair/mask/alignment/refusal checks, HLSL parity,llvm-mcbinary verification target, CasePpeer swap across wave halves +v[8:9], v8aliasing, CaseBtight 512-byteLDS_SIZE=1allocation + lane-37 broadcastoffset:296, and five mutated negative controls) wired intoCMakeLists.txt,.github/workflows/windows.yml, anddocs/experiments.md.Verification
Microsoft Basic Render Driver(vendor=1414 device=008c, driver10.0.26100.9818, Windows 1110.0.26300build26300,debug_layer=enabled): CasesP(groups=2x1x1) andB(groups=1x1x1) matched320/320words (mismatches=0,debug_errors=0 debug_warnings=0); controls rejected cleanly (p-same-lane:word=0256 mismatches;p-swap-dwords:word=0256 mismatches;p-drop-high:word=1128 mismatches;b-wrong-mask:word=064 mismatches;b-wrong-lane:word=2128 mismatches).NVIDIA GeForce RTX 4070 SUPER(vendor=10de device=2783, driver32.0.16.2114, Windows 1110.0.26300build26300,debug_layer=enabled): CasesPandBmatched320/320words (mismatches=0,debug_errors=0 debug_warnings=0); all 5 controls rejected cleanly with matching mismatch counts and zero debug errors/warnings.cmake --preset release; cmake --build --preset release --target offscreen_checkctest --preset release --no-tests=error -j 1 -R "^startup_(compute_lds_b64|gfx2hlsl_compute)" -V-> 30/30 passed (0 failed, 0 skipped)startup_*regression subset -> 84/84 passed (0 failed, 0 skipped)tests/startup_compute_lds_b64_check.py,tests/startup_gfx2hlsl_*_check.py,tests/startup_translator_check.py,tests/startup_tools_lint_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py(all 0 failed),tests/rdna2_tools_check.py(156 ran, 19 skipped, 0 failed)tests/startup_compute_lds_b64_check.py binary llvm-mc-15(llvm-mc-15is not installed on Windows; covered in.github/workflows/windows.ymlLinux check and cross-checked locally withtools/disasm_rdna2.py).AI-assisted implementation and verification.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:11:42Z.
Review: COMMENTED
Review of head
8dd26f26df807bd4744a9d7c1c58580c98f2a7cb(comment only, no approval).Scope read:
tools/startup/gfx2hlsl.py(check_lds_exchange,Stage.lowerb64 path),tests/startup_compute_lds_b64_check.py, CTest and workflow wiring.Commands executed locally (worktree at the head SHA):
git diff --stat origin/main...HEAD: 5 files, +452/-14python3 tests/startup_compute_lds_b64_check.py: pass ("sizing, pair validation, aligned masks, bounds and refusals pass")python3 tests/docs_links_check.py: pass (19 files, 454 links)python3 tests/bidi_controls_check.py: pass (1628 files)git diff --check origin/main...HEAD: cleangh pr checks: Linux checks, gfx1013 fixtures, and Windows build/test all pass. The /O2 job was skipped.Mutations of the new logic (each reverted with
git checkout -- .):3changed to2: refused with "needs one bounded qword per local X ID". Killed.(width - 4)term removed: the test fails with "accepted, expected a refusal naming 'initialized span'". Killed.lds[a + 1u]changed tolds[a]: the exact-HLSL assertion fails. Killed.Findings:
Stage.lowernow raisesUnsupported('LDS exchange needs pipeline metadata')whenpipeis None. That is a sound guard, but no test covers it. A one-line refusal test would pin it.offset % 4 == 0. That is correct for LDS dword access and the span bound covers it. A short comment saying "8-byte alignment is not required" would help future readers.high + offset + 4 < first + group*8, the 4-byte-aligned mask and literal checks, the mixed b32/b64 refusal, and evaluatingabefore the destination write (no aliasing with the address VGPR) all look correct against the RDNA 2 DS description.Windows proof: I did not run
x2w_pipe.py win2025. The PR's CI Windows job passed and the new CTest WARP and hardware dispatch and control tests are wired. The Win2025 WARP gate is left to the normal Stage-2 step.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:34:19Z.
@Vladimir-Human could you rebase this branch onto current
mainand force-push?GitHub reports head
8dd26f26as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(43608f2e):tools/startup/gfx2hlsl.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T13:40:04Z.
Since #2347 landed, GitHub reports a conflict in the shared LDS validator. I tried the combination against main at
ec519d0cand this PR at8dd26f26. A tested merge commit is available if it helps resolve the conflict.The combined validator checks the two independent
ds_read2_b32offsets against the dword fill, and checks both ends of the contiguousds_read_b64against the qword fill. Both host suites passed. On WARP and RTX 4060, both dispatch suites passed, including the omitted paired offset cases, and both paired-read plus all five b64 mutation controls failed readback as expected. Example first mismatches on the RTX: address overlap at word 1 (00000000/00000004), wrong b64 mask at word 0 (00000020/00000000) and wrong lane at word 2 (00000025/00000024). Windows 11 build 26100.9711, NVIDIA 32.0.15.9579, local debug layer unavailable.Imported from R0Y00/Xbox2Windows. Originally posted by Vladimir-Human on 2026-11-25T14:02:09Z.
Rebased onto \main\ (\489f934, commit \b6bfbc9) to resolve the conflict with #2347\ (\ds_read2_b32), keeping mixed \32/\64/\ds_read2_b32-over-\64\ exchanges refused, and addressed both nits from @tedin7\ (added a refusal test for \pipe is None\ and a comment explaining why 4-byte alignment suffices for \64\ dword-addressed LDS writes). Re-verified \34/34\ \startup_(compute_lds_b64|gfx2hlsl_compute)\ CTests on WARP and RTX 4070 SUPER plus \9/9\ pure-Python checks; thanks @tedin7\ and @RavenCurseBurg!
AI-assisted.