writer/msl: Wrap each array type in a struct

This allows them to be used in various places that WGSL allows, such
as function return types and parameters, and as the type of the RHS of
an assignment.

Fixed: tint:814
Fixed: tint:820
Change-Id: Idb6a901b9a34e96bb9733cc158191e7b3bafaa0e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52844
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-06-02 17:23:03 +00:00
committed by Tint LUCI CQ
parent 5c0820c76b
commit 94ac078990
50 changed files with 1713 additions and 32 deletions

View File

@@ -0,0 +1,28 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper_0 {
int array[4];
};
struct S {
tint_array_wrapper_0 arr;
};
struct tint_array_wrapper_1 {
tint_array_wrapper_0 array[2];
};
void foo() {
tint_array_wrapper_0 const src = {};
tint_array_wrapper_0 dst = {0};
S dst_struct = {};
tint_array_wrapper_1 dst_array = {{0}};
thread tint_array_wrapper_0* const dst_ptr = &(dst);
thread S* const dst_struct_ptr = &(dst_struct);
thread tint_array_wrapper_1* const dst_array_ptr = &(dst_array);
dst_struct.arr = src;
dst_array.array[1] = src;
*(dst_ptr) = src;
(*(dst_struct_ptr)).arr = src;
(*(dst_array_ptr)).array[0] = src;
}