mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 06:45:16 +00:00
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:
committed by
Dawn LUCI CQ
parent
fe19fee3ea
commit
6176c85be8
@@ -16,6 +16,22 @@ layout(binding = 1, std430) buffer u_block_ssbo {
|
||||
f16mat4x3 inner[4];
|
||||
} s;
|
||||
|
||||
void assign_and_preserve_padding_1_s_X(uint dest[1], f16mat4x3 value) {
|
||||
s.inner[dest[0]][0] = value[0u];
|
||||
s.inner[dest[0]][1] = value[1u];
|
||||
s.inner[dest[0]][2] = value[2u];
|
||||
s.inner[dest[0]][3] = value[3u];
|
||||
}
|
||||
|
||||
void assign_and_preserve_padding_s(f16mat4x3 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f16mat4x3 conv_mat4x3_f16(mat4x3_f16 val) {
|
||||
return f16mat4x3(val.col0, val.col1, val.col2, val.col3);
|
||||
}
|
||||
@@ -31,8 +47,9 @@ f16mat4x3[4] conv_arr4_mat4x3_f16(mat4x3_f16 val[4]) {
|
||||
}
|
||||
|
||||
void f() {
|
||||
s.inner = conv_arr4_mat4x3_f16(u.inner);
|
||||
s.inner[1] = conv_mat4x3_f16(u.inner[2u]);
|
||||
assign_and_preserve_padding_s(conv_arr4_mat4x3_f16(u.inner));
|
||||
uint tint_symbol_1[1] = uint[1](1u);
|
||||
assign_and_preserve_padding_1_s_X(tint_symbol_1, conv_mat4x3_f16(u.inner[2u]));
|
||||
s.inner[1][0] = u.inner[0u].col1.zxy;
|
||||
s.inner[1][0].x = u.inner[0u].col1[0u];
|
||||
}
|
||||
|
||||
@@ -14,9 +14,22 @@ struct tint_array {
|
||||
T elements[N];
|
||||
};
|
||||
|
||||
void assign_and_preserve_padding_1(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(device tint_array<half4x3, 4>* const dest, tint_array<half4x3, 4> value) {
|
||||
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
|
||||
assign_and_preserve_padding_1(&((*(dest))[i]), value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
kernel void f(device tint_array<half4x3, 4>* tint_symbol [[buffer(1)]], const constant tint_array<half4x3, 4>* tint_symbol_1 [[buffer(0)]]) {
|
||||
*(tint_symbol) = *(tint_symbol_1);
|
||||
(*(tint_symbol))[1] = (*(tint_symbol_1))[2];
|
||||
assign_and_preserve_padding(tint_symbol, *(tint_symbol_1));
|
||||
assign_and_preserve_padding_1(&((*(tint_symbol))[1]), (*(tint_symbol_1))[2]);
|
||||
(*(tint_symbol))[1][0] = half3((*(tint_symbol_1))[0][1]).zxy;
|
||||
(*(tint_symbol))[1][0][0] = (*(tint_symbol_1))[0][1][0];
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 91
|
||||
; Bound: 134
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpCapability Float16
|
||||
@@ -22,13 +22,20 @@
|
||||
OpName %u_block "u_block"
|
||||
OpMemberName %u_block 0 "inner"
|
||||
OpName %s "s"
|
||||
OpName %assign_and_preserve_padding_1_s_X "assign_and_preserve_padding_1_s_X"
|
||||
OpName %dest "dest"
|
||||
OpName %value "value"
|
||||
OpName %assign_and_preserve_padding_s "assign_and_preserve_padding_s"
|
||||
OpName %value_0 "value"
|
||||
OpName %i "i"
|
||||
OpName %var_for_index "var_for_index"
|
||||
OpName %conv_mat4x3_f16 "conv_mat4x3_f16"
|
||||
OpName %val "val"
|
||||
OpName %conv_arr4_mat4x3_f16 "conv_arr4_mat4x3_f16"
|
||||
OpName %val_0 "val"
|
||||
OpName %arr "arr"
|
||||
OpName %i "i"
|
||||
OpName %var_for_index "var_for_index"
|
||||
OpName %i_0 "i"
|
||||
OpName %var_for_index_1 "var_for_index_1"
|
||||
OpName %f "f"
|
||||
OpDecorate %u_block_std140 Block
|
||||
OpMemberDecorate %u_block_std140 0 Offset 0
|
||||
@@ -47,6 +54,7 @@
|
||||
OpDecorate %_arr_mat4v3half_uint_4 ArrayStride 32
|
||||
OpDecorate %s DescriptorSet 0
|
||||
OpDecorate %s Binding 1
|
||||
OpDecorate %_arr_uint_uint_1 ArrayStride 4
|
||||
%half = OpTypeFloat 16
|
||||
%v3half = OpTypeVector %half 3
|
||||
%mat4x3_f16 = OpTypeStruct %v3half %v3half %v3half %v3half
|
||||
@@ -61,100 +69,160 @@
|
||||
%u_block = OpTypeStruct %_arr_mat4v3half_uint_4
|
||||
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
|
||||
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
|
||||
%15 = OpTypeFunction %mat4v3half %mat4x3_f16
|
||||
%24 = OpTypeFunction %_arr_mat4v3half_uint_4 %_arr_mat4x3_f16_uint_4
|
||||
%_ptr_Function__arr_mat4v3half_uint_4 = OpTypePointer Function %_arr_mat4v3half_uint_4
|
||||
%30 = OpConstantNull %_arr_mat4v3half_uint_4
|
||||
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||
%33 = OpConstantNull %uint
|
||||
%bool = OpTypeBool
|
||||
%_ptr_Function__arr_mat4x3_f16_uint_4 = OpTypePointer Function %_arr_mat4x3_f16_uint_4
|
||||
%46 = OpConstantNull %_arr_mat4x3_f16_uint_4
|
||||
%_ptr_Function_mat4v3half = OpTypePointer Function %mat4v3half
|
||||
%_ptr_Function_mat4x3_f16 = OpTypePointer Function %mat4x3_f16
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%void = OpTypeVoid
|
||||
%59 = OpTypeFunction %void
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%_arr_uint_uint_1 = OpTypeArray %uint %uint_1
|
||||
%15 = OpTypeFunction %void %_arr_uint_uint_1 %mat4v3half
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_StorageBuffer__arr_mat4v3half_uint_4 = OpTypePointer StorageBuffer %_arr_mat4v3half_uint_4
|
||||
%_ptr_Uniform__arr_mat4x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat4x3_f16_uint_4
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%_ptr_StorageBuffer_mat4v3half = OpTypePointer StorageBuffer %mat4v3half
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%_ptr_Uniform_mat4x3_f16 = OpTypePointer Uniform %mat4x3_f16
|
||||
%79 = OpConstantNull %int
|
||||
%25 = OpConstantNull %int
|
||||
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
|
||||
%29 = OpConstantNull %uint
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%45 = OpTypeFunction %void %_arr_mat4v3half_uint_4
|
||||
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||
%bool = OpTypeBool
|
||||
%_ptr_Function__arr_mat4v3half_uint_4 = OpTypePointer Function %_arr_mat4v3half_uint_4
|
||||
%63 = OpConstantNull %_arr_mat4v3half_uint_4
|
||||
%_ptr_Function_mat4v3half = OpTypePointer Function %mat4v3half
|
||||
%73 = OpTypeFunction %mat4v3half %mat4x3_f16
|
||||
%82 = OpTypeFunction %_arr_mat4v3half_uint_4 %_arr_mat4x3_f16_uint_4
|
||||
%_ptr_Function__arr_mat4x3_f16_uint_4 = OpTypePointer Function %_arr_mat4x3_f16_uint_4
|
||||
%99 = OpConstantNull %_arr_mat4x3_f16_uint_4
|
||||
%_ptr_Function_mat4x3_f16 = OpTypePointer Function %mat4x3_f16
|
||||
%110 = OpTypeFunction %void
|
||||
%_ptr_Uniform__arr_mat4x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat4x3_f16_uint_4
|
||||
%119 = OpConstantComposite %_arr_uint_uint_1 %uint_1
|
||||
%_ptr_Uniform_mat4x3_f16 = OpTypePointer Uniform %mat4x3_f16
|
||||
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
|
||||
%_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half
|
||||
%_ptr_Uniform_half = OpTypePointer Uniform %half
|
||||
%conv_mat4x3_f16 = OpFunction %mat4v3half None %15
|
||||
%val = OpFunctionParameter %mat4x3_f16
|
||||
%18 = OpLabel
|
||||
%19 = OpCompositeExtract %v3half %val 0
|
||||
%20 = OpCompositeExtract %v3half %val 1
|
||||
%21 = OpCompositeExtract %v3half %val 2
|
||||
%22 = OpCompositeExtract %v3half %val 3
|
||||
%23 = OpCompositeConstruct %mat4v3half %19 %20 %21 %22
|
||||
OpReturnValue %23
|
||||
OpFunctionEnd
|
||||
%conv_arr4_mat4x3_f16 = OpFunction %_arr_mat4v3half_uint_4 None %24
|
||||
%val_0 = OpFunctionParameter %_arr_mat4x3_f16_uint_4
|
||||
%27 = OpLabel
|
||||
%arr = OpVariable %_ptr_Function__arr_mat4v3half_uint_4 Function %30
|
||||
%i = OpVariable %_ptr_Function_uint Function %33
|
||||
%var_for_index = OpVariable %_ptr_Function__arr_mat4x3_f16_uint_4 Function %46
|
||||
OpBranch %34
|
||||
%34 = OpLabel
|
||||
OpLoopMerge %35 %36 None
|
||||
OpBranch %37
|
||||
%37 = OpLabel
|
||||
%39 = OpLoad %uint %i
|
||||
%40 = OpULessThan %bool %39 %uint_4
|
||||
%38 = OpLogicalNot %bool %40
|
||||
OpSelectionMerge %42 None
|
||||
OpBranchConditional %38 %43 %42
|
||||
%43 = OpLabel
|
||||
OpBranch %35
|
||||
%42 = OpLabel
|
||||
OpStore %var_for_index %val_0
|
||||
%47 = OpLoad %uint %i
|
||||
%49 = OpAccessChain %_ptr_Function_mat4v3half %arr %47
|
||||
%51 = OpLoad %uint %i
|
||||
%53 = OpAccessChain %_ptr_Function_mat4x3_f16 %var_for_index %51
|
||||
%54 = OpLoad %mat4x3_f16 %53
|
||||
%50 = OpFunctionCall %mat4v3half %conv_mat4x3_f16 %54
|
||||
OpStore %49 %50
|
||||
OpBranch %36
|
||||
%36 = OpLabel
|
||||
%55 = OpLoad %uint %i
|
||||
%57 = OpIAdd %uint %55 %uint_1
|
||||
OpStore %i %57
|
||||
OpBranch %34
|
||||
%35 = OpLabel
|
||||
%58 = OpLoad %_arr_mat4v3half_uint_4 %arr
|
||||
OpReturnValue %58
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %59
|
||||
%62 = OpLabel
|
||||
%65 = OpAccessChain %_ptr_StorageBuffer__arr_mat4v3half_uint_4 %s %uint_0
|
||||
%68 = OpAccessChain %_ptr_Uniform__arr_mat4x3_f16_uint_4 %u %uint_0
|
||||
%69 = OpLoad %_arr_mat4x3_f16_uint_4 %68
|
||||
%66 = OpFunctionCall %_arr_mat4v3half_uint_4 %conv_arr4_mat4x3_f16 %69
|
||||
OpStore %65 %66
|
||||
%73 = OpAccessChain %_ptr_StorageBuffer_mat4v3half %s %uint_0 %int_1
|
||||
%77 = OpAccessChain %_ptr_Uniform_mat4x3_f16 %u %uint_0 %uint_2
|
||||
%78 = OpLoad %mat4x3_f16 %77
|
||||
%74 = OpFunctionCall %mat4v3half %conv_mat4x3_f16 %78
|
||||
OpStore %73 %74
|
||||
%81 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1 %79
|
||||
%83 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %33 %uint_1
|
||||
%84 = OpLoad %v3half %83
|
||||
%85 = OpVectorShuffle %v3half %84 %84 2 0 1
|
||||
OpStore %81 %85
|
||||
%87 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %int_1 %79 %uint_0
|
||||
%89 = OpAccessChain %_ptr_Uniform_half %u %uint_0 %33 %uint_1 %33
|
||||
%90 = OpLoad %half %89
|
||||
OpStore %87 %90
|
||||
%assign_and_preserve_padding_1_s_X = OpFunction %void None %15
|
||||
%dest = OpFunctionParameter %_arr_uint_uint_1
|
||||
%value = OpFunctionParameter %mat4v3half
|
||||
%22 = OpLabel
|
||||
%26 = OpCompositeExtract %uint %dest 0
|
||||
%28 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %26 %25
|
||||
%30 = OpCompositeExtract %v3half %value 0
|
||||
OpStore %28 %30
|
||||
%31 = OpCompositeExtract %uint %dest 0
|
||||
%33 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %31 %int_1
|
||||
%34 = OpCompositeExtract %v3half %value 1
|
||||
OpStore %33 %34
|
||||
%35 = OpCompositeExtract %uint %dest 0
|
||||
%37 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %35 %int_2
|
||||
%39 = OpCompositeExtract %v3half %value 2
|
||||
OpStore %37 %39
|
||||
%40 = OpCompositeExtract %uint %dest 0
|
||||
%42 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %40 %int_3
|
||||
%44 = OpCompositeExtract %v3half %value 3
|
||||
OpStore %42 %44
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%assign_and_preserve_padding_s = OpFunction %void None %45
|
||||
%value_0 = OpFunctionParameter %_arr_mat4v3half_uint_4
|
||||
%48 = OpLabel
|
||||
%i = OpVariable %_ptr_Function_uint Function %29
|
||||
%var_for_index = OpVariable %_ptr_Function__arr_mat4v3half_uint_4 Function %63
|
||||
OpStore %i %29
|
||||
OpBranch %51
|
||||
%51 = OpLabel
|
||||
OpLoopMerge %52 %53 None
|
||||
OpBranch %54
|
||||
%54 = OpLabel
|
||||
%56 = OpLoad %uint %i
|
||||
%57 = OpULessThan %bool %56 %uint_4
|
||||
%55 = OpLogicalNot %bool %57
|
||||
OpSelectionMerge %59 None
|
||||
OpBranchConditional %55 %60 %59
|
||||
%60 = OpLabel
|
||||
OpBranch %52
|
||||
%59 = OpLabel
|
||||
OpStore %var_for_index %value_0
|
||||
%65 = OpLoad %uint %i
|
||||
%66 = OpCompositeConstruct %_arr_uint_uint_1 %65
|
||||
%67 = OpLoad %uint %i
|
||||
%69 = OpAccessChain %_ptr_Function_mat4v3half %var_for_index %67
|
||||
%70 = OpLoad %mat4v3half %69
|
||||
%64 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %66 %70
|
||||
OpBranch %53
|
||||
%53 = OpLabel
|
||||
%71 = OpLoad %uint %i
|
||||
%72 = OpIAdd %uint %71 %uint_1
|
||||
OpStore %i %72
|
||||
OpBranch %51
|
||||
%52 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%conv_mat4x3_f16 = OpFunction %mat4v3half None %73
|
||||
%val = OpFunctionParameter %mat4x3_f16
|
||||
%76 = OpLabel
|
||||
%77 = OpCompositeExtract %v3half %val 0
|
||||
%78 = OpCompositeExtract %v3half %val 1
|
||||
%79 = OpCompositeExtract %v3half %val 2
|
||||
%80 = OpCompositeExtract %v3half %val 3
|
||||
%81 = OpCompositeConstruct %mat4v3half %77 %78 %79 %80
|
||||
OpReturnValue %81
|
||||
OpFunctionEnd
|
||||
%conv_arr4_mat4x3_f16 = OpFunction %_arr_mat4v3half_uint_4 None %82
|
||||
%val_0 = OpFunctionParameter %_arr_mat4x3_f16_uint_4
|
||||
%85 = OpLabel
|
||||
%arr = OpVariable %_ptr_Function__arr_mat4v3half_uint_4 Function %63
|
||||
%i_0 = OpVariable %_ptr_Function_uint Function %29
|
||||
%var_for_index_1 = OpVariable %_ptr_Function__arr_mat4x3_f16_uint_4 Function %99
|
||||
OpBranch %88
|
||||
%88 = OpLabel
|
||||
OpLoopMerge %89 %90 None
|
||||
OpBranch %91
|
||||
%91 = OpLabel
|
||||
%93 = OpLoad %uint %i_0
|
||||
%94 = OpULessThan %bool %93 %uint_4
|
||||
%92 = OpLogicalNot %bool %94
|
||||
OpSelectionMerge %95 None
|
||||
OpBranchConditional %92 %96 %95
|
||||
%96 = OpLabel
|
||||
OpBranch %89
|
||||
%95 = OpLabel
|
||||
OpStore %var_for_index_1 %val_0
|
||||
%100 = OpLoad %uint %i_0
|
||||
%101 = OpAccessChain %_ptr_Function_mat4v3half %arr %100
|
||||
%103 = OpLoad %uint %i_0
|
||||
%105 = OpAccessChain %_ptr_Function_mat4x3_f16 %var_for_index_1 %103
|
||||
%106 = OpLoad %mat4x3_f16 %105
|
||||
%102 = OpFunctionCall %mat4v3half %conv_mat4x3_f16 %106
|
||||
OpStore %101 %102
|
||||
OpBranch %90
|
||||
%90 = OpLabel
|
||||
%107 = OpLoad %uint %i_0
|
||||
%108 = OpIAdd %uint %107 %uint_1
|
||||
OpStore %i_0 %108
|
||||
OpBranch %88
|
||||
%89 = OpLabel
|
||||
%109 = OpLoad %_arr_mat4v3half_uint_4 %arr
|
||||
OpReturnValue %109
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %110
|
||||
%112 = OpLabel
|
||||
%116 = OpAccessChain %_ptr_Uniform__arr_mat4x3_f16_uint_4 %u %uint_0
|
||||
%117 = OpLoad %_arr_mat4x3_f16_uint_4 %116
|
||||
%114 = OpFunctionCall %_arr_mat4v3half_uint_4 %conv_arr4_mat4x3_f16 %117
|
||||
%113 = OpFunctionCall %void %assign_and_preserve_padding_s %114
|
||||
%122 = OpAccessChain %_ptr_Uniform_mat4x3_f16 %u %uint_0 %uint_2
|
||||
%123 = OpLoad %mat4x3_f16 %122
|
||||
%120 = OpFunctionCall %mat4v3half %conv_mat4x3_f16 %123
|
||||
%118 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %119 %120
|
||||
%124 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1 %25
|
||||
%126 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %29 %uint_1
|
||||
%127 = OpLoad %v3half %126
|
||||
%128 = OpVectorShuffle %v3half %127 %127 2 0 1
|
||||
OpStore %124 %128
|
||||
%130 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %int_1 %25 %uint_0
|
||||
%132 = OpAccessChain %_ptr_Uniform_half %u %uint_0 %29 %uint_1 %29
|
||||
%133 = OpLoad %half %132
|
||||
OpStore %130 %133
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user