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

@@ -1,5 +1,5 @@
struct UBO {
data: @stride(16) array<i32, 4>;
data: array<vec4<i32>, 4>;
dynamic_idx: i32;
};
@group(0) @binding(0) var<uniform> ubo: UBO;
@@ -10,5 +10,5 @@ struct Result {
@stage(compute) @workgroup_size(1)
fn f() {
result.out = ubo.data[ubo.dynamic_idx];
result.out = ubo.data[ubo.dynamic_idx].x;
}

View File

@@ -1,16 +1,13 @@
#version 310 es
precision mediump float;
struct tint_padded_array_element {
int el;
};
struct UBO {
tint_padded_array_element data[4];
ivec4 data[4];
int dynamic_idx;
};
layout (binding = 0) uniform UBO_1 {
tint_padded_array_element data[4];
ivec4 data[4];
int dynamic_idx;
} ubo;
@@ -24,7 +21,7 @@ layout (binding = 2) buffer Result_1 {
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void f() {
result.tint_symbol = ubo.data[ubo.dynamic_idx].el;
result.tint_symbol = ubo.data[ubo.dynamic_idx].x;
return;
}
void main() {

View File

@@ -1,23 +1,20 @@
#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 UBO {
/* 0x0000 */ tint_array_wrapper data;
/* 0x0040 */ int dynamic_idx;
/* 0x0044 */ int8_t tint_pad[12];
};
struct Result {
/* 0x0000 */ int out;
};
kernel void f(device Result* tint_symbol [[buffer(1)]], const constant UBO* tint_symbol_1 [[buffer(0)]]) {
(*(tint_symbol)).out = (*(tint_symbol_1)).data.arr[(*(tint_symbol_1)).dynamic_idx].el;
(*(tint_symbol)).out = (*(tint_symbol_1)).data.arr[(*(tint_symbol_1)).dynamic_idx][0];
return;
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 24
; Bound: 25
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -17,7 +17,7 @@
OpName %f "f"
OpDecorate %UBO Block
OpMemberDecorate %UBO 0 Offset 0
OpDecorate %_arr_int_uint_4 ArrayStride 16
OpDecorate %_arr_v4int_uint_4 ArrayStride 16
OpMemberDecorate %UBO 1 Offset 64
OpDecorate %ubo NonWritable
OpDecorate %ubo DescriptorSet 0
@@ -27,28 +27,29 @@
OpDecorate %result DescriptorSet 0
OpDecorate %result Binding 2
%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
%UBO = OpTypeStruct %_arr_int_uint_4 %int
%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4
%UBO = OpTypeStruct %_arr_v4int_uint_4 %int
%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO
%ubo = OpVariable %_ptr_Uniform_UBO Uniform
%Result = OpTypeStruct %int
%_ptr_StorageBuffer_Result = OpTypePointer StorageBuffer %Result
%result = OpVariable %_ptr_StorageBuffer_Result StorageBuffer
%void = OpTypeVoid
%11 = OpTypeFunction %void
%12 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
%uint_1 = OpConstant %uint 1
%_ptr_Uniform_int = OpTypePointer Uniform %int
%f = OpFunction %void None %11
%14 = OpLabel
%17 = OpAccessChain %_ptr_StorageBuffer_int %result %uint_0
%20 = OpAccessChain %_ptr_Uniform_int %ubo %uint_1
%21 = OpLoad %int %20
%22 = OpAccessChain %_ptr_Uniform_int %ubo %uint_0 %21
%23 = OpLoad %int %22
OpStore %17 %23
%f = OpFunction %void None %12
%15 = OpLabel
%18 = OpAccessChain %_ptr_StorageBuffer_int %result %uint_0
%21 = OpAccessChain %_ptr_Uniform_int %ubo %uint_1
%22 = OpLoad %int %21
%23 = OpAccessChain %_ptr_Uniform_int %ubo %uint_0 %22 %uint_0
%24 = OpLoad %int %23
OpStore %18 %24
OpReturn
OpFunctionEnd

View File

@@ -1,5 +1,5 @@
struct UBO {
data : @stride(16) array<i32, 4>;
data : array<vec4<i32>, 4>;
dynamic_idx : i32;
}
@@ -13,5 +13,5 @@ struct Result {
@stage(compute) @workgroup_size(1)
fn f() {
result.out = ubo.data[ubo.dynamic_idx];
result.out = ubo.data[ubo.dynamic_idx].x;
}