blob: e6f3323bf5a042341d412cdeb6db69ff70d76e4a [file] [log] [blame]
Ben Clayton9dc42ad2024-02-05 18:01:33 +00001groupshared int4 src_workgroup[4];
2
3void tint_zero_workgroup_memory(uint local_idx) {
4 {
5 for(uint idx = local_idx; (idx < 4u); idx = (idx + 1u)) {
6 uint i = idx;
7 src_workgroup[i] = (0).xxxx;
8 }
9 }
10 GroupMemoryBarrierWithGroupSync();
11}
12
Ben Clayton4135ea52021-07-05 15:20:57 +000013struct S {
James Pricef6e5cc02022-01-20 22:11:07 +000014 int4 arr[4];
Ben Clayton5d2f34e2021-06-16 09:19:36 +000015};
16
James Pricef6e5cc02022-01-20 22:11:07 +000017static int4 src_private[4] = (int4[4])0;
Peng Huangc00ff7f2023-03-31 17:55:19 +000018cbuffer cbuffer_src_uniform : register(b0) {
Ben Clayton8a96c782021-07-15 20:29:09 +000019 uint4 src_uniform[4];
20};
Peng Huangc00ff7f2023-03-31 17:55:19 +000021RWByteAddressBuffer src_storage : register(u1);
22RWByteAddressBuffer tint_symbol : register(u2);
23RWByteAddressBuffer dst_nested : register(u3);
Ben Clayton8a96c782021-07-15 20:29:09 +000024
James Pricef6e5cc02022-01-20 22:11:07 +000025typedef int4 ret_arr_ret[4];
Ben Clayton8a96c782021-07-15 20:29:09 +000026ret_arr_ret ret_arr() {
Antonio Maiorano144ebed2024-01-30 16:30:15 +000027 int4 tint_symbol_4[4] = (int4[4])0;
dan sinclaira01fd242023-12-05 20:23:42 +000028 return tint_symbol_4;
Ben Clayton5d2f34e2021-06-16 09:19:36 +000029}
Ben Clayton9ef52ff2021-06-16 09:19:36 +000030
Ben Clayton8a96c782021-07-15 20:29:09 +000031S ret_struct_arr() {
Antonio Maiorano144ebed2024-01-30 16:30:15 +000032 S tint_symbol_5 = (S)0;
dan sinclaira01fd242023-12-05 20:23:42 +000033 return tint_symbol_5;
Ben Clayton165512c2021-06-18 21:15:25 +000034}
35
Ben Clayton1a1b5272023-02-24 17:16:55 +000036void tint_symbol_store(uint offset, int4 value[4]) {
Ben Clayton971318f2023-02-14 13:52:43 +000037 int4 array_1[4] = value;
Ben Clayton883fb632021-07-16 19:47:44 +000038 {
dan sinclaira01fd242023-12-05 20:23:42 +000039 for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
40 tint_symbol.Store4((offset + (i_1 * 16u)), asuint(array_1[i_1]));
Ben Clayton883fb632021-07-16 19:47:44 +000041 }
42 }
Ben Clayton5d2f34e2021-06-16 09:19:36 +000043}
44
Ben Clayton1a1b5272023-02-24 17:16:55 +000045typedef int4 src_uniform_load_ret[4];
46src_uniform_load_ret src_uniform_load(uint offset) {
James Pricef6e5cc02022-01-20 22:11:07 +000047 int4 arr_1[4] = (int4[4])0;
Ben Clayton883fb632021-07-16 19:47:44 +000048 {
dan sinclaira01fd242023-12-05 20:23:42 +000049 for(uint i_2 = 0u; (i_2 < 4u); i_2 = (i_2 + 1u)) {
50 const uint scalar_offset = ((offset + (i_2 * 16u))) / 4;
51 arr_1[i_2] = asint(src_uniform[scalar_offset / 4]);
Ben Clayton883fb632021-07-16 19:47:44 +000052 }
53 }
54 return arr_1;
Ben Clayton8a96c782021-07-15 20:29:09 +000055}
56
Ben Clayton1a1b5272023-02-24 17:16:55 +000057typedef int4 src_storage_load_ret[4];
58src_storage_load_ret src_storage_load(uint offset) {
James Pricef6e5cc02022-01-20 22:11:07 +000059 int4 arr_2[4] = (int4[4])0;
Ben Clayton883fb632021-07-16 19:47:44 +000060 {
dan sinclaira01fd242023-12-05 20:23:42 +000061 for(uint i_3 = 0u; (i_3 < 4u); i_3 = (i_3 + 1u)) {
62 arr_2[i_3] = asint(src_storage.Load4((offset + (i_3 * 16u))));
Ben Clayton883fb632021-07-16 19:47:44 +000063 }
64 }
65 return arr_2;
Ben Clayton8a96c782021-07-15 20:29:09 +000066}
67
Ben Clayton1a1b5272023-02-24 17:16:55 +000068void dst_nested_store_2(uint offset, int value[2]) {
Ben Clayton971318f2023-02-14 13:52:43 +000069 int array_4[2] = value;
Ben Clayton883fb632021-07-16 19:47:44 +000070 {
dan sinclaira01fd242023-12-05 20:23:42 +000071 for(uint i_4 = 0u; (i_4 < 2u); i_4 = (i_4 + 1u)) {
72 dst_nested.Store((offset + (i_4 * 4u)), asuint(array_4[i_4]));
Ben Clayton883fb632021-07-16 19:47:44 +000073 }
74 }
Ben Clayton5d2f34e2021-06-16 09:19:36 +000075}
76
Ben Clayton1a1b5272023-02-24 17:16:55 +000077void dst_nested_store_1(uint offset, int value[3][2]) {
Ben Clayton971318f2023-02-14 13:52:43 +000078 int array_3[3][2] = value;
Ben Clayton883fb632021-07-16 19:47:44 +000079 {
dan sinclaira01fd242023-12-05 20:23:42 +000080 for(uint i_5 = 0u; (i_5 < 3u); i_5 = (i_5 + 1u)) {
81 dst_nested_store_2((offset + (i_5 * 8u)), array_3[i_5]);
Ben Clayton883fb632021-07-16 19:47:44 +000082 }
83 }
Ben Clayton9ef52ff2021-06-16 09:19:36 +000084}
85
Ben Clayton1a1b5272023-02-24 17:16:55 +000086void dst_nested_store(uint offset, int value[4][3][2]) {
Ben Clayton971318f2023-02-14 13:52:43 +000087 int array_2[4][3][2] = value;
Ben Clayton883fb632021-07-16 19:47:44 +000088 {
dan sinclaira01fd242023-12-05 20:23:42 +000089 for(uint i_6 = 0u; (i_6 < 4u); i_6 = (i_6 + 1u)) {
90 dst_nested_store_1((offset + (i_6 * 24u)), array_2[i_6]);
Ben Clayton883fb632021-07-16 19:47:44 +000091 }
92 }
Ben Clayton9ef52ff2021-06-16 09:19:36 +000093}
94
James Pricef6e5cc02022-01-20 22:11:07 +000095void foo(int4 src_param[4]) {
96 int4 src_function[4] = (int4[4])0;
Antonio Maiorano144ebed2024-01-30 16:30:15 +000097 int4 tint_symbol_6[4] = {(1).xxxx, (2).xxxx, (3).xxxx, (3).xxxx};
dan sinclaira01fd242023-12-05 20:23:42 +000098 tint_symbol_store(0u, tint_symbol_6);
Ben Clayton1a1b5272023-02-24 17:16:55 +000099 tint_symbol_store(0u, src_param);
Ben Claytonda353b42023-03-08 21:48:45 +0000100 tint_symbol_store(0u, ret_arr());
Antonio Maiorano144ebed2024-01-30 16:30:15 +0000101 int4 src_let[4] = (int4[4])0;
Ben Clayton1a1b5272023-02-24 17:16:55 +0000102 tint_symbol_store(0u, src_let);
103 tint_symbol_store(0u, src_function);
104 tint_symbol_store(0u, src_private);
105 tint_symbol_store(0u, src_workgroup);
Antonio Maiorano144ebed2024-01-30 16:30:15 +0000106 S tint_symbol_1 = ret_struct_arr();
Ben Claytonda353b42023-03-08 21:48:45 +0000107 tint_symbol_store(0u, tint_symbol_1.arr);
Ben Clayton1a1b5272023-02-24 17:16:55 +0000108 tint_symbol_store(0u, src_uniform_load(0u));
109 tint_symbol_store(0u, src_storage_load(0u));
Ben Clayton4135ea52021-07-05 15:20:57 +0000110 int src_nested[4][3][2] = (int[4][3][2])0;
Ben Clayton1a1b5272023-02-24 17:16:55 +0000111 dst_nested_store(0u, src_nested);
Ben Clayton5d2f34e2021-06-16 09:19:36 +0000112}
dan sinclaira01fd242023-12-05 20:23:42 +0000113
114struct tint_symbol_3 {
115 uint local_invocation_index : SV_GroupIndex;
116};
117
118void main_inner(uint local_invocation_index) {
Ben Clayton9dc42ad2024-02-05 18:01:33 +0000119 tint_zero_workgroup_memory(local_invocation_index);
Antonio Maiorano144ebed2024-01-30 16:30:15 +0000120 int4 ary[4] = (int4[4])0;
dan sinclaira01fd242023-12-05 20:23:42 +0000121 foo(ary);
122}
123
124[numthreads(1, 1, 1)]
125void main(tint_symbol_3 tint_symbol_2) {
126 main_inner(tint_symbol_2.local_invocation_index);
127 return;
128}