upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorundeadhuman37 <343031842+undeadhuman37@users.noreply.github.com>2026-11-22 21:59:29 +0300
committerundeadhuman37 <343031842+undeadhuman37@users.noreply.github.com>2026-11-22 23:17:58 +0300
commit0808dfa96ee4d98f4ea3a3b4e7ec061dfbd558ce (patch)
treef1be84df7049e4826737ff961123c9af70ef3e44 /runtime
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
Tests for SHADER-328: constant SGPR offsets in SMEM loads, CPU and GPU
The 64-bit fold itself landed with #1948. This adds what #1938 still carries: two semantic tests (a constant sOFF of -4 is out of bounds, not a 32-bit wrap; a constant sOFF of 2^20 is not sign-extended) and the GPU fixture cs_smem_sconst_off. Its run-time sOFF is now in range (4): an out-of-range run-time sOFF made llvmpipe do the guarded load and segfault (review on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/test/shaders/check.py2
-rw-r--r--runtime/test/shaders/cs_smem_sconst_off.asm47
2 files changed, 49 insertions, 0 deletions
diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py
index 9771f17b1..e15b36293 100644
--- a/runtime/test/shaders/check.py
+++ b/runtime/test/shaders/check.py
@@ -156,6 +156,8 @@ CS_DUMPS = [*CS_DPP, ("cs_store", CS_STORE), ("cs_smem_soffset_imm", CS_SMEM),
156BOUNDS = [("cs_bounds", [0x12345678, 0x12345678, 0x00000000, 0xEEEEEEEE]), 156BOUNDS = [("cs_bounds", [0x12345678, 0x12345678, 0x00000000, 0xEEEEEEEE]),
157 ("cs_smem_bounds", [0, 0x5eed0010, 0x5eed000c, 0, 0x5eed000c, 0x5eed0010, 0, 0]), 157 ("cs_smem_bounds", [0, 0x5eed0010, 0x5eed000c, 0, 0x5eed000c, 0x5eed0010, 0, 0]),
158 ("cs_smem_stride_align", [0x5eed0010, 0, 0, 0x5eed0000, 0x5eed0000, 0x5eed0000, 0x5eed0000, 0x5eed0004]), 158 ("cs_smem_stride_align", [0x5eed0010, 0, 0, 0x5eed0000, 0x5eed0000, 0x5eed0000, 0x5eed0000, 0x5eed0004]),
159 # SHADER-328: a constant SGPR offset gives what the run-time one gives (no 32-bit wrap)
160 ("cs_smem_sconst_off", [0, 0x5eed0018, 0x5eed0018, 0x5eed0014]),
159 ("cs_smem_sload_neg", [0x5eed0004, 0x5eed0000, 0x5eed0004, 0x5eed0004, 0x5eed0008, 0x5eed000c, 161 ("cs_smem_sload_neg", [0x5eed0004, 0x5eed0000, 0x5eed0004, 0x5eed0004, 0x5eed0008, 0x5eed000c,
160 0xeeeeeeee, 0xeeeeeeee]), 162 0xeeeeeeee, 0xeeeeeeee]),
161 ("cs_buf_tail", [0, 0x5eed000c, 0x5eed0008, 0x5eed000c, 0, 0, 0x5eed0010, 0]), 163 ("cs_buf_tail", [0, 0x5eed000c, 0x5eed0008, 0x5eed000c, 0, 0, 0x5eed0010, 0]),
diff --git a/runtime/test/shaders/cs_smem_sconst_off.asm b/runtime/test/shaders/cs_smem_sconst_off.asm
new file mode 100644
index 000000000..1da78df89
--- /dev/null
+++ b/runtime/test/shaders/cs_smem_sconst_off.asm
@@ -0,0 +1,47 @@
1; SHADER-328: an s_buffer_load SGPR offset the translator can see as a constant gives what the same offset gives at run
2; time. The rule (docs/design.md, Scalar/buffer memory): off = zext(soffset & ~3) + (imm & ~3) in 64 bits, and the
3; dword is 0 when off + 4 > limit. #1686 folded a constant soffset as a 32-bit sum, so 0xfffffffc + 20 wrapped to 16
4; and read data; gfx1036 (tools/hw_oracle, #1686) reads 0.
5; Thread 0 seeds heap bytes 0x40..0x5f (region offset X = byte 0x40 + X) with 0x5eed0000 + X and byte 0x60 with
6; 4, then loads through a V# it builds itself (base 0x40, stride 0, NUM_RECORDS 0x40, word3 0x31016fac):
7; s_buffer_load_dword s24, s8=-4 offset:20 (constant) -> 0xfffffffc + 0x14 > 0x40: 0 (32-bit wrap: 0x5eed0010)
8; s_buffer_load_dword s25, s9=4 offset:20 (from heap 0x60) -> run time, in range: 0x5eed0018, as s26
9; s_buffer_load_dword s26, s10=4 offset:20 (constant) -> 0x18: 0x5eed0018
10; s_buffer_load_dword s27, s11=0x10 offset:4 (constant) -> 0x14: 0x5eed0014
11; and writes s24..s27 to out[0..3]. The run-time load stays in range: an out-of-range run-time sOFF (-4) made llvmpipe
12; (Mesa 26.0.8) do the guarded load anyway and segfault (#1938 review); the CPU tests cover that path.
13; Run: vk_compute_test cs_smem_sconst_off.spv 1 dump -> out[0..3] = 0x00000000 0x5eed0018 0x5eed0018 0x5eed0014.
14v_cmpx_eq_u32_e32 0, v0
15v_mov_b32 v1, 0x5eed0000
16v_mov_b32 v2, 0x5eed0004
17v_mov_b32 v3, 0x5eed0008
18v_mov_b32 v4, 0x5eed000c
19buffer_store_dwordx4 v[1:4], off, s[0:3], 0 offset:64
20v_mov_b32 v1, 0x5eed0010
21v_mov_b32 v2, 0x5eed0014
22v_mov_b32 v3, 0x5eed0018
23v_mov_b32 v4, 0x5eed001c
24buffer_store_dwordx4 v[1:4], off, s[0:3], 0 offset:80
25v_mov_b32 v5, 4
26buffer_store_dword v5, off, s[0:3], 0 offset:96
27s_waitcnt vmcnt(0)
28s_mov_b32 s4, 0x40
29s_mov_b32 s5, 0
30s_mov_b32 s6, 0x40
31s_mov_b32 s7, 0x31016fac
32s_mov_b32 s8, -4
33s_buffer_load_dword s9, s[0:3], 0x60
34s_mov_b32 s10, 4
35s_mov_b32 s11, 0x10
36s_waitcnt lgkmcnt(0)
37s_buffer_load_dword s24, s[4:7], s8 offset:0x14
38s_buffer_load_dword s25, s[4:7], s9 offset:0x14
39s_buffer_load_dword s26, s[4:7], s10 offset:0x14
40s_buffer_load_dword s27, s[4:7], s11 offset:0x4
41s_waitcnt lgkmcnt(0)
42v_mov_b32 v1, s24
43v_mov_b32 v2, s25
44v_mov_b32 v3, s26
45v_mov_b32 v4, s27
46buffer_store_dwordx4 v[1:4], off, s[0:3], 0
47s_endpgm