tint: Preserve padding in matrices with three rows

The PreservePadding transform now decomposes writes to matrices with
three rows into separate column vector writes, to avoid modifying
padding between columns.

Bug: tint:1571
Change-Id: If575f79bb87f52810783fd3338e2f3ce3228ab2e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121600
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
James Price
2023-02-27 16:06:54 +00:00
committed by Dawn LUCI CQ
parent fe19fee3ea
commit 6176c85be8
84 changed files with 3733 additions and 1968 deletions

View File

@@ -74,17 +74,23 @@ layout(binding = 1, std430) buffer u_block_ssbo {
S inner[4];
} s;
void assign_and_preserve_padding_2_s_X_m(uint dest[1], f16mat2x3 value) {
s.inner[dest[0]].m[0] = value[0u];
s.inner[dest[0]].m[1] = value[1u];
}
void assign_and_preserve_padding_1_s_X(uint dest[1], S value) {
s.inner[dest[0]].before = value.before;
s.inner[dest[0]].m = value.m;
uint tint_symbol[1] = uint[1](dest[0u]);
assign_and_preserve_padding_2_s_X_m(tint_symbol, value.m);
s.inner[dest[0]].after = value.after;
}
void assign_and_preserve_padding_s(S value[4]) {
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
uint tint_symbol[1] = uint[1](i);
assign_and_preserve_padding_1_s_X(tint_symbol, value[i]);
uint tint_symbol_1[1] = uint[1](i);
assign_and_preserve_padding_1_s_X(tint_symbol_1, value[i]);
}
}
}
@@ -109,9 +115,10 @@ f16mat2x3 load_u_inner_2_m() {
void f() {
assign_and_preserve_padding_s(conv_arr4_S(u.inner));
uint tint_symbol_1[1] = uint[1](1u);
assign_and_preserve_padding_1_s_X(tint_symbol_1, conv_S(u.inner[2u]));
s.inner[3].m = load_u_inner_2_m();
uint tint_symbol_2[1] = uint[1](1u);
assign_and_preserve_padding_1_s_X(tint_symbol_2, conv_S(u.inner[2u]));
uint tint_symbol_3[1] = uint[1](3u);
assign_and_preserve_padding_2_s_X_m(tint_symbol_3, load_u_inner_2_m());
s.inner[1].m[0] = u.inner[0u].m_1.zxy;
}

View File

@@ -23,9 +23,14 @@ struct S {
/* 0x0044 */ tint_array<int8_t, 60> tint_pad_2;
};
void assign_and_preserve_padding_2(device half2x3* const dest, half2x3 value) {
(*(dest))[0u] = value[0u];
(*(dest))[1u] = value[1u];
}
void assign_and_preserve_padding_1(device S* const dest, S value) {
(*(dest)).before = value.before;
(*(dest)).m = value.m;
assign_and_preserve_padding_2(&((*(dest)).m), value.m);
(*(dest)).after = value.after;
}
@@ -38,7 +43,7 @@ void assign_and_preserve_padding(device tint_array<S, 4>* const dest, tint_array
kernel void f(device tint_array<S, 4>* tint_symbol [[buffer(1)]], const constant tint_array<S, 4>* tint_symbol_1 [[buffer(0)]]) {
assign_and_preserve_padding(tint_symbol, *(tint_symbol_1));
assign_and_preserve_padding_1(&((*(tint_symbol))[1]), (*(tint_symbol_1))[2]);
(*(tint_symbol))[3].m = (*(tint_symbol_1))[2].m;
assign_and_preserve_padding_2(&((*(tint_symbol))[3].m), (*(tint_symbol_1))[2].m);
(*(tint_symbol))[1].m[0] = half3((*(tint_symbol_1))[0].m[1]).zxy;
return;
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 142
; Bound: 154
; Schema: 0
OpCapability Shader
OpCapability Float16
@@ -26,11 +26,14 @@
OpMemberName %S 1 "m"
OpMemberName %S 2 "after"
OpName %s "s"
OpName %assign_and_preserve_padding_1_s_X "assign_and_preserve_padding_1_s_X"
OpName %assign_and_preserve_padding_2_s_X_m "assign_and_preserve_padding_2_s_X_m"
OpName %dest "dest"
OpName %value "value"
OpName %assign_and_preserve_padding_s "assign_and_preserve_padding_s"
OpName %assign_and_preserve_padding_1_s_X "assign_and_preserve_padding_1_s_X"
OpName %dest_0 "dest"
OpName %value_0 "value"
OpName %assign_and_preserve_padding_s "assign_and_preserve_padding_s"
OpName %value_1 "value"
OpName %i "i"
OpName %var_for_index "var_for_index"
OpName %conv_S "conv_S"
@@ -82,161 +85,175 @@
%void = OpTypeVoid
%uint_1 = OpConstant %uint 1
%_arr_uint_uint_1 = OpTypeArray %uint %uint_1
%17 = OpTypeFunction %void %_arr_uint_uint_1 %S
%17 = OpTypeFunction %void %_arr_uint_uint_1 %mat2v3half
%uint_0 = OpConstant %uint 0
%26 = OpConstantNull %int
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
%30 = OpConstantNull %uint
%int_1 = OpConstant %int 1
%36 = OpTypeFunction %void %_arr_uint_uint_1 %S
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
%_ptr_StorageBuffer_mat2v3half = OpTypePointer StorageBuffer %mat2v3half
%uint_2 = OpConstant %uint 2
%39 = OpTypeFunction %void %_arr_S_uint_4
%43 = OpConstantNull %uint
%53 = OpTypeFunction %void %_arr_S_uint_4
%_ptr_Function_uint = OpTypePointer Function %uint
%bool = OpTypeBool
%_ptr_Function__arr_S_uint_4 = OpTypePointer Function %_arr_S_uint_4
%58 = OpConstantNull %_arr_S_uint_4
%71 = OpConstantNull %_arr_S_uint_4
%_ptr_Function_S = OpTypePointer Function %S
%68 = OpTypeFunction %S %S_std140
%78 = OpTypeFunction %_arr_S_uint_4 %_arr_S_std140_uint_4
%81 = OpTypeFunction %S %S_std140
%91 = OpTypeFunction %_arr_S_uint_4 %_arr_S_std140_uint_4
%_ptr_Function__arr_S_std140_uint_4 = OpTypePointer Function %_arr_S_std140_uint_4
%95 = OpConstantNull %_arr_S_std140_uint_4
%108 = OpConstantNull %_arr_S_std140_uint_4
%_ptr_Function_S_std140 = OpTypePointer Function %S_std140
%106 = OpTypeFunction %mat2v3half
%119 = OpTypeFunction %mat2v3half
%_ptr_Uniform_S_std140 = OpTypePointer Uniform %S_std140
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%120 = OpTypeFunction %void
%133 = OpTypeFunction %void
%_ptr_Uniform__arr_S_std140_uint_4 = OpTypePointer Uniform %_arr_S_std140_uint_4
%129 = OpConstantComposite %_arr_uint_uint_1 %uint_1
%int_3 = OpConstant %int 3
%int_1 = OpConstant %int 1
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
%assign_and_preserve_padding_1_s_X = OpFunction %void None %17
%142 = OpConstantComposite %_arr_uint_uint_1 %uint_1
%uint_3 = OpConstant %uint 3
%148 = OpConstantComposite %_arr_uint_uint_1 %uint_3
%assign_and_preserve_padding_2_s_X_m = OpFunction %void None %17
%dest = OpFunctionParameter %_arr_uint_uint_1
%value = OpFunctionParameter %S
%value = OpFunctionParameter %mat2v3half
%24 = OpLabel
%27 = OpCompositeExtract %uint %dest 0
%29 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %27 %uint_0
%30 = OpCompositeExtract %int %value 0
OpStore %29 %30
%31 = OpCompositeExtract %uint %dest 0
%33 = OpAccessChain %_ptr_StorageBuffer_mat2v3half %s %uint_0 %31 %uint_1
%34 = OpCompositeExtract %mat2v3half %value 1
OpStore %33 %34
%35 = OpCompositeExtract %uint %dest 0
%37 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %35 %uint_2
%38 = OpCompositeExtract %int %value 2
OpStore %37 %38
%29 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %27 %uint_1 %26
%31 = OpCompositeExtract %v3half %value 0
OpStore %29 %31
%32 = OpCompositeExtract %uint %dest 0
%34 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %32 %uint_1 %int_1
%35 = OpCompositeExtract %v3half %value 1
OpStore %34 %35
OpReturn
OpFunctionEnd
%assign_and_preserve_padding_s = OpFunction %void None %39
%value_0 = OpFunctionParameter %_arr_S_uint_4
%42 = OpLabel
%i = OpVariable %_ptr_Function_uint Function %43
%var_for_index = OpVariable %_ptr_Function__arr_S_uint_4 Function %58
OpStore %i %43
OpBranch %46
%46 = OpLabel
OpLoopMerge %47 %48 None
OpBranch %49
%49 = OpLabel
%51 = OpLoad %uint %i
%52 = OpULessThan %bool %51 %uint_4
%50 = OpLogicalNot %bool %52
OpSelectionMerge %54 None
OpBranchConditional %50 %55 %54
%55 = OpLabel
OpBranch %47
%54 = OpLabel
OpStore %var_for_index %value_0
%60 = OpLoad %uint %i
%61 = OpCompositeConstruct %_arr_uint_uint_1 %60
%62 = OpLoad %uint %i
%64 = OpAccessChain %_ptr_Function_S %var_for_index %62
%65 = OpLoad %S %64
%59 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %61 %65
OpBranch %48
%48 = OpLabel
%66 = OpLoad %uint %i
%67 = OpIAdd %uint %66 %uint_1
OpStore %i %67
OpBranch %46
%47 = OpLabel
%assign_and_preserve_padding_1_s_X = OpFunction %void None %36
%dest_0 = OpFunctionParameter %_arr_uint_uint_1
%value_0 = OpFunctionParameter %S
%40 = OpLabel
%41 = OpCompositeExtract %uint %dest_0 0
%43 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %41 %uint_0
%44 = OpCompositeExtract %int %value_0 0
OpStore %43 %44
%46 = OpCompositeExtract %uint %dest_0 0
%47 = OpCompositeConstruct %_arr_uint_uint_1 %46
%48 = OpCompositeExtract %mat2v3half %value_0 1
%45 = OpFunctionCall %void %assign_and_preserve_padding_2_s_X_m %47 %48
%49 = OpCompositeExtract %uint %dest_0 0
%51 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %49 %uint_2
%52 = OpCompositeExtract %int %value_0 2
OpStore %51 %52
OpReturn
OpFunctionEnd
%conv_S = OpFunction %S None %68
%assign_and_preserve_padding_s = OpFunction %void None %53
%value_1 = OpFunctionParameter %_arr_S_uint_4
%56 = OpLabel
%i = OpVariable %_ptr_Function_uint Function %30
%var_for_index = OpVariable %_ptr_Function__arr_S_uint_4 Function %71
OpStore %i %30
OpBranch %59
%59 = OpLabel
OpLoopMerge %60 %61 None
OpBranch %62
%62 = OpLabel
%64 = OpLoad %uint %i
%65 = OpULessThan %bool %64 %uint_4
%63 = OpLogicalNot %bool %65
OpSelectionMerge %67 None
OpBranchConditional %63 %68 %67
%68 = OpLabel
OpBranch %60
%67 = OpLabel
OpStore %var_for_index %value_1
%73 = OpLoad %uint %i
%74 = OpCompositeConstruct %_arr_uint_uint_1 %73
%75 = OpLoad %uint %i
%77 = OpAccessChain %_ptr_Function_S %var_for_index %75
%78 = OpLoad %S %77
%72 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %74 %78
OpBranch %61
%61 = OpLabel
%79 = OpLoad %uint %i
%80 = OpIAdd %uint %79 %uint_1
OpStore %i %80
OpBranch %59
%60 = OpLabel
OpReturn
OpFunctionEnd
%conv_S = OpFunction %S None %81
%val = OpFunctionParameter %S_std140
%71 = OpLabel
%72 = OpCompositeExtract %int %val 0
%73 = OpCompositeExtract %v3half %val 1
%74 = OpCompositeExtract %v3half %val 2
%75 = OpCompositeConstruct %mat2v3half %73 %74
%76 = OpCompositeExtract %int %val 3
%77 = OpCompositeConstruct %S %72 %75 %76
OpReturnValue %77
OpFunctionEnd
%conv_arr4_S = OpFunction %_arr_S_uint_4 None %78
%val_0 = OpFunctionParameter %_arr_S_std140_uint_4
%81 = OpLabel
%arr = OpVariable %_ptr_Function__arr_S_uint_4 Function %58
%i_0 = OpVariable %_ptr_Function_uint Function %43
%var_for_index_1 = OpVariable %_ptr_Function__arr_S_std140_uint_4 Function %95
OpBranch %84
%84 = OpLabel
OpLoopMerge %85 %86 None
OpBranch %87
%87 = OpLabel
%89 = OpLoad %uint %i_0
%90 = OpULessThan %bool %89 %uint_4
%88 = OpLogicalNot %bool %90
OpSelectionMerge %91 None
OpBranchConditional %88 %92 %91
%92 = OpLabel
OpBranch %85
%91 = OpLabel
%85 = OpCompositeExtract %int %val 0
%86 = OpCompositeExtract %v3half %val 1
%87 = OpCompositeExtract %v3half %val 2
%88 = OpCompositeConstruct %mat2v3half %86 %87
%89 = OpCompositeExtract %int %val 3
%90 = OpCompositeConstruct %S %85 %88 %89
OpReturnValue %90
OpFunctionEnd
%conv_arr4_S = OpFunction %_arr_S_uint_4 None %91
%val_0 = OpFunctionParameter %_arr_S_std140_uint_4
%94 = OpLabel
%arr = OpVariable %_ptr_Function__arr_S_uint_4 Function %71
%i_0 = OpVariable %_ptr_Function_uint Function %30
%var_for_index_1 = OpVariable %_ptr_Function__arr_S_std140_uint_4 Function %108
OpBranch %97
%97 = OpLabel
OpLoopMerge %98 %99 None
OpBranch %100
%100 = OpLabel
%102 = OpLoad %uint %i_0
%103 = OpULessThan %bool %102 %uint_4
%101 = OpLogicalNot %bool %103
OpSelectionMerge %104 None
OpBranchConditional %101 %105 %104
%105 = OpLabel
OpBranch %98
%104 = OpLabel
OpStore %var_for_index_1 %val_0
%96 = OpLoad %uint %i_0
%97 = OpAccessChain %_ptr_Function_S %arr %96
%99 = OpLoad %uint %i_0
%101 = OpAccessChain %_ptr_Function_S_std140 %var_for_index_1 %99
%102 = OpLoad %S_std140 %101
%98 = OpFunctionCall %S %conv_S %102
OpStore %97 %98
OpBranch %86
%86 = OpLabel
%103 = OpLoad %uint %i_0
%104 = OpIAdd %uint %103 %uint_1
OpStore %i_0 %104
OpBranch %84
%85 = OpLabel
%105 = OpLoad %_arr_S_uint_4 %arr
OpReturnValue %105
%109 = OpLoad %uint %i_0
%110 = OpAccessChain %_ptr_Function_S %arr %109
%112 = OpLoad %uint %i_0
%114 = OpAccessChain %_ptr_Function_S_std140 %var_for_index_1 %112
%115 = OpLoad %S_std140 %114
%111 = OpFunctionCall %S %conv_S %115
OpStore %110 %111
OpBranch %99
%99 = OpLabel
%116 = OpLoad %uint %i_0
%117 = OpIAdd %uint %116 %uint_1
OpStore %i_0 %117
OpBranch %97
%98 = OpLabel
%118 = OpLoad %_arr_S_uint_4 %arr
OpReturnValue %118
OpFunctionEnd
%load_u_inner_2_m = OpFunction %mat2v3half None %106
%108 = OpLabel
%111 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%114 = OpAccessChain %_ptr_Uniform_v3half %111 %uint_1
%115 = OpLoad %v3half %114
%117 = OpAccessChain %_ptr_Uniform_v3half %111 %uint_2
%118 = OpLoad %v3half %117
%119 = OpCompositeConstruct %mat2v3half %115 %118
OpReturnValue %119
%load_u_inner_2_m = OpFunction %mat2v3half None %119
%121 = OpLabel
%124 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%127 = OpAccessChain %_ptr_Uniform_v3half %124 %uint_1
%128 = OpLoad %v3half %127
%130 = OpAccessChain %_ptr_Uniform_v3half %124 %uint_2
%131 = OpLoad %v3half %130
%132 = OpCompositeConstruct %mat2v3half %128 %131
OpReturnValue %132
OpFunctionEnd
%f = OpFunction %void None %120
%122 = OpLabel
%126 = OpAccessChain %_ptr_Uniform__arr_S_std140_uint_4 %u %uint_0
%127 = OpLoad %_arr_S_std140_uint_4 %126
%124 = OpFunctionCall %_arr_S_uint_4 %conv_arr4_S %127
%123 = OpFunctionCall %void %assign_and_preserve_padding_s %124
%131 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%132 = OpLoad %S_std140 %131
%130 = OpFunctionCall %S %conv_S %132
%128 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %129 %130
%134 = OpAccessChain %_ptr_StorageBuffer_mat2v3half %s %uint_0 %int_3 %uint_1
%135 = OpFunctionCall %mat2v3half %load_u_inner_2_m
OpStore %134 %135
%138 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1 %uint_1 %26
%139 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %43 %uint_2
%140 = OpLoad %v3half %139
%141 = OpVectorShuffle %v3half %140 %140 2 0 1
OpStore %138 %141
%f = OpFunction %void None %133
%135 = OpLabel
%139 = OpAccessChain %_ptr_Uniform__arr_S_std140_uint_4 %u %uint_0
%140 = OpLoad %_arr_S_std140_uint_4 %139
%137 = OpFunctionCall %_arr_S_uint_4 %conv_arr4_S %140
%136 = OpFunctionCall %void %assign_and_preserve_padding_s %137
%144 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%145 = OpLoad %S_std140 %144
%143 = OpFunctionCall %S %conv_S %145
%141 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %142 %143
%149 = OpFunctionCall %mat2v3half %load_u_inner_2_m
%146 = OpFunctionCall %void %assign_and_preserve_padding_2_s_X_m %148 %149
%150 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1 %uint_1 %26
%151 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %30 %uint_2
%152 = OpLoad %v3half %151
%153 = OpVectorShuffle %v3half %152 %152 2 0 1
OpStore %150 %153
OpReturn
OpFunctionEnd