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>
This commit is contained in:
James Price
2022-01-20 22:11:07 +00:00
parent e04d0f40de
commit f6e5cc03bf
71 changed files with 575 additions and 512 deletions

View File

@@ -12,7 +12,7 @@ struct S {
g : mat2x3<f32>;
h : mat3x2<f32>;
i : Inner;
j : @stride(16) array<Inner, 4>;
j : array<Inner, 4>;
};
@binding(0) @group(0) var<storage, read> s : S;

View File

@@ -4,9 +4,6 @@ precision mediump float;
struct Inner {
int x;
};
struct tint_padded_array_element {
Inner el;
};
struct S {
ivec3 a;
int b;
@@ -17,7 +14,7 @@ struct S {
mat2x3 g;
mat3x2 h;
Inner i;
tint_padded_array_element j[4];
Inner j[4];
};
layout (binding = 0) buffer S_1 {
@@ -30,7 +27,7 @@ layout (binding = 0) buffer S_1 {
mat2x3 g;
mat3x2 h;
Inner i;
tint_padded_array_element j[4];
Inner j[4];
} s;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
@@ -44,7 +41,7 @@ void tint_symbol() {
mat2x3 g = s.g;
mat3x2 h = s.h;
Inner i = s.i;
tint_padded_array_element j[4] = s.j;
Inner j[4] = s.j;
return;
}
void main() {

View File

@@ -1,9 +1,6 @@
struct Inner {
int x;
};
struct tint_padded_array_element {
Inner el;
};
ByteAddressBuffer s : register(t0, space0);
@@ -20,12 +17,12 @@ Inner tint_symbol_9(ByteAddressBuffer buffer, uint offset) {
return tint_symbol_11;
}
typedef tint_padded_array_element tint_symbol_10_ret[4];
typedef Inner tint_symbol_10_ret[4];
tint_symbol_10_ret tint_symbol_10(ByteAddressBuffer buffer, uint offset) {
tint_padded_array_element arr[4] = (tint_padded_array_element[4])0;
Inner arr[4] = (Inner[4])0;
{
[loop] for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
arr[i_1].el = tint_symbol_9(buffer, (offset + (i_1 * 16u)));
arr[i_1] = tint_symbol_9(buffer, (offset + (i_1 * 4u)));
}
}
return arr;
@@ -42,6 +39,6 @@ void main() {
const float2x3 g = tint_symbol_6(s, 48u);
const float3x2 h = tint_symbol_7(s, 80u);
const Inner i = tint_symbol_9(s, 104u);
const tint_padded_array_element j[4] = tint_symbol_10(s, 108u);
const Inner j[4] = tint_symbol_10(s, 108u);
return;
}

View File

@@ -15,12 +15,8 @@ inline vec<T, N> operator*(packed_vec<T, M> lhs, matrix<T, N, M> rhs) {
struct Inner {
/* 0x0000 */ int x;
};
struct tint_padded_array_element {
/* 0x0000 */ Inner el;
/* 0x0004 */ int8_t tint_pad[12];
};
struct tint_array_wrapper {
/* 0x0000 */ tint_padded_array_element arr[4];
/* 0x0000 */ Inner arr[4];
};
struct S {
/* 0x0000 */ packed_int3 a;
@@ -33,7 +29,7 @@ struct S {
/* 0x0050 */ float3x2 h;
/* 0x0068 */ Inner i;
/* 0x006c */ tint_array_wrapper j;
/* 0x00ac */ int8_t tint_pad_1[4];
/* 0x007c */ int8_t tint_pad[4];
};
kernel void tint_symbol(const device S* tint_symbol_1 [[buffer(0)]]) {

View File

@@ -38,7 +38,7 @@
OpMemberDecorate %S 8 Offset 104
OpMemberDecorate %Inner 0 Offset 0
OpMemberDecorate %S 9 Offset 108
OpDecorate %_arr_Inner_uint_4 ArrayStride 16
OpDecorate %_arr_Inner_uint_4 ArrayStride 4
OpDecorate %s NonWritable
OpDecorate %s Binding 0
OpDecorate %s DescriptorSet 0

View File

@@ -12,7 +12,7 @@ struct S {
g : mat2x3<f32>;
h : mat3x2<f32>;
i : Inner;
j : @stride(16) array<Inner, 4>;
j : array<Inner, 4>;
}
@binding(0) @group(0) var<storage, read> s : S;

View File

@@ -12,7 +12,7 @@ struct S {
g : mat2x3<f32>;
h : mat3x2<f32>;
i : Inner;
j : @stride(16) array<Inner, 4>;
j : array<Inner, 4>;
};
@binding(0) @group(0) var<storage, write> s : S;
@@ -28,5 +28,5 @@ fn main() {
s.g = mat2x3<f32>();
s.h = mat3x2<f32>();
s.i = Inner();
s.j = @stride(16) array<Inner, 4>();
s.j = array<Inner, 4>();
}

View File

@@ -4,9 +4,6 @@ precision mediump float;
struct Inner {
int x;
};
struct tint_padded_array_element {
Inner el;
};
struct S {
ivec3 a;
int b;
@@ -17,7 +14,7 @@ struct S {
mat2x3 g;
mat3x2 h;
Inner i;
tint_padded_array_element j[4];
Inner j[4];
};
layout (binding = 0) buffer S_1 {
@@ -30,7 +27,7 @@ layout (binding = 0) buffer S_1 {
mat2x3 g;
mat3x2 h;
Inner i;
tint_padded_array_element j[4];
Inner j[4];
} s;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
@@ -45,7 +42,7 @@ void tint_symbol() {
s.h = mat3x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
Inner tint_symbol_1 = Inner(0);
s.i = tint_symbol_1;
tint_padded_array_element tint_symbol_2[4] = tint_padded_array_element[4](tint_padded_array_element(Inner(0)), tint_padded_array_element(Inner(0)), tint_padded_array_element(Inner(0)), tint_padded_array_element(Inner(0)));
Inner tint_symbol_2[4] = Inner[4](Inner(0), Inner(0), Inner(0), Inner(0));
s.j = tint_symbol_2;
return;
}

View File

@@ -1,9 +1,6 @@
struct Inner {
int x;
};
struct tint_padded_array_element {
Inner el;
};
RWByteAddressBuffer s : register(u0, space0);
@@ -22,11 +19,11 @@ void tint_symbol_9(RWByteAddressBuffer buffer, uint offset, Inner value) {
buffer.Store((offset + 0u), asuint(value.x));
}
void tint_symbol_10(RWByteAddressBuffer buffer, uint offset, tint_padded_array_element value[4]) {
tint_padded_array_element array[4] = value;
void tint_symbol_10(RWByteAddressBuffer buffer, uint offset, Inner value[4]) {
Inner array[4] = value;
{
[loop] for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
tint_symbol_9(buffer, (offset + (i_1 * 16u)), array[i_1].el);
tint_symbol_9(buffer, (offset + (i_1 * 4u)), array[i_1]);
}
}
}
@@ -43,7 +40,7 @@ void main() {
tint_symbol_7(s, 80u, float3x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
const Inner tint_symbol_11 = (Inner)0;
tint_symbol_9(s, 104u, tint_symbol_11);
const tint_padded_array_element tint_symbol_12[4] = (tint_padded_array_element[4])0;
const Inner tint_symbol_12[4] = (Inner[4])0;
tint_symbol_10(s, 108u, tint_symbol_12);
return;
}

View File

@@ -15,12 +15,8 @@ inline vec<T, N> operator*(packed_vec<T, M> lhs, matrix<T, N, M> rhs) {
struct Inner {
/* 0x0000 */ int x;
};
struct tint_padded_array_element {
/* 0x0000 */ Inner el;
/* 0x0004 */ int8_t tint_pad[12];
};
struct tint_array_wrapper {
/* 0x0000 */ tint_padded_array_element arr[4];
/* 0x0000 */ Inner arr[4];
};
struct S {
/* 0x0000 */ packed_int3 a;
@@ -33,7 +29,7 @@ struct S {
/* 0x0050 */ float3x2 h;
/* 0x0068 */ Inner i;
/* 0x006c */ tint_array_wrapper j;
/* 0x00ac */ int8_t tint_pad_1[4];
/* 0x007c */ int8_t tint_pad[4];
};
kernel void tint_symbol(device S* tint_symbol_3 [[buffer(0)]]) {

View File

@@ -38,7 +38,7 @@
OpMemberDecorate %S 8 Offset 104
OpMemberDecorate %Inner 0 Offset 0
OpMemberDecorate %S 9 Offset 108
OpDecorate %_arr_Inner_uint_4 ArrayStride 16
OpDecorate %_arr_Inner_uint_4 ArrayStride 4
OpDecorate %s NonReadable
OpDecorate %s Binding 0
OpDecorate %s DescriptorSet 0

View File

@@ -12,7 +12,7 @@ struct S {
g : mat2x3<f32>;
h : mat3x2<f32>;
i : Inner;
j : @stride(16) array<Inner, 4>;
j : array<Inner, 4>;
}
@binding(0) @group(0) var<storage, write> s : S;
@@ -28,5 +28,5 @@ fn main() {
s.g = mat2x3<f32>();
s.h = mat3x2<f32>();
s.i = Inner();
s.j = @stride(16) array<Inner, 4>();
s.j = array<Inner, 4>();
}