rdna2spirv: 64-bit buffer addresses without Int64, so shaders run without shaderInt64 (SHADER-423) #850
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/850"
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 c4k3ss on 2026-11-24T14:33:19Z.
Claimed in the coordination issue as: SHADER-423 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134292009), carried over from the upstream repository, where it was open with ten independent GPU test reports when the repository went private.
What and why
Translated shaders declared
OpCapability Int64only because of buffer addresses: the translator builds each PhysicalStorageBuffer address as a 64-bit integer (zero-extend, shift by 32, OR, add an offset, convert to pointer). A device withoutshaderInt64(Intel) refuses every such module, although the shader's own arithmetic is 32-bit.lower_addr64(tools/rdna2spirv.py, run inassemble()on the finished module text) rewrites that address arithmetic into pairs of 32-bit words: adds and subtracts throughOpIAddCarry/OpISubBorrow, the shift-by-32 / OR / AND / narrowing / sign-extension / 64-bit bitcast forms the address idiom uses, pair compares, andOpConvertUToPtrof a 64-bit value asOpBitcastof a two-componentuintvector to the pointer. A value is either lowered completely or left alone; when nothing 64-bit remains, theInt64capability is dropped. Shaders that use 64-bit integers as data keep it.--int64-addresseskeeps the previous form.Also in this PR:
tests/semantic/test_addr64_lowering.py(7 tests, including negative offsets throughglobal_load), the two test interpreters learn the pair pointer form, six existing tests accept either address form, and thedocs/design.mdcontract row "64-bit addresses withoutInt64".Tested
On
maind0da7dade, Windows 11 26200, llvm-mc 23.1.6, Vulkan SDK 1.4.363, MSVC 14.44:test_addr64_lowering7,test_buffer_atomic_fminmax_and_align10,test_buffer_store_format39,test_loop_ballot_barrier15,test_wave64_emulate_opt31, all OK.pytest tests/test_translate.py tests/test_rdna2spirv_xdxr_rules.py: 675 passed.scripts/run_gpu_tests.py, test programs built from this head: 258 of 258 shaders translate and passspirv-val; 198/249 passed, 49 skipped, 2 failed. The two failures,cs_imgload_tfeandcs_imgload_d16_tfe, fail identically with thismain's own translator on the same programs (--filter cs_imgload: 2/4 both ways, same texel values), so they are not from this change.mainwithout conflicts) was run by ten independent testers with no regression against theirmain: NVIDIA RTX 2060, 4080, 5080, 5090; AMD RX 5700 XT (RDNA1), RX 6800 and a Steam Deck (RDNA2), RX 9070 XT (RDNA4), gfx1036 iGPUs on the Windows driver; Windows, Linux/RADV.GPUs tested: NVIDIA RTX 5070 Ti, driver 621.24, Windows 11
AI-assisted: yes (Claude Code); built and tested on the machine above.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:44:37Z.
Review: APPROVED
Audited and verified. Implements lowering of 64-bit buffer device address arithmetic into 32-bit uint pairs (OpIAddCarry, OpISubBorrow, etc.) and vector pointer bitcasting, dropping the Int64 / shaderInt64 Vulkan capability requirement for devices lacking 64-bit integer support. Preserves 64-bit path under --int64-addresses. Comprehensive semantic test suite in ests/semantic/test_addr_no_int64.py and contract docs updated in docs/design.md. Approved.
Imported from ubiquitarianism/leonida. Originally posted by Sangonapou on 2026-11-24T18:26:43Z.
Tested
4f2628f8on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, regression checkRuntime built at this head with
scripts\build_runtime.ps1(MSVC 19.51);llvm-mc23.1.6, SPIRV-Tools 2026.4. No game files.tests/semantic/test_addr64_lowering.py7 OK.LEONIDA_W64_EMULATE=1230/249 passed, 17 skipped. The only failures arecs_imgload_tfe/cs_imgload_d16_tfe, which fail the same way onmainon this card (#892).This GPU has
shaderInt64, so it shows the 32-bit-pair addresses compute the same results as before on NVIDIA; the case the PR is for (a device withoutshaderInt64) needs an Intel or similar run.Imported from ubiquitarianism/leonida. Originally posted by titoreinaldo on 2026-11-24T20:34:43Z.
Intel Arc readback at
4f2628f83f390e0d25b30bf15718dbbd02852517. On Windows 11 Pro 26H2 build 26300.9974, driver 32.0.101.8132, the exact-headvk_compute_testprintedIntel(R) Arc(TM) Graphics (subgroup 8..32)on all 12 dispatches. Selected withVK_LOADER_DRIVERS_SELECT=*igvk*andLEONIDA_VK_DEVICE=Intel(R) Arc(TM) Graphics. Built Release with LLVM-MinGW 23.1.6.--int64-addressesreferenceglobal_load_dword, offsets −252, −4, +12, +276 bytess_load_dwords_lshl_b64used to compute the address12/12 passed, 0 failed, 0 skipped. Each dispatch compared all 256 readback words with the CPU expectation, including 224 untouched words. All 12 binaries also passed
spirv-val --target-env vulkan1.2. For the −4 case, intentionally expecting offset 0 produced differences in all 32 result lanes. The existing seventest_addr64_lowering.pytests passed as well. This Intel driver supports shaderInt64. The five default address-only modules ran with that device feature disabled by the harness.Reproduce the signed-offset case
Use the PR’s
tests/semantic/test_addr64_lowering.py::translate(name, body_lines, lowered=True)helper. Repeat withlowered=Falsefor the legacy module. For each of the four offsets substitute the signed decimal value below. The helper supplies the 32×1×1 workgroup and finals_endpgm.Initialize 256 little-endian uint32s with
w[i] = (0x6b120000 + i * 0x10203) & 0xffffffff. Assemble and validate the generated text, then dispatch once:Read
out.bin. Lanetmust containw[128 + offset/4 + t]and words 32–255 must match the input. For the scalar case all 32 lanes read byte address 256. The 64-bit-data control computes 256 as16 << 4in an SGPR pair before that scalar load.AI-assisted with OpenAI Codex. All buffers and shaders were synthetic.
Imported from ubiquitarianism/leonida. Originally posted by c4k3ss on 2026-11-25T17:39:52Z.
Rebased by merging
mainfe1553456(775 commits since the base); the only conflict was thedocs/design.mdtable row.Main's
Gen.host_addrnow sign-extends every 48-bit effective VA (a shift left and an arithmetic shift right by 16, with a 32-bit shift amount).lower_addr64knew only shifts by 32, so after the merge it refused every module and the lowering did nothing (all 7 semantic tests failed). Commitda9e7492bmakes a shift by 1..31 of a (low, high) pair the two words' shifts with the bits that cross between them, with the amount read as a 32-bit or 64-bit constant; shifts by a variable amount or by more than 32 still keepInt64. The contract row and the code comment say so.test_addr64_lowering.pygains a negative 48-bit VA case (bit 47 set, so the read lands below the heap base), compared with theInt64form inspirv_mini_interp.Tested on
mainfe1553456, Windows 11 26200, RTX 5070 Ti (NVIDIA 621.24), llvm-mc 23.1.6, Vulkan SDK 1.4.363:test_addr64_lowering8 OK;test_rdna2spirv_xdxr_rules6,test_buffer_atomic_fminmax_and_align11,test_buffer_store_format39,test_loop_ballot_barrier15,test_wave64_emulate_opt33, all passed.scripts/run_gpu_tests.pywith the lowering: 209/264 passed, 54 skipped, 1 failed (cs_imgatomic_ext: 6 of 64 sint words differ, word 32 = 0x0badf00d), runtime and test tools built from thismainwithscripts/build_runtime.ps1(MSVC). With thismain's own translator on the same build and programs: 209/264, 54 skipped, the samecs_imgatomic_extfailure with the same words. Same failures both ways, so none are from this change.Int64with the lowering; 98 did without it before (the rest are 64-bit data ops:cs_w32_salu64,cs_w32_shift64,ps_vcmp_64, the typed-format tests).AI-assisted (Claude Code); a second tool reviewed the shift formulas for every amount 1..32 against integer arithmetic and validated 192 lowered synthetic modules with spirv-val.
Imported from ubiquitarianism/leonida. Originally posted by c4k3ss on 2026-11-26T11:58:21Z.
Merged
maina73a57e13(440 commits since the last merge; the conflict was the samedocs/design.mdrow).Main's
RT-POST-LOAD-GPU-MEMORY(9f98dcc61) put three more 64-bit forms into the buffer address idiom: the fullindex * strideproduct (OpIMul %ulong, so an index that lands past 32 bits is out of range), a left shift by the element-size log read from the V# (a 32-bit value, not a constant), and the range compare against0xFFFFFFFF. The pass refused every such module and the lowering did nothing again. Commitc621105e6: a 64-bit multiply becomes the low words' product with its high word from the four 16-bit half products (plain 32-bit multiplies, which the three test interpreters run; noOpUMulExtended), plus each low word times the other's high word; a left shift by a 32-bit value becomes the shift byk & 31on both words with the crossing bits, the words moved up oncek >= 32. A right shift by a variable amount still keepsInt64. The contract row and the code comment say so.Tested on
maina73a57e13, Windows 11 26200, RTX 5070 Ti (NVIDIA 621.24), llvm-mc 23.1.6, Vulkan SDK 1.4.363:test_addr64_lowering8 OK;test_rdna2spirv_xdxr_rules6,test_buffer_atomic_fminmax_and_align11,test_buffer_store_format39,test_loop_ballot_barrier15,test_wave64_emulate_opt33, all passed.scripts/run_gpu_tests.pywith the lowering, runtime and test tools built from thismainwithscripts/build_runtime.ps1(MSVC): 211/268 passed, 55 skipped, 2 failed (cs_imgatomic_ext: 6 of 64 sint words differ;cs_texture_uav: "texture view format lacks the required formatless storage image access: 98"). With thismain's own translator on the same build and programs: 211/268, 55 skipped, the same two failures with the same words. So neither is from this change.Int64with the lowering.AI-assisted (Claude Code); a second tool checked the multiply and shift lowering against integer arithmetic (20,121 products, 13,504 shifts).
Imported from ubiquitarianism/leonida. Originally posted by c4k3ss on 2026-11-28T12:52:30Z.
Merged
main493867366and again4ecb05749(about 1,700 commits since the last merge; one conflict, thegloballine inrdna2spirv.py, both sides kept).Five newer
maintests looked for the 64-bit forms thatlower_addr64rewrites into (low, high) pairs, or for the module's first constant 16 or 31, which the lowering now declares as its own. Each accepts both forms now, with the counts and negative controls unchanged:test_mesh_compute(the store pointers areOpBitcastof the pair; the slot offset'sOpIMul %ulongis the pair's low product),test_salu_chained_const_prop(the fold check skips the lowering's own shifts by 16),test_lds_subword_d16andtest_wave32_lane_select(whichever constant 16 or 31 the instruction uses),test_vsharp_sext48(the pair form's arithmetic shift right by 16 on the high word, twice).Tested on
main4ecb05749, Windows 11 26200, llvm-mc 23.1.6: the top-level pytest files 10,055 passed, 390 skipped, and everytests/semanticfile passes. The ninetest_windows_boot_journal_seedfailures on this machine come fromscripts/windows-boot/boot.ps1being removed by the antivirus here; they fail the same way onmain. The earlier CI red on2f26ba981was these five tests.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T13:23:04Z.
Review: APPROVED
Independently verified
d477c94cdmerged cleanly ontomain(d48a957bb) on Windows 11 across two Vulkan GPUs (zero game files):32.0.16.1664, wave64 emulated)gfx1036) (driver32.0.21030.2001, native wave64)Red on
main(d48a957bb) control:tests/semantic/test_addr64_lowering.pyfails (8tests /13errors:AttributeError: module 'rdna2spirv' has no attribute 'ADDR_PAIR').Green on
#850(d477c94cd):scripts/run_semantic_tests.py tests/semantic -p test_addr64_lowering.py: 8/8 passed.tests/semantic, 519 files, 6,479 tests): 518/519 files (6,477/6,479 tests) passed; the sole failing file (test_valu_cvt_f16_int16_mods, 2 subtests inv_cvt_u16_f16/v_cvt_i16_f16) reproduces identically on cleanmain(d48a957bb) — 0 regressions from#850.pytest tests/test_mesh_compute.py tests/test_rdna2spirv_xdxr_rules.py tests/test_translate.py: 757/757 passed.scripts/run_gpu_tests.py --filter cs_buf --require-pass: 4/6 passed, 2 skipped (cs_buf_fmt8,cs_buf_load_sub,cs_buf_swizzle,cs_buf_tailpass;cs_buf_counterandcs_buf_typedskipped asd3d12_buffer_uav_test-only) on both RTX 5080 and AMD Radeongfx1036.tools/valu_fuzz.py --family mem --wave both --programs 100 --seed 850:--emulate): 200/200 match (0mismatched,0skipped,0not translated,0harness errors).gfx1036(native): 200/200 match (0mismatched,0skipped,0not translated,0harness errors).LGTM.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:07:49Z.
Independent verification on Windows 11 (
10.0.26200, x64) ofd477c94cd5merged onto currentorigin/main(aa52446f7d/21f5baff1d,0merge conflicts), tested under bothPython 3.12.10andPython 3.14.5:origin/main+#850tests/semantic/test_addr64_lowering.py&spirv_mini_interp.py):python -I tests/semantic/test_addr64_lowering.py:FAILED (errors=13)(AttributeError: module 'rdna2spirv' has no attribute 'ADDR_PAIR').d477c94cd5merged ontoorigin/main):python -I tests/semantic/test_addr64_lowering.py:Ran 8 tests,OKon bothPython 3.12.10(0.78 s) andPython 3.14.5(0.74 s).test_buffer_atomic_fminmax_and_align.py(11/11),test_buffer_store_format.py(39/39),test_lds_subword_d16.py(8/8),test_loop_ballot_barrier.py(15/15),test_salu_chained_const_prop.py(11/11),test_wave64_emulate_opt.py(34/34),test_rdna2spirv_xdxr_rules.py(6/6),pytest tests/semantic/test_vsharp_sext48.py tests/semantic/test_wave32_lane_select.py(3/3), andpytest tests/test_mesh_compute.py tests/test_translate.py(5 passed, 752 skipped,0failures).python -I tests/test_docs_design_rows.py:Ran 5 tests,OK;test_docs_cli_flags.pyadds0issues overorigin/main(--int64-addressesmatchestools/rdna2spirv.py).lower_addr64's 16-bit half-product 64-bitOpIMuland variable 32-bitOpShiftLeftLogical(k & 31,31 - (k & 31),k >= 32) formulas across3,033boundary operand combinations (0,1,0xFFFF,0x10000,0x7FFFFFFF,0x80000000,0xFFFFFFFE,0xFFFFFFFF, and allk in 0..63):0mismatches and no intermediate 32-bit carry overflow.git diff --checkandpython -I scripts/check_no_game_data.pyacross all 16 touched files exited0.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:40:34Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
53b77df14: red FAIL (test_addr64_lowering,ADDR_PAIRmissing) / green PASSd477c94cd53b77df14+ only this PR's test files; green = main +git merge --no-ffof the PR (clean merge).test_addr64_lowering.py: red 8 tests with 13 subtest errorsAttributeError: module 'rdna2spirv' has no attribute 'ADDR_PAIR'; green 8 OK. MEASURED 3 runs alone: red 3/3 fail, green 3/3 pass.python -I scripts/run_semantic_tests.py tests/semantic: red 527 files / 6514 tests, 2 files failed (test_addr64_lowering,test_valu_cvt_f16_int16_mods); green 527 / 6514, 1 file failed (test_valu_cvt_f16_int16_mods). Green-only failures: none.test_valu_cvt_f16_int16_mods(test_f16_to_int16_output_modifiers_still_rejectedfor v_cvt_u16_f16 and v_cvt_i16_f16: "Unsupported not raised") also fails on plain main53b77df14and is not touched by this PR (pre-existing on main, last changed in7de2d4461).tests/test_rdna2spirv_xdxr_rules.py: 6 passed on both sides.pytest tests/test_translate.py tests/test_mesh_compute.py: no failures, no skips on either side.test_translate.py: red 729 passed / green 729 passed.test_mesh_compute.py: red 22 passed / green 28 passed. The count differs because red's copy of this file is the PR head's, which predates main's476f014a2(pc-tail tests); the merged file (main + PR diff) run against red's source also gives 28 passed. Its newOpBitcast %_ptr_PSB_uint %a64_/ pair-form%msoassertions are disjunctions, so they hold on main's codegen too.AI-assisted: Claude Code (Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T02:10:26Z.
Merged after OreoFR's red/green check (check) (macOS 27.2.1, Apple M5, Python 3.12) and a local re-check here. Merged after local re-verification: this PR merged onto
main791899f65without conflict, and its test file(s) (tests/semantic/test_addr64_lowering.py,tests/semantic/test_buffer_atomic_fminmax_and_align.py,tests/semantic/test_buffer_store_format.py,tests/semantic/test_lds_subword_d16.py,tests/semantic/test_loop_ballot_barrier.py,tests/semantic/test_salu_chained_const_prop.py,tests/semantic/test_vsharp_sext48.py,tests/semantic/test_wave32_lane_select.py,tests/semantic/test_wave64_emulate_opt.py,tests/test_mesh_compute.py,tests/test_rdna2spirv_xdxr_rules.py,tests/test_translate.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.