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

@@ -68,17 +68,25 @@ layout(binding = 1, std430) buffer u_block_ssbo {
S inner[4];
} s;
void assign_and_preserve_padding_2_s_X_m(uint dest[1], f16mat4x3 value) {
s.inner[dest[0]].m[0] = value[0u];
s.inner[dest[0]].m[1] = value[1u];
s.inner[dest[0]].m[2] = value[2u];
s.inner[dest[0]].m[3] = value[3u];
}
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]);
}
}
}
@@ -103,9 +111,10 @@ f16mat4x3 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,16 @@ struct S {
/* 0x0044 */ tint_array<int8_t, 60> tint_pad_2;
};
void assign_and_preserve_padding_2(device half4x3* const dest, half4x3 value) {
(*(dest))[0u] = value[0u];
(*(dest))[1u] = value[1u];
(*(dest))[2u] = value[2u];
(*(dest))[3u] = value[3u];
}
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 +45,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: 151
; Bound: 170
; Schema: 0
OpCapability Shader
OpCapability Float16
@@ -28,11 +28,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"
@@ -86,168 +89,191 @@
%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 %mat4v3half
%uint_0 = OpConstant %uint 0
%26 = OpConstantNull %int
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
%_ptr_StorageBuffer_mat4v3half = OpTypePointer StorageBuffer %mat4v3half
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
%30 = OpConstantNull %uint
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%uint_2 = OpConstant %uint 2
%39 = OpTypeFunction %void %_arr_S_uint_4
%43 = OpConstantNull %uint
%int_3 = OpConstant %int 3
%uint_3 = OpConstant %uint 3
%46 = OpTypeFunction %void %_arr_uint_uint_1 %S
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
%62 = 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
%80 = OpConstantNull %_arr_S_uint_4
%_ptr_Function_S = OpTypePointer Function %S
%68 = OpTypeFunction %S %S_std140
%80 = OpTypeFunction %_arr_S_uint_4 %_arr_S_std140_uint_4
%90 = OpTypeFunction %S %S_std140
%102 = OpTypeFunction %_arr_S_uint_4 %_arr_S_std140_uint_4
%_ptr_Function__arr_S_std140_uint_4 = OpTypePointer Function %_arr_S_std140_uint_4
%97 = OpConstantNull %_arr_S_std140_uint_4
%119 = OpConstantNull %_arr_S_std140_uint_4
%_ptr_Function_S_std140 = OpTypePointer Function %S_std140
%108 = OpTypeFunction %mat4v3half
%130 = OpTypeFunction %mat4v3half
%_ptr_Uniform_S_std140 = OpTypePointer Uniform %S_std140
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%uint_3 = OpConstant %uint 3
%129 = OpTypeFunction %void
%150 = OpTypeFunction %void
%_ptr_Uniform__arr_S_std140_uint_4 = OpTypePointer Uniform %_arr_S_std140_uint_4
%138 = 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
%159 = OpConstantComposite %_arr_uint_uint_1 %uint_1
%164 = 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 %mat4v3half
%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_mat4v3half %s %uint_0 %31 %uint_1
%34 = OpCompositeExtract %mat4v3half %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
%36 = OpCompositeExtract %uint %dest 0
%38 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %36 %uint_1 %int_2
%40 = OpCompositeExtract %v3half %value 2
OpStore %38 %40
%41 = OpCompositeExtract %uint %dest 0
%43 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %41 %uint_1 %int_3
%45 = OpCompositeExtract %v3half %value 3
OpStore %43 %45
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 %46
%dest_0 = OpFunctionParameter %_arr_uint_uint_1
%value_0 = OpFunctionParameter %S
%50 = OpLabel
%51 = OpCompositeExtract %uint %dest_0 0
%53 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %51 %uint_0
%54 = OpCompositeExtract %int %value_0 0
OpStore %53 %54
%56 = OpCompositeExtract %uint %dest_0 0
%57 = OpCompositeConstruct %_arr_uint_uint_1 %56
%58 = OpCompositeExtract %mat4v3half %value_0 1
%55 = OpFunctionCall %void %assign_and_preserve_padding_2_s_X_m %57 %58
%59 = OpCompositeExtract %uint %dest_0 0
%60 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %59 %uint_2
%61 = OpCompositeExtract %int %value_0 2
OpStore %60 %61
OpReturn
OpFunctionEnd
%conv_S = OpFunction %S None %68
%val = OpFunctionParameter %S_std140
%assign_and_preserve_padding_s = OpFunction %void None %62
%value_1 = OpFunctionParameter %_arr_S_uint_4
%65 = OpLabel
%i = OpVariable %_ptr_Function_uint Function %30
%var_for_index = OpVariable %_ptr_Function__arr_S_uint_4 Function %80
OpStore %i %30
OpBranch %68
%68 = OpLabel
OpLoopMerge %69 %70 None
OpBranch %71
%71 = OpLabel
%72 = OpCompositeExtract %int %val 0
%73 = OpCompositeExtract %v3half %val 1
%74 = OpCompositeExtract %v3half %val 2
%75 = OpCompositeExtract %v3half %val 3
%76 = OpCompositeExtract %v3half %val 4
%77 = OpCompositeConstruct %mat4v3half %73 %74 %75 %76
%78 = OpCompositeExtract %int %val 5
%79 = OpCompositeConstruct %S %72 %77 %78
OpReturnValue %79
OpFunctionEnd
%conv_arr4_S = OpFunction %_arr_S_uint_4 None %80
%val_0 = OpFunctionParameter %_arr_S_std140_uint_4
%83 = 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 %97
OpBranch %86
%86 = OpLabel
OpLoopMerge %87 %88 None
OpBranch %89
%89 = OpLabel
%91 = OpLoad %uint %i_0
%92 = OpULessThan %bool %91 %uint_4
%90 = OpLogicalNot %bool %92
OpSelectionMerge %93 None
OpBranchConditional %90 %94 %93
%94 = OpLabel
OpBranch %87
%93 = OpLabel
OpStore %var_for_index_1 %val_0
%98 = OpLoad %uint %i_0
%99 = OpAccessChain %_ptr_Function_S %arr %98
%101 = OpLoad %uint %i_0
%103 = OpAccessChain %_ptr_Function_S_std140 %var_for_index_1 %101
%104 = OpLoad %S_std140 %103
%100 = OpFunctionCall %S %conv_S %104
OpStore %99 %100
OpBranch %88
%88 = OpLabel
%105 = OpLoad %uint %i_0
%106 = OpIAdd %uint %105 %uint_1
OpStore %i_0 %106
OpBranch %86
%87 = OpLabel
%107 = OpLoad %_arr_S_uint_4 %arr
OpReturnValue %107
OpFunctionEnd
%load_u_inner_2_m = OpFunction %mat4v3half None %108
%110 = OpLabel
%113 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%116 = OpAccessChain %_ptr_Uniform_v3half %113 %uint_1
%117 = OpLoad %v3half %116
%119 = OpAccessChain %_ptr_Uniform_v3half %113 %uint_2
%120 = OpLoad %v3half %119
%123 = OpAccessChain %_ptr_Uniform_v3half %113 %uint_3
%124 = OpLoad %v3half %123
%126 = OpAccessChain %_ptr_Uniform_v3half %113 %uint_4
%127 = OpLoad %v3half %126
%128 = OpCompositeConstruct %mat4v3half %117 %120 %124 %127
OpReturnValue %128
OpFunctionEnd
%f = OpFunction %void None %129
%131 = OpLabel
%135 = OpAccessChain %_ptr_Uniform__arr_S_std140_uint_4 %u %uint_0
%136 = OpLoad %_arr_S_std140_uint_4 %135
%133 = OpFunctionCall %_arr_S_uint_4 %conv_arr4_S %136
%132 = OpFunctionCall %void %assign_and_preserve_padding_s %133
%140 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%141 = OpLoad %S_std140 %140
%139 = OpFunctionCall %S %conv_S %141
%137 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %138 %139
%143 = OpAccessChain %_ptr_StorageBuffer_mat4v3half %s %uint_0 %int_3 %uint_1
%144 = OpFunctionCall %mat4v3half %load_u_inner_2_m
OpStore %143 %144
%147 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1 %uint_1 %26
%148 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %43 %uint_2
%149 = OpLoad %v3half %148
%150 = OpVectorShuffle %v3half %149 %149 2 0 1
OpStore %147 %150
%73 = OpLoad %uint %i
%74 = OpULessThan %bool %73 %uint_4
%72 = OpLogicalNot %bool %74
OpSelectionMerge %76 None
OpBranchConditional %72 %77 %76
%77 = OpLabel
OpBranch %69
%76 = OpLabel
OpStore %var_for_index %value_1
%82 = OpLoad %uint %i
%83 = OpCompositeConstruct %_arr_uint_uint_1 %82
%84 = OpLoad %uint %i
%86 = OpAccessChain %_ptr_Function_S %var_for_index %84
%87 = OpLoad %S %86
%81 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %83 %87
OpBranch %70
%70 = OpLabel
%88 = OpLoad %uint %i
%89 = OpIAdd %uint %88 %uint_1
OpStore %i %89
OpBranch %68
%69 = OpLabel
OpReturn
OpFunctionEnd
%conv_S = OpFunction %S None %90
%val = OpFunctionParameter %S_std140
%93 = OpLabel
%94 = OpCompositeExtract %int %val 0
%95 = OpCompositeExtract %v3half %val 1
%96 = OpCompositeExtract %v3half %val 2
%97 = OpCompositeExtract %v3half %val 3
%98 = OpCompositeExtract %v3half %val 4
%99 = OpCompositeConstruct %mat4v3half %95 %96 %97 %98
%100 = OpCompositeExtract %int %val 5
%101 = OpCompositeConstruct %S %94 %99 %100
OpReturnValue %101
OpFunctionEnd
%conv_arr4_S = OpFunction %_arr_S_uint_4 None %102
%val_0 = OpFunctionParameter %_arr_S_std140_uint_4
%105 = OpLabel
%arr = OpVariable %_ptr_Function__arr_S_uint_4 Function %80
%i_0 = OpVariable %_ptr_Function_uint Function %30
%var_for_index_1 = OpVariable %_ptr_Function__arr_S_std140_uint_4 Function %119
OpBranch %108
%108 = OpLabel
OpLoopMerge %109 %110 None
OpBranch %111
%111 = OpLabel
%113 = OpLoad %uint %i_0
%114 = OpULessThan %bool %113 %uint_4
%112 = OpLogicalNot %bool %114
OpSelectionMerge %115 None
OpBranchConditional %112 %116 %115
%116 = OpLabel
OpBranch %109
%115 = OpLabel
OpStore %var_for_index_1 %val_0
%120 = OpLoad %uint %i_0
%121 = OpAccessChain %_ptr_Function_S %arr %120
%123 = OpLoad %uint %i_0
%125 = OpAccessChain %_ptr_Function_S_std140 %var_for_index_1 %123
%126 = OpLoad %S_std140 %125
%122 = OpFunctionCall %S %conv_S %126
OpStore %121 %122
OpBranch %110
%110 = OpLabel
%127 = OpLoad %uint %i_0
%128 = OpIAdd %uint %127 %uint_1
OpStore %i_0 %128
OpBranch %108
%109 = OpLabel
%129 = OpLoad %_arr_S_uint_4 %arr
OpReturnValue %129
OpFunctionEnd
%load_u_inner_2_m = OpFunction %mat4v3half None %130
%132 = OpLabel
%135 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%138 = OpAccessChain %_ptr_Uniform_v3half %135 %uint_1
%139 = OpLoad %v3half %138
%141 = OpAccessChain %_ptr_Uniform_v3half %135 %uint_2
%142 = OpLoad %v3half %141
%144 = OpAccessChain %_ptr_Uniform_v3half %135 %uint_3
%145 = OpLoad %v3half %144
%147 = OpAccessChain %_ptr_Uniform_v3half %135 %uint_4
%148 = OpLoad %v3half %147
%149 = OpCompositeConstruct %mat4v3half %139 %142 %145 %148
OpReturnValue %149
OpFunctionEnd
%f = OpFunction %void None %150
%152 = OpLabel
%156 = OpAccessChain %_ptr_Uniform__arr_S_std140_uint_4 %u %uint_0
%157 = OpLoad %_arr_S_std140_uint_4 %156
%154 = OpFunctionCall %_arr_S_uint_4 %conv_arr4_S %157
%153 = OpFunctionCall %void %assign_and_preserve_padding_s %154
%161 = OpAccessChain %_ptr_Uniform_S_std140 %u %uint_0 %uint_2
%162 = OpLoad %S_std140 %161
%160 = OpFunctionCall %S %conv_S %162
%158 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %159 %160
%165 = OpFunctionCall %mat4v3half %load_u_inner_2_m
%163 = OpFunctionCall %void %assign_and_preserve_padding_2_s_X_m %164 %165
%166 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1 %uint_1 %26
%167 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %30 %uint_2
%168 = OpLoad %v3half %167
%169 = OpVectorShuffle %v3half %168 %168 2 0 1
OpStore %166 %169
OpReturn
OpFunctionEnd