Deprecate the @stride attribute
Update validation error for invalid uniform array element alignment.
Update tests to either remove the @stride attribute or use a different
element type.
Bug: tint:1381
Change-Id: I50b52cd78a34d9cd162fa5f2171a5fd35dcf3b79
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77560
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/test/array/assign_to_function_var.wgsl b/test/array/assign_to_function_var.wgsl
index d5ccaa2..b2dc68d 100644
--- a/test/array/assign_to_function_var.wgsl
+++ b/test/array/assign_to_function_var.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -23,7 +23,7 @@
var dst : ArrayType;
// Assign from type constructor.
- dst = ArrayType(1, 2, 3, 3);
+ dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
// Assign from parameter.
dst = src_param;
diff --git a/test/array/assign_to_function_var.wgsl.expected.hlsl b/test/array/assign_to_function_var.wgsl.expected.hlsl
index f5c4ff0..eda01ad 100644
--- a/test/array/assign_to_function_var.wgsl.expected.hlsl
+++ b/test/array/assign_to_function_var.wgsl.expected.hlsl
@@ -3,23 +3,20 @@
return;
}
-struct tint_padded_array_element {
- int el;
-};
struct S {
- tint_padded_array_element arr[4];
+ int4 arr[4];
};
-static tint_padded_array_element src_private[4] = (tint_padded_array_element[4])0;
-groupshared tint_padded_array_element src_workgroup[4];
+static int4 src_private[4] = (int4[4])0;
+groupshared int4 src_workgroup[4];
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
};
RWByteAddressBuffer src_storage : register(u1, space0);
-typedef tint_padded_array_element ret_arr_ret[4];
+typedef int4 ret_arr_ret[4];
ret_arr_ret ret_arr() {
- const tint_padded_array_element tint_symbol_5[4] = (tint_padded_array_element[4])0;
+ const int4 tint_symbol_5[4] = (int4[4])0;
return tint_symbol_5;
}
@@ -28,37 +25,37 @@
return tint_symbol_6;
}
-typedef tint_padded_array_element tint_symbol_1_ret[4];
+typedef int4 tint_symbol_1_ret[4];
tint_symbol_1_ret tint_symbol_1(uint4 buffer[4], uint offset) {
- tint_padded_array_element arr_1[4] = (tint_padded_array_element[4])0;
+ int4 arr_1[4] = (int4[4])0;
{
[loop] for(uint i = 0u; (i < 4u); i = (i + 1u)) {
const uint scalar_offset = ((offset + (i * 16u))) / 4;
- arr_1[i].el = asint(buffer[scalar_offset / 4][scalar_offset % 4]);
+ arr_1[i] = asint(buffer[scalar_offset / 4]);
}
}
return arr_1;
}
-typedef tint_padded_array_element tint_symbol_3_ret[4];
+typedef int4 tint_symbol_3_ret[4];
tint_symbol_3_ret tint_symbol_3(RWByteAddressBuffer buffer, uint offset) {
- tint_padded_array_element arr_2[4] = (tint_padded_array_element[4])0;
+ int4 arr_2[4] = (int4[4])0;
{
[loop] for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
- arr_2[i_1].el = asint(buffer.Load((offset + (i_1 * 16u))));
+ arr_2[i_1] = asint(buffer.Load4((offset + (i_1 * 16u))));
}
}
return arr_2;
}
-void foo(tint_padded_array_element src_param[4]) {
- tint_padded_array_element src_function[4] = (tint_padded_array_element[4])0;
- tint_padded_array_element tint_symbol[4] = (tint_padded_array_element[4])0;
- const tint_padded_array_element tint_symbol_7[4] = {{1}, {2}, {3}, {3}};
+void foo(int4 src_param[4]) {
+ int4 src_function[4] = (int4[4])0;
+ int4 tint_symbol[4] = (int4[4])0;
+ const int4 tint_symbol_7[4] = {int4((1).xxxx), int4((2).xxxx), int4((3).xxxx), int4((3).xxxx)};
tint_symbol = tint_symbol_7;
tint_symbol = src_param;
tint_symbol = ret_arr();
- const tint_padded_array_element src_let[4] = (tint_padded_array_element[4])0;
+ const int4 src_let[4] = (int4[4])0;
tint_symbol = src_let;
tint_symbol = src_function;
tint_symbol = src_private;
diff --git a/test/array/assign_to_function_var.wgsl.expected.msl b/test/array/assign_to_function_var.wgsl.expected.msl
index e198433..7abc32d 100644
--- a/test/array/assign_to_function_var.wgsl.expected.msl
+++ b/test/array/assign_to_function_var.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-struct tint_padded_array_element {
- /* 0x0000 */ int el;
- /* 0x0004 */ int8_t tint_pad[12];
-};
struct tint_array_wrapper {
- /* 0x0000 */ tint_padded_array_element arr[4];
+ /* 0x0000 */ int4 arr[4];
};
struct S {
/* 0x0000 */ tint_array_wrapper arr;
@@ -34,7 +30,7 @@
void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_3, threadgroup tint_array_wrapper* const tint_symbol_4, const constant S* const tint_symbol_5, device S* const tint_symbol_6) {
tint_array_wrapper src_function = {};
tint_array_wrapper dst = {};
- tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
+ tint_array_wrapper const tint_symbol_2 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
dst = tint_symbol_2;
dst = src_param;
dst = ret_arr();
diff --git a/test/array/assign_to_function_var.wgsl.expected.spvasm b/test/array/assign_to_function_var.wgsl.expected.spvasm
index 668fc9c..636346d 100644
--- a/test/array/assign_to_function_var.wgsl.expected.spvasm
+++ b/test/array/assign_to_function_var.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 60
+; Bound: 64
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -22,7 +22,7 @@
OpName %dst "dst"
OpName %dst_nested "dst_nested"
OpName %src_nested "src_nested"
- OpDecorate %_arr_int_uint_4 ArrayStride 16
+ OpDecorate %_arr_v4int_uint_4 ArrayStride 16
OpDecorate %S Block
OpMemberDecorate %S 0 Offset 0
OpDecorate %src_uniform NonWritable
@@ -34,80 +34,84 @@
OpDecorate %_arr__arr_int_uint_2_uint_3 ArrayStride 8
OpDecorate %_arr__arr__arr_int_uint_2_uint_3_uint_4 ArrayStride 24
%int = OpTypeInt 32 1
+ %v4int = OpTypeVector %int 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
-%_arr_int_uint_4 = OpTypeArray %int %uint_4
-%_ptr_Private__arr_int_uint_4 = OpTypePointer Private %_arr_int_uint_4
- %7 = OpConstantNull %_arr_int_uint_4
-%src_private = OpVariable %_ptr_Private__arr_int_uint_4 Private %7
-%_ptr_Workgroup__arr_int_uint_4 = OpTypePointer Workgroup %_arr_int_uint_4
-%src_workgroup = OpVariable %_ptr_Workgroup__arr_int_uint_4 Workgroup
- %S = OpTypeStruct %_arr_int_uint_4
+%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4
+%_ptr_Private__arr_v4int_uint_4 = OpTypePointer Private %_arr_v4int_uint_4
+ %8 = OpConstantNull %_arr_v4int_uint_4
+%src_private = OpVariable %_ptr_Private__arr_v4int_uint_4 Private %8
+%_ptr_Workgroup__arr_v4int_uint_4 = OpTypePointer Workgroup %_arr_v4int_uint_4
+%src_workgroup = OpVariable %_ptr_Workgroup__arr_v4int_uint_4 Workgroup
+ %S = OpTypeStruct %_arr_v4int_uint_4
%_ptr_Uniform_S = OpTypePointer Uniform %S
%src_uniform = OpVariable %_ptr_Uniform_S Uniform
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
%src_storage = OpVariable %_ptr_StorageBuffer_S StorageBuffer
%void = OpTypeVoid
- %15 = OpTypeFunction %void
- %19 = OpTypeFunction %_arr_int_uint_4
- %22 = OpTypeFunction %S
- %25 = OpConstantNull %S
- %26 = OpTypeFunction %void %_arr_int_uint_4
-%_ptr_Function__arr_int_uint_4 = OpTypePointer Function %_arr_int_uint_4
+ %16 = OpTypeFunction %void
+ %20 = OpTypeFunction %_arr_v4int_uint_4
+ %23 = OpTypeFunction %S
+ %26 = OpConstantNull %S
+ %27 = OpTypeFunction %void %_arr_v4int_uint_4
+%_ptr_Function__arr_v4int_uint_4 = OpTypePointer Function %_arr_v4int_uint_4
%int_1 = OpConstant %int 1
+ %35 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%int_2 = OpConstant %int 2
+ %37 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%int_3 = OpConstant %int 3
- %36 = OpConstantComposite %_arr_int_uint_4 %int_1 %int_2 %int_3 %int_3
+ %39 = OpConstantComposite %v4int %int_3 %int_3 %int_3 %int_3
+ %40 = OpConstantComposite %_arr_v4int_uint_4 %35 %37 %39 %39
%uint_0 = OpConstant %uint 0
-%_ptr_Uniform__arr_int_uint_4 = OpTypePointer Uniform %_arr_int_uint_4
-%_ptr_StorageBuffer__arr_int_uint_4 = OpTypePointer StorageBuffer %_arr_int_uint_4
+%_ptr_Uniform__arr_v4int_uint_4 = OpTypePointer Uniform %_arr_v4int_uint_4
+%_ptr_StorageBuffer__arr_v4int_uint_4 = OpTypePointer StorageBuffer %_arr_v4int_uint_4
%uint_2 = OpConstant %uint 2
%_arr_int_uint_2 = OpTypeArray %int %uint_2
%uint_3 = OpConstant %uint 3
%_arr__arr_int_uint_2_uint_3 = OpTypeArray %_arr_int_uint_2 %uint_3
%_arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypeArray %_arr__arr_int_uint_2_uint_3 %uint_4
%_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypePointer Function %_arr__arr__arr_int_uint_2_uint_3_uint_4
- %57 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
-%unused_entry_point = OpFunction %void None %15
- %18 = OpLabel
+ %61 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
+%unused_entry_point = OpFunction %void None %16
+ %19 = OpLabel
OpReturn
OpFunctionEnd
- %ret_arr = OpFunction %_arr_int_uint_4 None %19
- %21 = OpLabel
- OpReturnValue %7
+ %ret_arr = OpFunction %_arr_v4int_uint_4 None %20
+ %22 = OpLabel
+ OpReturnValue %8
OpFunctionEnd
-%ret_struct_arr = OpFunction %S None %22
- %24 = OpLabel
- OpReturnValue %25
+%ret_struct_arr = OpFunction %S None %23
+ %25 = OpLabel
+ OpReturnValue %26
OpFunctionEnd
- %foo = OpFunction %void None %26
- %src_param = OpFunctionParameter %_arr_int_uint_4
- %29 = OpLabel
-%src_function = OpVariable %_ptr_Function__arr_int_uint_4 Function %7
- %dst = OpVariable %_ptr_Function__arr_int_uint_4 Function %7
- %dst_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %57
- %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %57
- OpStore %dst %36
- OpStore %dst %src_param
- %37 = OpFunctionCall %_arr_int_uint_4 %ret_arr
- OpStore %dst %37
- OpStore %dst %7
- %38 = OpLoad %_arr_int_uint_4 %src_function
- OpStore %dst %38
- %39 = OpLoad %_arr_int_uint_4 %src_private
- OpStore %dst %39
- %40 = OpLoad %_arr_int_uint_4 %src_workgroup
+ %foo = OpFunction %void None %27
+ %src_param = OpFunctionParameter %_arr_v4int_uint_4
+ %30 = OpLabel
+%src_function = OpVariable %_ptr_Function__arr_v4int_uint_4 Function %8
+ %dst = OpVariable %_ptr_Function__arr_v4int_uint_4 Function %8
+ %dst_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %61
+ %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %61
OpStore %dst %40
- %41 = OpFunctionCall %S %ret_struct_arr
- %42 = OpCompositeExtract %_arr_int_uint_4 %41 0
+ OpStore %dst %src_param
+ %41 = OpFunctionCall %_arr_v4int_uint_4 %ret_arr
+ OpStore %dst %41
+ OpStore %dst %8
+ %42 = OpLoad %_arr_v4int_uint_4 %src_function
OpStore %dst %42
- %45 = OpAccessChain %_ptr_Uniform__arr_int_uint_4 %src_uniform %uint_0
- %46 = OpLoad %_arr_int_uint_4 %45
+ %43 = OpLoad %_arr_v4int_uint_4 %src_private
+ OpStore %dst %43
+ %44 = OpLoad %_arr_v4int_uint_4 %src_workgroup
+ OpStore %dst %44
+ %45 = OpFunctionCall %S %ret_struct_arr
+ %46 = OpCompositeExtract %_arr_v4int_uint_4 %45 0
OpStore %dst %46
- %48 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %src_storage %uint_0
- %49 = OpLoad %_arr_int_uint_4 %48
- OpStore %dst %49
- %59 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
- OpStore %dst_nested %59
+ %49 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %src_uniform %uint_0
+ %50 = OpLoad %_arr_v4int_uint_4 %49
+ OpStore %dst %50
+ %52 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %src_storage %uint_0
+ %53 = OpLoad %_arr_v4int_uint_4 %52
+ OpStore %dst %53
+ %63 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
+ OpStore %dst_nested %63
OpReturn
OpFunctionEnd
diff --git a/test/array/assign_to_function_var.wgsl.expected.wgsl b/test/array/assign_to_function_var.wgsl.expected.wgsl
index 0033bea..b001ab6 100644
--- a/test/array/assign_to_function_var.wgsl.expected.wgsl
+++ b/test/array/assign_to_function_var.wgsl.expected.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -23,7 +23,7 @@
fn foo(src_param : ArrayType) {
var src_function : ArrayType;
var dst : ArrayType;
- dst = ArrayType(1, 2, 3, 3);
+ dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
dst = src_param;
dst = ret_arr();
let src_let : ArrayType = ArrayType();
diff --git a/test/array/assign_to_private_var.wgsl b/test/array/assign_to_private_var.wgsl
index 510da19..c19b3ee 100644
--- a/test/array/assign_to_private_var.wgsl
+++ b/test/array/assign_to_private_var.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -24,7 +24,7 @@
var src_function : ArrayType;
// Assign from type constructor.
- dst = ArrayType(1, 2, 3, 3);
+ dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
// Assign from parameter.
dst = src_param;
diff --git a/test/array/assign_to_private_var.wgsl.expected.hlsl b/test/array/assign_to_private_var.wgsl.expected.hlsl
index 4fd9d45..ddb084e 100644
--- a/test/array/assign_to_private_var.wgsl.expected.hlsl
+++ b/test/array/assign_to_private_var.wgsl.expected.hlsl
@@ -3,25 +3,22 @@
return;
}
-struct tint_padded_array_element {
- int el;
-};
struct S {
- tint_padded_array_element arr[4];
+ int4 arr[4];
};
-static tint_padded_array_element src_private[4] = (tint_padded_array_element[4])0;
-groupshared tint_padded_array_element src_workgroup[4];
+static int4 src_private[4] = (int4[4])0;
+groupshared int4 src_workgroup[4];
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
};
RWByteAddressBuffer src_storage : register(u1, space0);
-static tint_padded_array_element tint_symbol[4] = (tint_padded_array_element[4])0;
+static int4 tint_symbol[4] = (int4[4])0;
static int dst_nested[4][3][2] = (int[4][3][2])0;
-typedef tint_padded_array_element ret_arr_ret[4];
+typedef int4 ret_arr_ret[4];
ret_arr_ret ret_arr() {
- const tint_padded_array_element tint_symbol_5[4] = (tint_padded_array_element[4])0;
+ const int4 tint_symbol_5[4] = (int4[4])0;
return tint_symbol_5;
}
@@ -30,36 +27,36 @@
return tint_symbol_6;
}
-typedef tint_padded_array_element tint_symbol_1_ret[4];
+typedef int4 tint_symbol_1_ret[4];
tint_symbol_1_ret tint_symbol_1(uint4 buffer[4], uint offset) {
- tint_padded_array_element arr_1[4] = (tint_padded_array_element[4])0;
+ int4 arr_1[4] = (int4[4])0;
{
[loop] for(uint i = 0u; (i < 4u); i = (i + 1u)) {
const uint scalar_offset = ((offset + (i * 16u))) / 4;
- arr_1[i].el = asint(buffer[scalar_offset / 4][scalar_offset % 4]);
+ arr_1[i] = asint(buffer[scalar_offset / 4]);
}
}
return arr_1;
}
-typedef tint_padded_array_element tint_symbol_3_ret[4];
+typedef int4 tint_symbol_3_ret[4];
tint_symbol_3_ret tint_symbol_3(RWByteAddressBuffer buffer, uint offset) {
- tint_padded_array_element arr_2[4] = (tint_padded_array_element[4])0;
+ int4 arr_2[4] = (int4[4])0;
{
[loop] for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
- arr_2[i_1].el = asint(buffer.Load((offset + (i_1 * 16u))));
+ arr_2[i_1] = asint(buffer.Load4((offset + (i_1 * 16u))));
}
}
return arr_2;
}
-void foo(tint_padded_array_element src_param[4]) {
- tint_padded_array_element src_function[4] = (tint_padded_array_element[4])0;
- const tint_padded_array_element tint_symbol_7[4] = {{1}, {2}, {3}, {3}};
+void foo(int4 src_param[4]) {
+ int4 src_function[4] = (int4[4])0;
+ const int4 tint_symbol_7[4] = {int4((1).xxxx), int4((2).xxxx), int4((3).xxxx), int4((3).xxxx)};
tint_symbol = tint_symbol_7;
tint_symbol = src_param;
tint_symbol = ret_arr();
- const tint_padded_array_element src_let[4] = (tint_padded_array_element[4])0;
+ const int4 src_let[4] = (int4[4])0;
tint_symbol = src_let;
tint_symbol = src_function;
tint_symbol = src_private;
diff --git a/test/array/assign_to_private_var.wgsl.expected.msl b/test/array/assign_to_private_var.wgsl.expected.msl
index dd91dca..7d8a3ab 100644
--- a/test/array/assign_to_private_var.wgsl.expected.msl
+++ b/test/array/assign_to_private_var.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-struct tint_padded_array_element {
- /* 0x0000 */ int el;
- /* 0x0004 */ int8_t tint_pad[12];
-};
struct tint_array_wrapper {
- /* 0x0000 */ tint_padded_array_element arr[4];
+ /* 0x0000 */ int4 arr[4];
};
struct S {
/* 0x0000 */ tint_array_wrapper arr;
@@ -33,7 +29,7 @@
void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7, thread tint_array_wrapper_1* const tint_symbol_8) {
tint_array_wrapper src_function = {};
- tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
+ tint_array_wrapper const tint_symbol_2 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
*(tint_symbol_3) = tint_symbol_2;
*(tint_symbol_3) = src_param;
*(tint_symbol_3) = ret_arr();
diff --git a/test/array/assign_to_private_var.wgsl.expected.spvasm b/test/array/assign_to_private_var.wgsl.expected.spvasm
index 258a540..3427ea7 100644
--- a/test/array/assign_to_private_var.wgsl.expected.spvasm
+++ b/test/array/assign_to_private_var.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 61
+; Bound: 65
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -22,7 +22,7 @@
OpName %src_param "src_param"
OpName %src_function "src_function"
OpName %src_nested "src_nested"
- OpDecorate %_arr_int_uint_4 ArrayStride 16
+ OpDecorate %_arr_v4int_uint_4 ArrayStride 16
OpDecorate %S Block
OpMemberDecorate %S 0 Offset 0
OpDecorate %src_uniform NonWritable
@@ -34,81 +34,85 @@
OpDecorate %_arr__arr_int_uint_2_uint_3 ArrayStride 8
OpDecorate %_arr__arr__arr_int_uint_2_uint_3_uint_4 ArrayStride 24
%int = OpTypeInt 32 1
+ %v4int = OpTypeVector %int 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
-%_arr_int_uint_4 = OpTypeArray %int %uint_4
-%_ptr_Private__arr_int_uint_4 = OpTypePointer Private %_arr_int_uint_4
- %7 = OpConstantNull %_arr_int_uint_4
-%src_private = OpVariable %_ptr_Private__arr_int_uint_4 Private %7
-%_ptr_Workgroup__arr_int_uint_4 = OpTypePointer Workgroup %_arr_int_uint_4
-%src_workgroup = OpVariable %_ptr_Workgroup__arr_int_uint_4 Workgroup
- %S = OpTypeStruct %_arr_int_uint_4
+%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4
+%_ptr_Private__arr_v4int_uint_4 = OpTypePointer Private %_arr_v4int_uint_4
+ %8 = OpConstantNull %_arr_v4int_uint_4
+%src_private = OpVariable %_ptr_Private__arr_v4int_uint_4 Private %8
+%_ptr_Workgroup__arr_v4int_uint_4 = OpTypePointer Workgroup %_arr_v4int_uint_4
+%src_workgroup = OpVariable %_ptr_Workgroup__arr_v4int_uint_4 Workgroup
+ %S = OpTypeStruct %_arr_v4int_uint_4
%_ptr_Uniform_S = OpTypePointer Uniform %S
%src_uniform = OpVariable %_ptr_Uniform_S Uniform
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
%src_storage = OpVariable %_ptr_StorageBuffer_S StorageBuffer
- %dst = OpVariable %_ptr_Private__arr_int_uint_4 Private %7
+ %dst = OpVariable %_ptr_Private__arr_v4int_uint_4 Private %8
%uint_2 = OpConstant %uint 2
%_arr_int_uint_2 = OpTypeArray %int %uint_2
%uint_3 = OpConstant %uint 3
%_arr__arr_int_uint_2_uint_3 = OpTypeArray %_arr_int_uint_2 %uint_3
%_arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypeArray %_arr__arr_int_uint_2_uint_3 %uint_4
%_ptr_Private__arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypePointer Private %_arr__arr__arr_int_uint_2_uint_3_uint_4
- %23 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
- %dst_nested = OpVariable %_ptr_Private__arr__arr__arr_int_uint_2_uint_3_uint_4 Private %23
+ %24 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
+ %dst_nested = OpVariable %_ptr_Private__arr__arr__arr_int_uint_2_uint_3_uint_4 Private %24
%void = OpTypeVoid
- %24 = OpTypeFunction %void
- %28 = OpTypeFunction %_arr_int_uint_4
- %31 = OpTypeFunction %S
- %34 = OpConstantNull %S
- %35 = OpTypeFunction %void %_arr_int_uint_4
-%_ptr_Function__arr_int_uint_4 = OpTypePointer Function %_arr_int_uint_4
+ %25 = OpTypeFunction %void
+ %29 = OpTypeFunction %_arr_v4int_uint_4
+ %32 = OpTypeFunction %S
+ %35 = OpConstantNull %S
+ %36 = OpTypeFunction %void %_arr_v4int_uint_4
+%_ptr_Function__arr_v4int_uint_4 = OpTypePointer Function %_arr_v4int_uint_4
%int_1 = OpConstant %int 1
+ %43 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%int_2 = OpConstant %int 2
+ %45 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%int_3 = OpConstant %int 3
- %44 = OpConstantComposite %_arr_int_uint_4 %int_1 %int_2 %int_3 %int_3
+ %47 = OpConstantComposite %v4int %int_3 %int_3 %int_3 %int_3
+ %48 = OpConstantComposite %_arr_v4int_uint_4 %43 %45 %47 %47
%uint_0 = OpConstant %uint 0
-%_ptr_Uniform__arr_int_uint_4 = OpTypePointer Uniform %_arr_int_uint_4
-%_ptr_StorageBuffer__arr_int_uint_4 = OpTypePointer StorageBuffer %_arr_int_uint_4
+%_ptr_Uniform__arr_v4int_uint_4 = OpTypePointer Uniform %_arr_v4int_uint_4
+%_ptr_StorageBuffer__arr_v4int_uint_4 = OpTypePointer StorageBuffer %_arr_v4int_uint_4
%_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypePointer Function %_arr__arr__arr_int_uint_2_uint_3_uint_4
-%unused_entry_point = OpFunction %void None %24
- %27 = OpLabel
+%unused_entry_point = OpFunction %void None %25
+ %28 = OpLabel
OpReturn
OpFunctionEnd
- %ret_arr = OpFunction %_arr_int_uint_4 None %28
- %30 = OpLabel
- OpReturnValue %7
+ %ret_arr = OpFunction %_arr_v4int_uint_4 None %29
+ %31 = OpLabel
+ OpReturnValue %8
OpFunctionEnd
-%ret_struct_arr = OpFunction %S None %31
- %33 = OpLabel
- OpReturnValue %34
+%ret_struct_arr = OpFunction %S None %32
+ %34 = OpLabel
+ OpReturnValue %35
OpFunctionEnd
- %foo = OpFunction %void None %35
- %src_param = OpFunctionParameter %_arr_int_uint_4
- %38 = OpLabel
-%src_function = OpVariable %_ptr_Function__arr_int_uint_4 Function %7
- %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %23
- OpStore %dst %44
- OpStore %dst %src_param
- %45 = OpFunctionCall %_arr_int_uint_4 %ret_arr
- OpStore %dst %45
- OpStore %dst %7
- %46 = OpLoad %_arr_int_uint_4 %src_function
- OpStore %dst %46
- %47 = OpLoad %_arr_int_uint_4 %src_private
- OpStore %dst %47
- %48 = OpLoad %_arr_int_uint_4 %src_workgroup
+ %foo = OpFunction %void None %36
+ %src_param = OpFunctionParameter %_arr_v4int_uint_4
+ %39 = OpLabel
+%src_function = OpVariable %_ptr_Function__arr_v4int_uint_4 Function %8
+ %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %24
OpStore %dst %48
- %49 = OpFunctionCall %S %ret_struct_arr
- %50 = OpCompositeExtract %_arr_int_uint_4 %49 0
+ OpStore %dst %src_param
+ %49 = OpFunctionCall %_arr_v4int_uint_4 %ret_arr
+ OpStore %dst %49
+ OpStore %dst %8
+ %50 = OpLoad %_arr_v4int_uint_4 %src_function
OpStore %dst %50
- %53 = OpAccessChain %_ptr_Uniform__arr_int_uint_4 %src_uniform %uint_0
- %54 = OpLoad %_arr_int_uint_4 %53
+ %51 = OpLoad %_arr_v4int_uint_4 %src_private
+ OpStore %dst %51
+ %52 = OpLoad %_arr_v4int_uint_4 %src_workgroup
+ OpStore %dst %52
+ %53 = OpFunctionCall %S %ret_struct_arr
+ %54 = OpCompositeExtract %_arr_v4int_uint_4 %53 0
OpStore %dst %54
- %56 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %src_storage %uint_0
- %57 = OpLoad %_arr_int_uint_4 %56
- OpStore %dst %57
- %60 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
- OpStore %dst_nested %60
+ %57 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %src_uniform %uint_0
+ %58 = OpLoad %_arr_v4int_uint_4 %57
+ OpStore %dst %58
+ %60 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %src_storage %uint_0
+ %61 = OpLoad %_arr_v4int_uint_4 %60
+ OpStore %dst %61
+ %64 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
+ OpStore %dst_nested %64
OpReturn
OpFunctionEnd
diff --git a/test/array/assign_to_private_var.wgsl.expected.wgsl b/test/array/assign_to_private_var.wgsl.expected.wgsl
index fd2057b..7f88483 100644
--- a/test/array/assign_to_private_var.wgsl.expected.wgsl
+++ b/test/array/assign_to_private_var.wgsl.expected.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -26,7 +26,7 @@
fn foo(src_param : ArrayType) {
var src_function : ArrayType;
- dst = ArrayType(1, 2, 3, 3);
+ dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
dst = src_param;
dst = ret_arr();
let src_let : ArrayType = ArrayType();
diff --git a/test/array/assign_to_storage_var.wgsl b/test/array/assign_to_storage_var.wgsl
index 6d001d8..9ed30b2 100644
--- a/test/array/assign_to_storage_var.wgsl
+++ b/test/array/assign_to_storage_var.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -28,7 +28,7 @@
var src_function : ArrayType;
// Assign from type constructor.
- dst.arr = ArrayType(1, 2, 3, 3);
+ dst.arr = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
// Assign from parameter.
dst.arr = src_param;
diff --git a/test/array/assign_to_storage_var.wgsl.expected.hlsl b/test/array/assign_to_storage_var.wgsl.expected.hlsl
index 8e9d0b6..c940b98 100644
--- a/test/array/assign_to_storage_var.wgsl.expected.hlsl
+++ b/test/array/assign_to_storage_var.wgsl.expected.hlsl
@@ -3,15 +3,12 @@
return;
}
-struct tint_padded_array_element {
- int el;
-};
struct S {
- tint_padded_array_element arr[4];
+ int4 arr[4];
};
-static tint_padded_array_element src_private[4] = (tint_padded_array_element[4])0;
-groupshared tint_padded_array_element src_workgroup[4];
+static int4 src_private[4] = (int4[4])0;
+groupshared int4 src_workgroup[4];
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
};
@@ -19,9 +16,9 @@
RWByteAddressBuffer tint_symbol : register(u2, space0);
RWByteAddressBuffer dst_nested : register(u3, space0);
-typedef tint_padded_array_element ret_arr_ret[4];
+typedef int4 ret_arr_ret[4];
ret_arr_ret ret_arr() {
- const tint_padded_array_element tint_symbol_11[4] = (tint_padded_array_element[4])0;
+ const int4 tint_symbol_11[4] = (int4[4])0;
return tint_symbol_11;
}
@@ -30,33 +27,33 @@
return tint_symbol_12;
}
-void tint_symbol_1(RWByteAddressBuffer buffer, uint offset, tint_padded_array_element value[4]) {
- tint_padded_array_element array[4] = value;
+void tint_symbol_1(RWByteAddressBuffer buffer, uint offset, int4 value[4]) {
+ int4 array[4] = value;
{
[loop] for(uint i = 0u; (i < 4u); i = (i + 1u)) {
- buffer.Store((offset + (i * 16u)), asuint(array[i].el));
+ buffer.Store4((offset + (i * 16u)), asuint(array[i]));
}
}
}
-typedef tint_padded_array_element tint_symbol_3_ret[4];
+typedef int4 tint_symbol_3_ret[4];
tint_symbol_3_ret tint_symbol_3(uint4 buffer[4], uint offset) {
- tint_padded_array_element arr_1[4] = (tint_padded_array_element[4])0;
+ int4 arr_1[4] = (int4[4])0;
{
[loop] for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
const uint scalar_offset = ((offset + (i_1 * 16u))) / 4;
- arr_1[i_1].el = asint(buffer[scalar_offset / 4][scalar_offset % 4]);
+ arr_1[i_1] = asint(buffer[scalar_offset / 4]);
}
}
return arr_1;
}
-typedef tint_padded_array_element tint_symbol_5_ret[4];
+typedef int4 tint_symbol_5_ret[4];
tint_symbol_5_ret tint_symbol_5(RWByteAddressBuffer buffer, uint offset) {
- tint_padded_array_element arr_2[4] = (tint_padded_array_element[4])0;
+ int4 arr_2[4] = (int4[4])0;
{
[loop] for(uint i_2 = 0u; (i_2 < 4u); i_2 = (i_2 + 1u)) {
- arr_2[i_2].el = asint(buffer.Load((offset + (i_2 * 16u))));
+ arr_2[i_2] = asint(buffer.Load4((offset + (i_2 * 16u))));
}
}
return arr_2;
@@ -89,13 +86,13 @@
}
}
-void foo(tint_padded_array_element src_param[4]) {
- tint_padded_array_element src_function[4] = (tint_padded_array_element[4])0;
- const tint_padded_array_element tint_symbol_13[4] = {{1}, {2}, {3}, {3}};
+void foo(int4 src_param[4]) {
+ int4 src_function[4] = (int4[4])0;
+ const int4 tint_symbol_13[4] = {int4((1).xxxx), int4((2).xxxx), int4((3).xxxx), int4((3).xxxx)};
tint_symbol_1(tint_symbol, 0u, tint_symbol_13);
tint_symbol_1(tint_symbol, 0u, src_param);
tint_symbol_1(tint_symbol, 0u, ret_arr());
- const tint_padded_array_element src_let[4] = (tint_padded_array_element[4])0;
+ const int4 src_let[4] = (int4[4])0;
tint_symbol_1(tint_symbol, 0u, src_let);
tint_symbol_1(tint_symbol, 0u, src_function);
tint_symbol_1(tint_symbol, 0u, src_private);
diff --git a/test/array/assign_to_storage_var.wgsl.expected.msl b/test/array/assign_to_storage_var.wgsl.expected.msl
index c0d7dba..c1a31f9 100644
--- a/test/array/assign_to_storage_var.wgsl.expected.msl
+++ b/test/array/assign_to_storage_var.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-struct tint_padded_array_element {
- /* 0x0000 */ int el;
- /* 0x0004 */ int8_t tint_pad[12];
-};
struct tint_array_wrapper {
- /* 0x0000 */ tint_padded_array_element arr[4];
+ /* 0x0000 */ int4 arr[4];
};
struct S {
/* 0x0000 */ tint_array_wrapper arr;
@@ -36,7 +32,7 @@
void foo(tint_array_wrapper src_param, device S* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7, device S_nested* const tint_symbol_8) {
tint_array_wrapper src_function = {};
- tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
+ tint_array_wrapper const tint_symbol_2 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
(*(tint_symbol_3)).arr = tint_symbol_2;
(*(tint_symbol_3)).arr = src_param;
(*(tint_symbol_3)).arr = ret_arr();
diff --git a/test/array/assign_to_storage_var.wgsl.expected.spvasm b/test/array/assign_to_storage_var.wgsl.expected.spvasm
index 1764efa..e4da62a 100644
--- a/test/array/assign_to_storage_var.wgsl.expected.spvasm
+++ b/test/array/assign_to_storage_var.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 74
+; Bound: 78
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -24,7 +24,7 @@
OpName %src_param "src_param"
OpName %src_function "src_function"
OpName %src_nested "src_nested"
- OpDecorate %_arr_int_uint_4 ArrayStride 16
+ OpDecorate %_arr_v4int_uint_4 ArrayStride 16
OpDecorate %S Block
OpMemberDecorate %S 0 Offset 0
OpDecorate %src_uniform NonWritable
@@ -42,15 +42,16 @@
OpDecorate %dst_nested DescriptorSet 0
OpDecorate %dst_nested Binding 3
%int = OpTypeInt 32 1
+ %v4int = OpTypeVector %int 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
-%_arr_int_uint_4 = OpTypeArray %int %uint_4
-%_ptr_Private__arr_int_uint_4 = OpTypePointer Private %_arr_int_uint_4
- %7 = OpConstantNull %_arr_int_uint_4
-%src_private = OpVariable %_ptr_Private__arr_int_uint_4 Private %7
-%_ptr_Workgroup__arr_int_uint_4 = OpTypePointer Workgroup %_arr_int_uint_4
-%src_workgroup = OpVariable %_ptr_Workgroup__arr_int_uint_4 Workgroup
- %S = OpTypeStruct %_arr_int_uint_4
+%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4
+%_ptr_Private__arr_v4int_uint_4 = OpTypePointer Private %_arr_v4int_uint_4
+ %8 = OpConstantNull %_arr_v4int_uint_4
+%src_private = OpVariable %_ptr_Private__arr_v4int_uint_4 Private %8
+%_ptr_Workgroup__arr_v4int_uint_4 = OpTypePointer Workgroup %_arr_v4int_uint_4
+%src_workgroup = OpVariable %_ptr_Workgroup__arr_v4int_uint_4 Workgroup
+ %S = OpTypeStruct %_arr_v4int_uint_4
%_ptr_Uniform_S = OpTypePointer Uniform %S
%src_uniform = OpVariable %_ptr_Uniform_S Uniform
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
@@ -65,71 +66,74 @@
%_ptr_StorageBuffer_S_nested = OpTypePointer StorageBuffer %S_nested
%dst_nested = OpVariable %_ptr_StorageBuffer_S_nested StorageBuffer
%void = OpTypeVoid
- %24 = OpTypeFunction %void
- %28 = OpTypeFunction %_arr_int_uint_4
- %31 = OpTypeFunction %S
- %34 = OpConstantNull %S
- %35 = OpTypeFunction %void %_arr_int_uint_4
-%_ptr_Function__arr_int_uint_4 = OpTypePointer Function %_arr_int_uint_4
+ %25 = OpTypeFunction %void
+ %29 = OpTypeFunction %_arr_v4int_uint_4
+ %32 = OpTypeFunction %S
+ %35 = OpConstantNull %S
+ %36 = OpTypeFunction %void %_arr_v4int_uint_4
+%_ptr_Function__arr_v4int_uint_4 = OpTypePointer Function %_arr_v4int_uint_4
%uint_0 = OpConstant %uint 0
-%_ptr_StorageBuffer__arr_int_uint_4 = OpTypePointer StorageBuffer %_arr_int_uint_4
+%_ptr_StorageBuffer__arr_v4int_uint_4 = OpTypePointer StorageBuffer %_arr_v4int_uint_4
%int_1 = OpConstant %int 1
+ %46 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%int_2 = OpConstant %int 2
+ %48 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%int_3 = OpConstant %int 3
- %47 = OpConstantComposite %_arr_int_uint_4 %int_1 %int_2 %int_3 %int_3
-%_ptr_Uniform__arr_int_uint_4 = OpTypePointer Uniform %_arr_int_uint_4
+ %50 = OpConstantComposite %v4int %int_3 %int_3 %int_3 %int_3
+ %51 = OpConstantComposite %_arr_v4int_uint_4 %46 %48 %50 %50
+%_ptr_Uniform__arr_v4int_uint_4 = OpTypePointer Uniform %_arr_v4int_uint_4
%_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypePointer Function %_arr__arr__arr_int_uint_2_uint_3_uint_4
- %70 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
+ %74 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
%_ptr_StorageBuffer__arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypePointer StorageBuffer %_arr__arr__arr_int_uint_2_uint_3_uint_4
-%unused_entry_point = OpFunction %void None %24
- %27 = OpLabel
+%unused_entry_point = OpFunction %void None %25
+ %28 = OpLabel
OpReturn
OpFunctionEnd
- %ret_arr = OpFunction %_arr_int_uint_4 None %28
- %30 = OpLabel
- OpReturnValue %7
+ %ret_arr = OpFunction %_arr_v4int_uint_4 None %29
+ %31 = OpLabel
+ OpReturnValue %8
OpFunctionEnd
-%ret_struct_arr = OpFunction %S None %31
- %33 = OpLabel
- OpReturnValue %34
+%ret_struct_arr = OpFunction %S None %32
+ %34 = OpLabel
+ OpReturnValue %35
OpFunctionEnd
- %foo = OpFunction %void None %35
- %src_param = OpFunctionParameter %_arr_int_uint_4
- %38 = OpLabel
-%src_function = OpVariable %_ptr_Function__arr_int_uint_4 Function %7
- %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %70
- %43 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- OpStore %43 %47
- %48 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- OpStore %48 %src_param
- %49 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- %50 = OpFunctionCall %_arr_int_uint_4 %ret_arr
- OpStore %49 %50
- %51 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- OpStore %51 %7
- %52 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- %53 = OpLoad %_arr_int_uint_4 %src_function
- OpStore %52 %53
- %54 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- %55 = OpLoad %_arr_int_uint_4 %src_private
- OpStore %54 %55
- %56 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- %57 = OpLoad %_arr_int_uint_4 %src_workgroup
+ %foo = OpFunction %void None %36
+ %src_param = OpFunctionParameter %_arr_v4int_uint_4
+ %39 = OpLabel
+%src_function = OpVariable %_ptr_Function__arr_v4int_uint_4 Function %8
+ %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %74
+ %44 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ OpStore %44 %51
+ %52 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ OpStore %52 %src_param
+ %53 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ %54 = OpFunctionCall %_arr_v4int_uint_4 %ret_arr
+ OpStore %53 %54
+ %55 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ OpStore %55 %8
+ %56 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ %57 = OpLoad %_arr_v4int_uint_4 %src_function
OpStore %56 %57
- %58 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- %59 = OpFunctionCall %S %ret_struct_arr
- %60 = OpCompositeExtract %_arr_int_uint_4 %59 0
- OpStore %58 %60
- %61 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- %63 = OpAccessChain %_ptr_Uniform__arr_int_uint_4 %src_uniform %uint_0
- %64 = OpLoad %_arr_int_uint_4 %63
- OpStore %61 %64
- %65 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %dst %uint_0
- %66 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %src_storage %uint_0
- %67 = OpLoad %_arr_int_uint_4 %66
- OpStore %65 %67
- %72 = OpAccessChain %_ptr_StorageBuffer__arr__arr__arr_int_uint_2_uint_3_uint_4 %dst_nested %uint_0
- %73 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
- OpStore %72 %73
+ %58 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ %59 = OpLoad %_arr_v4int_uint_4 %src_private
+ OpStore %58 %59
+ %60 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ %61 = OpLoad %_arr_v4int_uint_4 %src_workgroup
+ OpStore %60 %61
+ %62 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ %63 = OpFunctionCall %S %ret_struct_arr
+ %64 = OpCompositeExtract %_arr_v4int_uint_4 %63 0
+ OpStore %62 %64
+ %65 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ %67 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %src_uniform %uint_0
+ %68 = OpLoad %_arr_v4int_uint_4 %67
+ OpStore %65 %68
+ %69 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %dst %uint_0
+ %70 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %src_storage %uint_0
+ %71 = OpLoad %_arr_v4int_uint_4 %70
+ OpStore %69 %71
+ %76 = OpAccessChain %_ptr_StorageBuffer__arr__arr__arr_int_uint_2_uint_3_uint_4 %dst_nested %uint_0
+ %77 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
+ OpStore %76 %77
OpReturn
OpFunctionEnd
diff --git a/test/array/assign_to_storage_var.wgsl.expected.wgsl b/test/array/assign_to_storage_var.wgsl.expected.wgsl
index 88902fa..fe47458 100644
--- a/test/array/assign_to_storage_var.wgsl.expected.wgsl
+++ b/test/array/assign_to_storage_var.wgsl.expected.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -30,7 +30,7 @@
fn foo(src_param : ArrayType) {
var src_function : ArrayType;
- dst.arr = ArrayType(1, 2, 3, 3);
+ dst.arr = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
dst.arr = src_param;
dst.arr = ret_arr();
let src_let : ArrayType = ArrayType();
diff --git a/test/array/assign_to_workgroup_var.wgsl b/test/array/assign_to_workgroup_var.wgsl
index 9fb94eb..1615348 100644
--- a/test/array/assign_to_workgroup_var.wgsl
+++ b/test/array/assign_to_workgroup_var.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -24,7 +24,7 @@
var src_function : ArrayType;
// Assign from type constructor.
- dst = ArrayType(1, 2, 3, 3);
+ dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
// Assign from parameter.
dst = src_param;
diff --git a/test/array/assign_to_workgroup_var.wgsl.expected.hlsl b/test/array/assign_to_workgroup_var.wgsl.expected.hlsl
index b60b974..4243ec1 100644
--- a/test/array/assign_to_workgroup_var.wgsl.expected.hlsl
+++ b/test/array/assign_to_workgroup_var.wgsl.expected.hlsl
@@ -3,25 +3,22 @@
return;
}
-struct tint_padded_array_element {
- int el;
-};
struct S {
- tint_padded_array_element arr[4];
+ int4 arr[4];
};
-static tint_padded_array_element src_private[4] = (tint_padded_array_element[4])0;
-groupshared tint_padded_array_element src_workgroup[4];
+static int4 src_private[4] = (int4[4])0;
+groupshared int4 src_workgroup[4];
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
};
RWByteAddressBuffer src_storage : register(u1, space0);
-groupshared tint_padded_array_element tint_symbol[4];
+groupshared int4 tint_symbol[4];
groupshared int dst_nested[4][3][2];
-typedef tint_padded_array_element ret_arr_ret[4];
+typedef int4 ret_arr_ret[4];
ret_arr_ret ret_arr() {
- const tint_padded_array_element tint_symbol_5[4] = (tint_padded_array_element[4])0;
+ const int4 tint_symbol_5[4] = (int4[4])0;
return tint_symbol_5;
}
@@ -30,36 +27,36 @@
return tint_symbol_6;
}
-typedef tint_padded_array_element tint_symbol_1_ret[4];
+typedef int4 tint_symbol_1_ret[4];
tint_symbol_1_ret tint_symbol_1(uint4 buffer[4], uint offset) {
- tint_padded_array_element arr_1[4] = (tint_padded_array_element[4])0;
+ int4 arr_1[4] = (int4[4])0;
{
[loop] for(uint i = 0u; (i < 4u); i = (i + 1u)) {
const uint scalar_offset = ((offset + (i * 16u))) / 4;
- arr_1[i].el = asint(buffer[scalar_offset / 4][scalar_offset % 4]);
+ arr_1[i] = asint(buffer[scalar_offset / 4]);
}
}
return arr_1;
}
-typedef tint_padded_array_element tint_symbol_3_ret[4];
+typedef int4 tint_symbol_3_ret[4];
tint_symbol_3_ret tint_symbol_3(RWByteAddressBuffer buffer, uint offset) {
- tint_padded_array_element arr_2[4] = (tint_padded_array_element[4])0;
+ int4 arr_2[4] = (int4[4])0;
{
[loop] for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
- arr_2[i_1].el = asint(buffer.Load((offset + (i_1 * 16u))));
+ arr_2[i_1] = asint(buffer.Load4((offset + (i_1 * 16u))));
}
}
return arr_2;
}
-void foo(tint_padded_array_element src_param[4]) {
- tint_padded_array_element src_function[4] = (tint_padded_array_element[4])0;
- const tint_padded_array_element tint_symbol_7[4] = {{1}, {2}, {3}, {3}};
+void foo(int4 src_param[4]) {
+ int4 src_function[4] = (int4[4])0;
+ const int4 tint_symbol_7[4] = {int4((1).xxxx), int4((2).xxxx), int4((3).xxxx), int4((3).xxxx)};
tint_symbol = tint_symbol_7;
tint_symbol = src_param;
tint_symbol = ret_arr();
- const tint_padded_array_element src_let[4] = (tint_padded_array_element[4])0;
+ const int4 src_let[4] = (int4[4])0;
tint_symbol = src_let;
tint_symbol = src_function;
tint_symbol = src_private;
diff --git a/test/array/assign_to_workgroup_var.wgsl.expected.msl b/test/array/assign_to_workgroup_var.wgsl.expected.msl
index 0511506..2c45f26 100644
--- a/test/array/assign_to_workgroup_var.wgsl.expected.msl
+++ b/test/array/assign_to_workgroup_var.wgsl.expected.msl
@@ -1,12 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-struct tint_padded_array_element {
- /* 0x0000 */ int el;
- /* 0x0004 */ int8_t tint_pad[12];
-};
struct tint_array_wrapper {
- /* 0x0000 */ tint_padded_array_element arr[4];
+ /* 0x0000 */ int4 arr[4];
};
struct S {
/* 0x0000 */ tint_array_wrapper arr;
@@ -33,7 +29,7 @@
void foo(tint_array_wrapper src_param, threadgroup tint_array_wrapper* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7, threadgroup tint_array_wrapper_1* const tint_symbol_8) {
tint_array_wrapper src_function = {};
- tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
+ tint_array_wrapper const tint_symbol_2 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
*(tint_symbol_3) = tint_symbol_2;
*(tint_symbol_3) = src_param;
*(tint_symbol_3) = ret_arr();
diff --git a/test/array/assign_to_workgroup_var.wgsl.expected.spvasm b/test/array/assign_to_workgroup_var.wgsl.expected.spvasm
index 5f46701..a834fb2 100644
--- a/test/array/assign_to_workgroup_var.wgsl.expected.spvasm
+++ b/test/array/assign_to_workgroup_var.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 61
+; Bound: 65
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -22,7 +22,7 @@
OpName %src_param "src_param"
OpName %src_function "src_function"
OpName %src_nested "src_nested"
- OpDecorate %_arr_int_uint_4 ArrayStride 16
+ OpDecorate %_arr_v4int_uint_4 ArrayStride 16
OpDecorate %S Block
OpMemberDecorate %S 0 Offset 0
OpDecorate %src_uniform NonWritable
@@ -34,20 +34,21 @@
OpDecorate %_arr__arr_int_uint_2_uint_3 ArrayStride 8
OpDecorate %_arr__arr__arr_int_uint_2_uint_3_uint_4 ArrayStride 24
%int = OpTypeInt 32 1
+ %v4int = OpTypeVector %int 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
-%_arr_int_uint_4 = OpTypeArray %int %uint_4
-%_ptr_Private__arr_int_uint_4 = OpTypePointer Private %_arr_int_uint_4
- %7 = OpConstantNull %_arr_int_uint_4
-%src_private = OpVariable %_ptr_Private__arr_int_uint_4 Private %7
-%_ptr_Workgroup__arr_int_uint_4 = OpTypePointer Workgroup %_arr_int_uint_4
-%src_workgroup = OpVariable %_ptr_Workgroup__arr_int_uint_4 Workgroup
- %S = OpTypeStruct %_arr_int_uint_4
+%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4
+%_ptr_Private__arr_v4int_uint_4 = OpTypePointer Private %_arr_v4int_uint_4
+ %8 = OpConstantNull %_arr_v4int_uint_4
+%src_private = OpVariable %_ptr_Private__arr_v4int_uint_4 Private %8
+%_ptr_Workgroup__arr_v4int_uint_4 = OpTypePointer Workgroup %_arr_v4int_uint_4
+%src_workgroup = OpVariable %_ptr_Workgroup__arr_v4int_uint_4 Workgroup
+ %S = OpTypeStruct %_arr_v4int_uint_4
%_ptr_Uniform_S = OpTypePointer Uniform %S
%src_uniform = OpVariable %_ptr_Uniform_S Uniform
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
%src_storage = OpVariable %_ptr_StorageBuffer_S StorageBuffer
- %dst = OpVariable %_ptr_Workgroup__arr_int_uint_4 Workgroup
+ %dst = OpVariable %_ptr_Workgroup__arr_v4int_uint_4 Workgroup
%uint_2 = OpConstant %uint 2
%_arr_int_uint_2 = OpTypeArray %int %uint_2
%uint_3 = OpConstant %uint 3
@@ -56,59 +57,62 @@
%_ptr_Workgroup__arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypePointer Workgroup %_arr__arr__arr_int_uint_2_uint_3_uint_4
%dst_nested = OpVariable %_ptr_Workgroup__arr__arr__arr_int_uint_2_uint_3_uint_4 Workgroup
%void = OpTypeVoid
- %23 = OpTypeFunction %void
- %27 = OpTypeFunction %_arr_int_uint_4
- %30 = OpTypeFunction %S
- %33 = OpConstantNull %S
- %34 = OpTypeFunction %void %_arr_int_uint_4
-%_ptr_Function__arr_int_uint_4 = OpTypePointer Function %_arr_int_uint_4
+ %24 = OpTypeFunction %void
+ %28 = OpTypeFunction %_arr_v4int_uint_4
+ %31 = OpTypeFunction %S
+ %34 = OpConstantNull %S
+ %35 = OpTypeFunction %void %_arr_v4int_uint_4
+%_ptr_Function__arr_v4int_uint_4 = OpTypePointer Function %_arr_v4int_uint_4
%int_1 = OpConstant %int 1
+ %42 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%int_2 = OpConstant %int 2
+ %44 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%int_3 = OpConstant %int 3
- %43 = OpConstantComposite %_arr_int_uint_4 %int_1 %int_2 %int_3 %int_3
+ %46 = OpConstantComposite %v4int %int_3 %int_3 %int_3 %int_3
+ %47 = OpConstantComposite %_arr_v4int_uint_4 %42 %44 %46 %46
%uint_0 = OpConstant %uint 0
-%_ptr_Uniform__arr_int_uint_4 = OpTypePointer Uniform %_arr_int_uint_4
-%_ptr_StorageBuffer__arr_int_uint_4 = OpTypePointer StorageBuffer %_arr_int_uint_4
+%_ptr_Uniform__arr_v4int_uint_4 = OpTypePointer Uniform %_arr_v4int_uint_4
+%_ptr_StorageBuffer__arr_v4int_uint_4 = OpTypePointer StorageBuffer %_arr_v4int_uint_4
%_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 = OpTypePointer Function %_arr__arr__arr_int_uint_2_uint_3_uint_4
- %59 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
-%unused_entry_point = OpFunction %void None %23
- %26 = OpLabel
+ %63 = OpConstantNull %_arr__arr__arr_int_uint_2_uint_3_uint_4
+%unused_entry_point = OpFunction %void None %24
+ %27 = OpLabel
OpReturn
OpFunctionEnd
- %ret_arr = OpFunction %_arr_int_uint_4 None %27
- %29 = OpLabel
- OpReturnValue %7
+ %ret_arr = OpFunction %_arr_v4int_uint_4 None %28
+ %30 = OpLabel
+ OpReturnValue %8
OpFunctionEnd
-%ret_struct_arr = OpFunction %S None %30
- %32 = OpLabel
- OpReturnValue %33
+%ret_struct_arr = OpFunction %S None %31
+ %33 = OpLabel
+ OpReturnValue %34
OpFunctionEnd
- %foo = OpFunction %void None %34
- %src_param = OpFunctionParameter %_arr_int_uint_4
- %37 = OpLabel
-%src_function = OpVariable %_ptr_Function__arr_int_uint_4 Function %7
- %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %59
- OpStore %dst %43
- OpStore %dst %src_param
- %44 = OpFunctionCall %_arr_int_uint_4 %ret_arr
- OpStore %dst %44
- OpStore %dst %7
- %45 = OpLoad %_arr_int_uint_4 %src_function
- OpStore %dst %45
- %46 = OpLoad %_arr_int_uint_4 %src_private
- OpStore %dst %46
- %47 = OpLoad %_arr_int_uint_4 %src_workgroup
+ %foo = OpFunction %void None %35
+ %src_param = OpFunctionParameter %_arr_v4int_uint_4
+ %38 = OpLabel
+%src_function = OpVariable %_ptr_Function__arr_v4int_uint_4 Function %8
+ %src_nested = OpVariable %_ptr_Function__arr__arr__arr_int_uint_2_uint_3_uint_4 Function %63
OpStore %dst %47
- %48 = OpFunctionCall %S %ret_struct_arr
- %49 = OpCompositeExtract %_arr_int_uint_4 %48 0
+ OpStore %dst %src_param
+ %48 = OpFunctionCall %_arr_v4int_uint_4 %ret_arr
+ OpStore %dst %48
+ OpStore %dst %8
+ %49 = OpLoad %_arr_v4int_uint_4 %src_function
OpStore %dst %49
- %52 = OpAccessChain %_ptr_Uniform__arr_int_uint_4 %src_uniform %uint_0
- %53 = OpLoad %_arr_int_uint_4 %52
+ %50 = OpLoad %_arr_v4int_uint_4 %src_private
+ OpStore %dst %50
+ %51 = OpLoad %_arr_v4int_uint_4 %src_workgroup
+ OpStore %dst %51
+ %52 = OpFunctionCall %S %ret_struct_arr
+ %53 = OpCompositeExtract %_arr_v4int_uint_4 %52 0
OpStore %dst %53
- %55 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_4 %src_storage %uint_0
- %56 = OpLoad %_arr_int_uint_4 %55
- OpStore %dst %56
- %60 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
- OpStore %dst_nested %60
+ %56 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %src_uniform %uint_0
+ %57 = OpLoad %_arr_v4int_uint_4 %56
+ OpStore %dst %57
+ %59 = OpAccessChain %_ptr_StorageBuffer__arr_v4int_uint_4 %src_storage %uint_0
+ %60 = OpLoad %_arr_v4int_uint_4 %59
+ OpStore %dst %60
+ %64 = OpLoad %_arr__arr__arr_int_uint_2_uint_3_uint_4 %src_nested
+ OpStore %dst_nested %64
OpReturn
OpFunctionEnd
diff --git a/test/array/assign_to_workgroup_var.wgsl.expected.wgsl b/test/array/assign_to_workgroup_var.wgsl.expected.wgsl
index 4fecbc8..6888710 100644
--- a/test/array/assign_to_workgroup_var.wgsl.expected.wgsl
+++ b/test/array/assign_to_workgroup_var.wgsl.expected.wgsl
@@ -1,4 +1,4 @@
-type ArrayType = @stride(16) array<i32, 4>;
+type ArrayType = array<vec4<i32>, 4>;
struct S {
arr : ArrayType;
@@ -26,7 +26,7 @@
fn foo(src_param : ArrayType) {
var src_function : ArrayType;
- dst = ArrayType(1, 2, 3, 3);
+ dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3));
dst = src_param;
dst = ret_arr();
let src_let : ArrayType = ArrayType();