tint: Add and use new Std140 transform

This transform breaks up matNx2<f32> matrices used in uniform buffers
into column vectors, which fixes std140 layout rules.

Used by the SPIR-V and GLSL backends.

Re-enable tests that were disabled for these cases.

Bug: tint:1632
Change-Id: I596d016582b4189a0b413d762b3e7eabd3504b22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100907
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton
2022-09-01 22:12:19 +00:00
committed by Dawn LUCI CQ
parent 644d23b3f8
commit 657e61d43d
166 changed files with 13544 additions and 274 deletions

View File

@@ -14,14 +14,39 @@ struct Inner {
ivec4 k[4];
};
struct Inner_std140 {
ivec3 a;
int b;
uvec3 c;
uint d;
vec3 e;
float f;
ivec2 g;
ivec2 h;
mat2x3 i;
vec2 j_0;
vec2 j_1;
vec2 j_2;
ivec4 k[4];
};
struct S {
Inner arr[8];
};
layout(binding = 0) uniform S_1 {
Inner arr[8];
struct S_std140 {
Inner_std140 arr[8];
};
layout(binding = 0) uniform S_std140_1 {
Inner_std140 arr[8];
} s;
mat3x2 load_s_arr_p0_j(uint p0) {
uint s_save = p0;
return mat3x2(s.arr[s_save].j_0, s.arr[s_save].j_1, s.arr[s_save].j_2);
}
void tint_symbol(uint idx) {
ivec3 a = s.arr[idx].a;
int b = s.arr[idx].b;
@@ -32,7 +57,7 @@ void tint_symbol(uint idx) {
ivec2 g = s.arr[idx].g;
ivec2 h = s.arr[idx].h;
mat2x3 i = s.arr[idx].i;
mat3x2 j = s.arr[idx].j;
mat3x2 j = load_s_arr_p0_j(uint(idx));
ivec4 k[4] = s.arr[idx].k;
}

View File

@@ -1,53 +1,55 @@
SKIP: FAILED
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 73
; Bound: 86
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %idx_1
OpExecutionMode %main LocalSize 1 1 1
OpName %idx_1 "idx_1"
OpName %S "S"
OpMemberName %S 0 "arr"
OpName %Inner "Inner"
OpMemberName %Inner 0 "a"
OpMemberName %Inner 1 "b"
OpMemberName %Inner 2 "c"
OpMemberName %Inner 3 "d"
OpMemberName %Inner 4 "e"
OpMemberName %Inner 5 "f"
OpMemberName %Inner 6 "g"
OpMemberName %Inner 7 "h"
OpMemberName %Inner 8 "i"
OpMemberName %Inner 9 "j"
OpMemberName %Inner 10 "k"
OpName %S_std140 "S_std140"
OpMemberName %S_std140 0 "arr"
OpName %Inner_std140 "Inner_std140"
OpMemberName %Inner_std140 0 "a"
OpMemberName %Inner_std140 1 "b"
OpMemberName %Inner_std140 2 "c"
OpMemberName %Inner_std140 3 "d"
OpMemberName %Inner_std140 4 "e"
OpMemberName %Inner_std140 5 "f"
OpMemberName %Inner_std140 6 "g"
OpMemberName %Inner_std140 7 "h"
OpMemberName %Inner_std140 8 "i"
OpMemberName %Inner_std140 9 "j_0"
OpMemberName %Inner_std140 10 "j_1"
OpMemberName %Inner_std140 11 "j_2"
OpMemberName %Inner_std140 12 "k"
OpName %s "s"
OpName %load_s_arr_p0_j "load_s_arr_p0_j"
OpName %p0 "p0"
OpName %main_inner "main_inner"
OpName %idx "idx"
OpName %main "main"
OpDecorate %idx_1 BuiltIn LocalInvocationIndex
OpDecorate %S Block
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %Inner 0 Offset 0
OpMemberDecorate %Inner 1 Offset 12
OpMemberDecorate %Inner 2 Offset 16
OpMemberDecorate %Inner 3 Offset 28
OpMemberDecorate %Inner 4 Offset 32
OpMemberDecorate %Inner 5 Offset 44
OpMemberDecorate %Inner 6 Offset 48
OpMemberDecorate %Inner 7 Offset 56
OpMemberDecorate %Inner 8 Offset 64
OpMemberDecorate %Inner 8 ColMajor
OpMemberDecorate %Inner 8 MatrixStride 16
OpMemberDecorate %Inner 9 Offset 96
OpMemberDecorate %Inner 9 ColMajor
OpMemberDecorate %Inner 9 MatrixStride 8
OpMemberDecorate %Inner 10 Offset 128
OpDecorate %S_std140 Block
OpMemberDecorate %S_std140 0 Offset 0
OpMemberDecorate %Inner_std140 0 Offset 0
OpMemberDecorate %Inner_std140 1 Offset 12
OpMemberDecorate %Inner_std140 2 Offset 16
OpMemberDecorate %Inner_std140 3 Offset 28
OpMemberDecorate %Inner_std140 4 Offset 32
OpMemberDecorate %Inner_std140 5 Offset 44
OpMemberDecorate %Inner_std140 6 Offset 48
OpMemberDecorate %Inner_std140 7 Offset 56
OpMemberDecorate %Inner_std140 8 Offset 64
OpMemberDecorate %Inner_std140 8 ColMajor
OpMemberDecorate %Inner_std140 8 MatrixStride 16
OpMemberDecorate %Inner_std140 9 Offset 96
OpMemberDecorate %Inner_std140 10 Offset 104
OpMemberDecorate %Inner_std140 11 Offset 112
OpMemberDecorate %Inner_std140 12 Offset 128
OpDecorate %_arr_v4int_uint_4 ArrayStride 16
OpDecorate %_arr_Inner_uint_8 ArrayStride 192
OpDecorate %_arr_Inner_std140_uint_8 ArrayStride 192
OpDecorate %s NonWritable
OpDecorate %s Binding 0
OpDecorate %s DescriptorSet 0
@@ -62,19 +64,24 @@ SKIP: FAILED
%v2int = OpTypeVector %int 2
%mat2v3float = OpTypeMatrix %v3float 2
%v2float = OpTypeVector %float 2
%mat3v2float = OpTypeMatrix %v2float 3
%v4int = OpTypeVector %int 4
%uint_4 = OpConstant %uint 4
%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4
%Inner = OpTypeStruct %v3int %int %v3uint %uint %v3float %float %v2int %v2int %mat2v3float %mat3v2float %_arr_v4int_uint_4
%Inner_std140 = OpTypeStruct %v3int %int %v3uint %uint %v3float %float %v2int %v2int %mat2v3float %v2float %v2float %v2float %_arr_v4int_uint_4
%uint_8 = OpConstant %uint 8
%_arr_Inner_uint_8 = OpTypeArray %Inner %uint_8
%S = OpTypeStruct %_arr_Inner_uint_8
%_ptr_Uniform_S = OpTypePointer Uniform %S
%s = OpVariable %_ptr_Uniform_S Uniform
%void = OpTypeVoid
%22 = OpTypeFunction %void %uint
%_arr_Inner_std140_uint_8 = OpTypeArray %Inner_std140 %uint_8
%S_std140 = OpTypeStruct %_arr_Inner_std140_uint_8
%_ptr_Uniform_S_std140 = OpTypePointer Uniform %S_std140
%s = OpVariable %_ptr_Uniform_S_std140 Uniform
%mat3v2float = OpTypeMatrix %v2float 3
%21 = OpTypeFunction %mat3v2float %uint
%uint_0 = OpConstant %uint 0
%uint_9 = OpConstant %uint 9
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%uint_10 = OpConstant %uint 10
%uint_11 = OpConstant %uint 11
%void = OpTypeVoid
%38 = OpTypeFunction %void %uint
%_ptr_Uniform_v3int = OpTypePointer Uniform %v3int
%uint_1 = OpConstant %uint 1
%_ptr_Uniform_int = OpTypePointer Uniform %int
@@ -89,44 +96,50 @@ SKIP: FAILED
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%uint_7 = OpConstant %uint 7
%_ptr_Uniform_mat2v3float = OpTypePointer Uniform %mat2v3float
%uint_9 = OpConstant %uint 9
%_ptr_Uniform_mat3v2float = OpTypePointer Uniform %mat3v2float
%uint_10 = OpConstant %uint 10
%uint_12 = OpConstant %uint 12
%_ptr_Uniform__arr_v4int_uint_4 = OpTypePointer Uniform %_arr_v4int_uint_4
%68 = OpTypeFunction %void
%main_inner = OpFunction %void None %22
%81 = OpTypeFunction %void
%load_s_arr_p0_j = OpFunction %mat3v2float None %21
%p0 = OpFunctionParameter %uint
%25 = OpLabel
%29 = OpAccessChain %_ptr_Uniform_v2float %s %uint_0 %p0 %uint_9
%30 = OpLoad %v2float %29
%32 = OpAccessChain %_ptr_Uniform_v2float %s %uint_0 %p0 %uint_10
%33 = OpLoad %v2float %32
%35 = OpAccessChain %_ptr_Uniform_v2float %s %uint_0 %p0 %uint_11
%36 = OpLoad %v2float %35
%37 = OpCompositeConstruct %mat3v2float %30 %33 %36
OpReturnValue %37
OpFunctionEnd
%main_inner = OpFunction %void None %38
%idx = OpFunctionParameter %uint
%26 = OpLabel
%29 = OpAccessChain %_ptr_Uniform_v3int %s %uint_0 %idx %uint_0
%30 = OpLoad %v3int %29
%33 = OpAccessChain %_ptr_Uniform_int %s %uint_0 %idx %uint_1
%34 = OpLoad %int %33
%37 = OpAccessChain %_ptr_Uniform_v3uint %s %uint_0 %idx %uint_2
%38 = OpLoad %v3uint %37
%41 = OpAccessChain %_ptr_Uniform_uint %s %uint_0 %idx %uint_3
%42 = OpLoad %uint %41
%44 = OpAccessChain %_ptr_Uniform_v3float %s %uint_0 %idx %uint_4
%45 = OpLoad %v3float %44
%48 = OpAccessChain %_ptr_Uniform_float %s %uint_0 %idx %uint_5
%49 = OpLoad %float %48
%52 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %idx %uint_6
%53 = OpLoad %v2int %52
%55 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %idx %uint_7
%56 = OpLoad %v2int %55
%58 = OpAccessChain %_ptr_Uniform_mat2v3float %s %uint_0 %idx %uint_8
%59 = OpLoad %mat2v3float %58
%62 = OpAccessChain %_ptr_Uniform_mat3v2float %s %uint_0 %idx %uint_9
%63 = OpLoad %mat3v2float %62
%66 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %s %uint_0 %idx %uint_10
%67 = OpLoad %_arr_v4int_uint_4 %66
%42 = OpLabel
%44 = OpAccessChain %_ptr_Uniform_v3int %s %uint_0 %idx %uint_0
%45 = OpLoad %v3int %44
%48 = OpAccessChain %_ptr_Uniform_int %s %uint_0 %idx %uint_1
%49 = OpLoad %int %48
%52 = OpAccessChain %_ptr_Uniform_v3uint %s %uint_0 %idx %uint_2
%53 = OpLoad %v3uint %52
%56 = OpAccessChain %_ptr_Uniform_uint %s %uint_0 %idx %uint_3
%57 = OpLoad %uint %56
%59 = OpAccessChain %_ptr_Uniform_v3float %s %uint_0 %idx %uint_4
%60 = OpLoad %v3float %59
%63 = OpAccessChain %_ptr_Uniform_float %s %uint_0 %idx %uint_5
%64 = OpLoad %float %63
%67 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %idx %uint_6
%68 = OpLoad %v2int %67
%70 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %idx %uint_7
%71 = OpLoad %v2int %70
%73 = OpAccessChain %_ptr_Uniform_mat2v3float %s %uint_0 %idx %uint_8
%74 = OpLoad %mat2v3float %73
%75 = OpFunctionCall %mat3v2float %load_s_arr_p0_j %idx
%79 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %s %uint_0 %idx %uint_12
%80 = OpLoad %_arr_v4int_uint_4 %79
OpReturn
OpFunctionEnd
%main = OpFunction %void None %68
%70 = OpLabel
%72 = OpLoad %uint %idx_1
%71 = OpFunctionCall %void %main_inner %72
%main = OpFunction %void None %81
%83 = OpLabel
%85 = OpLoad %uint %idx_1
%84 = OpFunctionCall %void %main_inner %85
OpReturn
OpFunctionEnd
1:1: Structure id 8 decorated as Block for variable in Uniform storage class must follow relaxed uniform buffer layout rules: member 9 is a matrix with stride 8 not satisfying alignment to 16
%Inner = OpTypeStruct %v3int %int %v3uint %uint %v3float %float %v2int %v2int %mat2v3float %mat3v2float %_arr_v4int_uint_4