upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/main.cpp
diff options
context:
space:
mode:
authorshelbykb2 <80599220+shelbykb2@users.noreply.github.com>2026-11-21 16:21:10 -0700
committershelbykb2 <80599220+shelbykb2@users.noreply.github.com>2026-11-21 16:43:16 -0700
commitb15eaa3ac075d089cd02a6f44daf78240c16c18d (patch)
treeafddc5de285c0571c8f3915facc703fcf0d1c911 /runtime/src/main.cpp
parentd937b7f092dbc188b59754e5c73c1a9dac553cf9 (diff)
rdna2spirv: global_load/store negative offsets were 4096 bytes too low
global_mem read the instruction offset with int(..., 0) and then did "if inst & 0x800: inst -= 0x1000". llvm-mc prints the 12-bit field signed (offset:-4 for 0xffc, range -2048..2047; it rejects offset:0xffc and disassembles 0xffc back as offset:-4), so -4 & 0x800 was true and every negative offset became base - 4096 + offset. Both repo paths (shader_disasm --disassemble, build.py -show-encoding) deliver only the signed spelling. The offset is now taken as written; a raw unsigned field (0x800..0xfff), which llvm-mc never prints, still means the same negative offset, and anything outside 12 bits raises Unsupported instead of being guessed. Hardware (AMD Radeon RX 6800, gfx1030, raw compute kernel, wave32 = wave64): dword at byte n = 0x10000000+n, pointer 0x1000: offset 0 reads 0x10001000, -4 0x10000ffc, -2048 0x10000800, 2044 0x100017fc, -1024 0x10000c00. Audit of the other offset / signed-immediate sites in rdna2spirv.py (widths checked by assembling and disassembling with llvm-mc 21): MUBUF offset: (12-bit unsigned; llvm-mc assembles a hand-written offset:4096 to field 0 while echoing offset:4096, reachable only from hand-written sources, left alone), DS offset: (16-bit unsigned), offset0/offset1 (8-bit unsigned), ds_bpermute offset (16-bit unsigned), s_movk/s_addk/s_mulk and s_cmpk_*_i32 (16-bit, masked then sign-extended, so 0xfffc and -4 agree), s_cmpk_*_u32 (zero-extended), branch targets (16-bit signed, disassembled unsigned as 65532, masked then sign-extended): all right. Not changed here: scalar_load zero-extends a negative SMEM immediate (21-bit signed; -0x4 adds 0xfffffffc), which another branch is changing. Tests: tests/semantic/test_global_mem_offset.py runs the emitted address code (both addressing modes, dword/x2/x4, ubyte/sbyte/ushort/sshort, stores, offsets -4, -2048, 2047 and 0, raw-field and out-of-range spellings): the negative-offset cases fail on main's translator (0 and 2047 pass there too), all pass here. New GPU test runtime/test/shaders/cs_global_neg_offset.asm (wired into check.py and scripts/run_gpu_tests.py), expected words derived from its seeds. On AMD Radeon RX 6800 / Windows / driver 26.11.2: run_gpu_tests 57/57, check.py 51 of 51; with main's translator the new test returns the 4096-lower seeds and fails. AI-assisted. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
0 files changed, 0 insertions, 0 deletions