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

@@ -6,13 +6,26 @@ struct S {
vec3 vector;
};
layout(binding = 0) uniform S_1 {
mat3x2 matrix;
struct S_std140 {
vec2 matrix_0;
vec2 matrix_1;
vec2 matrix_2;
vec3 vector;
};
layout(binding = 0) uniform S_std140_1 {
vec2 matrix_0;
vec2 matrix_1;
vec2 matrix_2;
vec3 vector;
} data;
mat3x2 load_data_matrix() {
return mat3x2(data.matrix_0, data.matrix_1, data.matrix_2);
}
void tint_symbol() {
vec2 x = (data.matrix * data.vector);
vec2 x = (load_data_matrix() * data.vector);
}
void main() {

View File

@@ -1,50 +1,61 @@
SKIP: FAILED
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 22
; Bound: 33
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main"
OpExecutionMode %main OriginUpperLeft
OpName %S "S"
OpMemberName %S 0 "matrix"
OpMemberName %S 1 "vector"
OpName %S_std140 "S_std140"
OpMemberName %S_std140 0 "matrix_0"
OpMemberName %S_std140 1 "matrix_1"
OpMemberName %S_std140 2 "matrix_2"
OpMemberName %S_std140 3 "vector"
OpName %data "data"
OpName %load_data_matrix "load_data_matrix"
OpName %main "main"
OpDecorate %S Block
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %S 0 ColMajor
OpMemberDecorate %S 0 MatrixStride 8
OpMemberDecorate %S 1 Offset 32
OpDecorate %S_std140 Block
OpMemberDecorate %S_std140 0 Offset 0
OpMemberDecorate %S_std140 1 Offset 8
OpMemberDecorate %S_std140 2 Offset 16
OpMemberDecorate %S_std140 3 Offset 32
OpDecorate %data NonWritable
OpDecorate %data DescriptorSet 0
OpDecorate %data Binding 0
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%mat3v2float = OpTypeMatrix %v2float 3
%v3float = OpTypeVector %float 3
%S = OpTypeStruct %mat3v2float %v3float
%_ptr_Uniform_S = OpTypePointer Uniform %S
%data = OpVariable %_ptr_Uniform_S Uniform
%void = OpTypeVoid
%8 = OpTypeFunction %void
%S_std140 = OpTypeStruct %v2float %v2float %v2float %v3float
%_ptr_Uniform_S_std140 = OpTypePointer Uniform %S_std140
%data = OpVariable %_ptr_Uniform_S_std140 Uniform
%mat3v2float = OpTypeMatrix %v2float 3
%7 = OpTypeFunction %mat3v2float
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_mat3v2float = OpTypePointer Uniform %mat3v2float
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%void = OpTypeVoid
%23 = OpTypeFunction %void
%uint_3 = OpConstant %uint 3
%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
%main = OpFunction %void None %8
%11 = OpLabel
%15 = OpAccessChain %_ptr_Uniform_mat3v2float %data %uint_0
%16 = OpLoad %mat3v2float %15
%19 = OpAccessChain %_ptr_Uniform_v3float %data %uint_1
%20 = OpLoad %v3float %19
%21 = OpMatrixTimesVector %v2float %16 %20
%load_data_matrix = OpFunction %mat3v2float None %7
%10 = OpLabel
%14 = OpAccessChain %_ptr_Uniform_v2float %data %uint_0
%15 = OpLoad %v2float %14
%17 = OpAccessChain %_ptr_Uniform_v2float %data %uint_1
%18 = OpLoad %v2float %17
%20 = OpAccessChain %_ptr_Uniform_v2float %data %uint_2
%21 = OpLoad %v2float %20
%22 = OpCompositeConstruct %mat3v2float %15 %18 %21
OpReturnValue %22
OpFunctionEnd
%main = OpFunction %void None %23
%26 = OpLabel
%27 = OpFunctionCall %mat3v2float %load_data_matrix
%30 = OpAccessChain %_ptr_Uniform_v3float %data %uint_3
%31 = OpLoad %v3float %30
%32 = OpMatrixTimesVector %v2float %27 %31
OpReturn
OpFunctionEnd
1:1: Structure id 3 decorated as Block for variable in Uniform storage class must follow relaxed uniform buffer layout rules: member 0 is a matrix with stride 8 not satisfying alignment to 16
%S = OpTypeStruct %mat3v2float %v3float