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:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:10:04 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:10:04 -0500
commit66ff7cb82adeca3232dc181dbc188feb2c2706ea (patch)
tree4cb29596a35fb1ae530e5adf50bc70c93bdbbb3a /runtime
parentdead2b33df2a60d03ff84b3192003786fa1eeb94 (diff)
parent3eb80d77e384a8c51bb58076dc881d7d291f8001 (diff)
Merge pull request #2039 from Vonsek
Diffstat (limited to 'runtime')
-rw-r--r--runtime/test/shaders/check.py14
-rw-r--r--runtime/test/shaders/cs_fmt_d16_xyz.asm98
2 files changed, 112 insertions, 0 deletions
diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py
index 5b9966216..b506c9b40 100644
--- a/runtime/test/shaders/check.py
+++ b/runtime/test/shaders/check.py
@@ -237,6 +237,14 @@ TBUFFER_STORE_WORDS = [
237 0xFF0080FF, 0xA5A50284, 0xA5A50288, 0xA5A5028C, 0xA5A50290, 0xA5A50294, 0xA5A50298, 0xA5A5029C, 237 0xFF0080FF, 0xA5A50284, 0xA5A50288, 0xA5A5028C, 0xA5A50290, 0xA5A50294, 0xA5A50298, 0xA5A5029C,
238 0xA5A502FF, 0xA5A502A4, 0xA5A502A8, 0xA5A502AC, 0x3F800000, 0xA5A502B4, 0xA5A502B8, 0xA5A502BC, 238 0xA5A502FF, 0xA5A502A4, 0xA5A502A8, 0xA5A502AC, 0x3F800000, 0xA5A502B4, 0xA5A502B8, 0xA5A502BC,
239 0xA5A502C0, 0xA5A502C4, 0xA5A502C8, 0xA5A502CC] 239 0xA5A502C0, 0xA5A502C4, 0xA5A502C8, 0xA5A502CC]
240# cs_fmt_d16_xyz.asm: d16_xyz / d16_xy typed-buffer loads (out[0..10]), the two d16_xyz stores (out[16..18] and
241# out[20..22]) and the inputs at 0x100 (out[64..72]); everything else is the untouched fill. Derivation in the header.
242FMT_D16_XYZ_WORDS = [
243 0xABCD1234, 0xA5A57FFF, 0xFFFF0005, 0x1234FFFF, 0xC0003C00, 0xC0003C00, 0xBEEF3555, 0x00003C00,
244 0xCAFE3C00, 0xFFFF0005, 0x0BADFFFF, *[0xEEEEEEEE] * 5,
245 0x00000007, 0x00008001, 0x0000FFFE, 0xEEEEEEEE, 0x3F800000, 0xC0000000, 0x3F000000, 0xEEEEEEEE,
246 *[0xEEEEEEEE] * 40,
247 0xABCD1234, 0x55557FFF, 0xC0003C00, 0x7BFF3555, 5, 0x10000, 0xFFFFFFFF, 0, 0x80FF00FF, *[0xEEEEEEEE] * 7]
240# Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups make a 0x2800-byte heap that holds 248# Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups make a 0x2800-byte heap that holds
241# both the right addresses and the 4096-lower ones; only group 0 thread 0 runs, so no wave64 requirement. 249# both the right addresses and the 4096-lower ones; only group 0 thread 0 runs, so no wave64 requirement.
242GLOBAL_OFFSET = [("cs_global_neg_offset", "40", [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4, 250GLOBAL_OFFSET = [("cs_global_neg_offset", "40", [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4,
@@ -558,6 +566,11 @@ def tbuffer_store_test(tools, spirv, env=None):
558 return dump_test(tools, spirv, "cs_tbuffer_store", TBUFFER_STORE_WORDS + [0xEEEEEEEE] * 76, 192, env) 566 return dump_test(tools, spirv, "cs_tbuffer_store", TBUFFER_STORE_WORDS + [0xEEEEEEEE] * 76, 192, env)
559 567
560 568
569def fmt_d16_xyz_test(tools, spirv, env=None):
570 """The d16_xyz/d16_xy loads and d16_xyz stores of cs_fmt_d16_xyz.asm: the whole 80-word heap."""
571 return dump_test(tools, spirv, "cs_fmt_d16_xyz", FMT_D16_XYZ_WORDS, len(FMT_D16_XYZ_WORDS), env)
572
573
561class Skip(str): 574class Skip(str):
562 """A result that is neither a pass nor a failure: the device can't run the test.""" 575 """A result that is neither a pass nor a failure: the device can't run the test."""
563 576
@@ -1469,6 +1482,7 @@ def main():
1469 results.append(("cs_fmt_int_narrow", fmt_int_narrow_test(tools, spirv))) 1482 results.append(("cs_fmt_int_narrow", fmt_int_narrow_test(tools, spirv)))
1470 results.append(("cs_fmt_xy_xyz", fmt_xy_xyz_test(tools, spirv))) 1483 results.append(("cs_fmt_xy_xyz", fmt_xy_xyz_test(tools, spirv)))
1471 results.append(("cs_tbuffer_store", tbuffer_store_test(tools, spirv))) 1484 results.append(("cs_tbuffer_store", tbuffer_store_test(tools, spirv)))
1485 results.append(("cs_fmt_d16_xyz", fmt_d16_xyz_test(tools, spirv)))
1472 for name, groups, want in GLOBAL_OFFSET: 1486 for name, groups, want in GLOBAL_OFFSET:
1473 results.append((name, compute_test(tools, spirv, name, groups, "dump", expected_words=want))) 1487 results.append((name, compute_test(tools, spirv, name, groups, "dump", expected_words=want)))
1474 results.append(("cs_user_sgprs", compute_test(tools, spirv, "cs_user_sgprs", "1", "dump", 1488 results.append(("cs_user_sgprs", compute_test(tools, spirv, "cs_user_sgprs", "1", "dump",
diff --git a/runtime/test/shaders/cs_fmt_d16_xyz.asm b/runtime/test/shaders/cs_fmt_d16_xyz.asm
new file mode 100644
index 000000000..c471a6439
--- /dev/null
+++ b/runtime/test/shaders/cs_fmt_d16_xyz.asm
@@ -0,0 +1,98 @@
1; The d16 typed-buffer forms no other test runs: buffer_load_format_d16_xyz, tbuffer_load_format_d16_xy,
2; tbuffer_load_format_d16_xyz and buffer_store_format_d16_xyz. One thread (lane 0) does everything.
3; RDNA2 ISA (MUBUF/MTBUF): a d16 load converts each component to 16 bits (f16 for float and normalized formats, the
4; integer saturated to 16 bits for UINT/SINT) and packs two per VGPR, X in bits 15:0 and Y in 31:16 of the first, Z
5; in 15:0 of the second. docs/design.md (d16 and f16 format narrowing): an odd final component (d16_x, d16_xyz)
6; writes only the low 16 bits of its VGPR and the high half keeps its bits; unsigned 32-bit channels clamp to 65535.
7; A d16 store takes the components from the same halves and encodes them in the V# format (an f16 widened to the
8; f32 of a 32_FLOAT channel, a 16-bit integer zero-extended into a 32_UINT channel).
9; MUBUF uses the V# format (word3 bits 18:12) and DST_SEL (bits 11:0, here X Y Z W); MTBUF uses the instruction's
10; format and identity selectors with a bound V# (32_FLOAT). V# word3 = 0x31000fac | format << 12.
11; Inputs, written first by lane 0:
12; 0x100: 0xabcd1234 0x55557fff 16_16_16_16 X=0x1234 Y=0xabcd Z=0x7fff W=0x5555
13; 0x108: 0xc0003c00 0x7bff3555 f16 X=1.0 (0x3c00) Y=-2.0 (0xc000) Z=0x3555 (0.33325) W=0x7bff
14; 0x110: 5 0x10000 0xffffffff 0 32-bit X Y Z (and a zero pad)
15; 0x120: 0x80ff00ff 8_8_8_8 X=0xff Y=0x00 Z=0xff W=0x80
16; Loads (the second VGPR of each _xyz is seeded first; its high half must survive):
17; L1 buffer_load_format_d16_xyz v[8:9] @0x100, V# 16_16_16_16_UINT (69): X, Y, Z fit in 16 bits.
18; v8 = 0xabcd1234; v9 = 0xa5a5 << 16 | 0x7fff = 0xa5a57fff (seed 0xa5a55a5a)
19; L2 buffer_load_format_d16_xyz v[10:11] @0x110, V# 32_32_32_UINT (72): 5, min(0x10000, 65535) = 0xffff,
20; min(0xffffffff, 65535) = 0xffff. v10 = 0xffff0005; v11 = 0x1234ffff (seed 0x12345678)
21; L3 tbuffer_load_format_d16_xy v12 @0x108, BUF_FMT_16_16_FLOAT: the f16 bits as they are. v12 = 0xc0003c00
22; L4 tbuffer_load_format_d16_xyz v[13:14] @0x108, BUF_FMT_16_16_16_16_FLOAT: v13 = 0xc0003c00;
23; v14 = 0xbeef3555 (seed 0xbeef7777)
24; L5 tbuffer_load_format_d16_xyz v[15:16] @0x120, BUF_FMT_8_8_8_8_UNORM: 255/255 = 1.0 -> 0x3c00, 0/255 = 0,
25; 255/255 = 1.0 -> 0x3c00 (exact, no rounding). v15 = 0x00003c00; v16 = 0xcafe3c00 (seed 0xcafe1111)
26; L6 tbuffer_load_format_d16_xyz v[17:18] @0x110, BUF_FMT_32_32_32_UINT: as L2. v17 = 0xffff0005;
27; v18 = 0x0badffff (seed 0x0bad0bad)
28; v8..v18 go to out[0..10] (0x00..0x28); out[11..15] are untouched (0xeeeeeeee).
29; Stores (the fourth word of each 16-byte region stays untouched):
30; S1 buffer_store_format_d16_xyz v[20:21] @0x40, V# 32_32_32_UINT (72): v20 = 0x80010007, v21 = 0xdeadfffe
31; -> X = 0x0007, Y = 0x8001, Z = 0xfffe (v21's high half is not a component), zero-extended:
32; out[16..19] = 0x00000007 0x00008001 0x0000fffe 0xeeeeeeee
33; S2 buffer_store_format_d16_xyz v[22:23] @0x50, V# 32_32_32_FLOAT (74): v22 = 0xc0003c00, v23 = 0x12343800
34; -> 1.0, -2.0, 0.5 (0x3800) as f32: out[20..23] = 0x3f800000 0xc0000000 0x3f000000 0xeeeeeeee
35; out[24..63] are untouched except the inputs at out[64..72] (0x100..0x120); the dump is 80 words.
36; Run: VKC_OUT_WORDS=80 VKC_DUMP=<file> vk_compute_test cs_fmt_d16_xyz.spv 1 dump
37v_cmpx_eq_u32_e32 0, v0
38s_mov_b32 s4, s0
39s_mov_b32 s5, s1
40s_mov_b32 s6, s2
41v_mov_b32_e32 v1, 0xabcd1234
42v_mov_b32_e32 v2, 0x55557fff
43v_mov_b32_e32 v3, 0xc0003c00
44v_mov_b32_e32 v4, 0x7bff3555
45v_mov_b32_e32 v5, 0x100
46buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
47v_mov_b32_e32 v1, 5
48v_mov_b32_e32 v2, 0x10000
49v_mov_b32_e32 v3, -1
50v_mov_b32_e32 v4, 0
51v_mov_b32_e32 v5, 0x110
52buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
53v_mov_b32_e32 v1, 0x80ff00ff
54v_mov_b32_e32 v5, 0x120
55buffer_store_dword v1, v5, s[0:3], 0 offen
56s_waitcnt vmcnt(0)
57; L1
58s_mov_b32 s7, 0x31045fac
59v_mov_b32_e32 v5, 0x100
60v_mov_b32_e32 v9, 0xa5a55a5a
61buffer_load_format_d16_xyz v[8:9], v5, s[4:7], 0 offen
62; L2
63s_mov_b32 s7, 0x31048fac
64v_mov_b32_e32 v5, 0x110
65v_mov_b32_e32 v11, 0x12345678
66buffer_load_format_d16_xyz v[10:11], v5, s[4:7], 0 offen
67; L3..L6: MTBUF with a bound 32_FLOAT V#
68s_mov_b32 s7, 0x31016fac
69v_mov_b32_e32 v5, 0x108
70tbuffer_load_format_d16_xy v12, v5, s[4:7], 0 format:[BUF_FMT_16_16_FLOAT] offen
71v_mov_b32_e32 v14, 0xbeef7777
72tbuffer_load_format_d16_xyz v[13:14], v5, s[4:7], 0 format:[BUF_FMT_16_16_16_16_FLOAT] offen
73v_mov_b32_e32 v5, 0x120
74v_mov_b32_e32 v16, 0xcafe1111
75tbuffer_load_format_d16_xyz v[15:16], v5, s[4:7], 0 format:[BUF_FMT_8_8_8_8_UNORM] offen
76v_mov_b32_e32 v5, 0x110
77v_mov_b32_e32 v18, 0x0bad0bad
78tbuffer_load_format_d16_xyz v[17:18], v5, s[4:7], 0 format:[BUF_FMT_32_32_32_UINT] offen
79s_waitcnt vmcnt(0)
80v_mov_b32_e32 v6, 0
81buffer_store_dwordx4 v[8:11], v6, s[0:3], 0 offen
82v_mov_b32_e32 v6, 0x10
83buffer_store_dwordx4 v[12:15], v6, s[0:3], 0 offen
84v_mov_b32_e32 v6, 0x20
85buffer_store_dwordx3 v[16:18], v6, s[0:3], 0 offen
86; S1
87s_mov_b32 s7, 0x31048fac
88v_mov_b32_e32 v20, 0x80010007
89v_mov_b32_e32 v21, 0xdeadfffe
90v_mov_b32_e32 v6, 0x40
91buffer_store_format_d16_xyz v[20:21], v6, s[4:7], 0 offen
92; S2
93s_mov_b32 s7, 0x3104afac
94v_mov_b32_e32 v22, 0xc0003c00
95v_mov_b32_e32 v23, 0x12343800
96v_mov_b32_e32 v6, 0x50
97buffer_store_format_d16_xyz v[22:23], v6, s[4:7], 0 offen
98s_endpgm