mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56: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
@@ -44,26 +44,35 @@ layout(binding = 1, std430) buffer u_block_ssbo {
|
||||
S inner[4];
|
||||
} s;
|
||||
|
||||
void assign_and_preserve_padding_2_s_X_m(uint dest[1], mat4x3 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void f() {
|
||||
assign_and_preserve_padding_s(u.inner);
|
||||
uint tint_symbol_1[1] = uint[1](1u);
|
||||
assign_and_preserve_padding_1_s_X(tint_symbol_1, u.inner[2]);
|
||||
s.inner[3].m = u.inner[2].m;
|
||||
uint tint_symbol_2[1] = uint[1](1u);
|
||||
assign_and_preserve_padding_1_s_X(tint_symbol_2, u.inner[2]);
|
||||
uint tint_symbol_3[1] = uint[1](3u);
|
||||
assign_and_preserve_padding_2_s_X_m(tint_symbol_3, u.inner[2].m);
|
||||
s.inner[1].m[0] = u.inner[0].m[1].zxy;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,16 @@ struct S {
|
||||
/* 0x0084 */ tint_array<int8_t, 60> tint_pad_2;
|
||||
};
|
||||
|
||||
void assign_and_preserve_padding_2(device float4x3* const dest, float4x3 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] = float3((*(tint_symbol_1))[0].m[1]).zxy;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 90
|
||||
; Bound: 109
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
@@ -15,11 +15,14 @@
|
||||
OpMemberName %S 2 "after"
|
||||
OpName %u "u"
|
||||
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 %f "f"
|
||||
@@ -53,98 +56,121 @@
|
||||
%void = OpTypeVoid
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%_arr_uint_uint_1 = OpTypeArray %uint %uint_1
|
||||
%14 = OpTypeFunction %void %_arr_uint_uint_1 %S
|
||||
%14 = OpTypeFunction %void %_arr_uint_uint_1 %mat4v3float
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%23 = OpConstantNull %int
|
||||
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
|
||||
%_ptr_StorageBuffer_mat4v3float = OpTypePointer StorageBuffer %mat4v3float
|
||||
%_ptr_StorageBuffer_v3float = OpTypePointer StorageBuffer %v3float
|
||||
%27 = OpConstantNull %uint
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%36 = OpTypeFunction %void %_arr_S_uint_4
|
||||
%40 = OpConstantNull %uint
|
||||
%int_3 = OpConstant %int 3
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%43 = OpTypeFunction %void %_arr_uint_uint_1 %S
|
||||
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
|
||||
%59 = 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
|
||||
%55 = OpConstantNull %_arr_S_uint_4
|
||||
%77 = OpConstantNull %_arr_S_uint_4
|
||||
%_ptr_Function_S = OpTypePointer Function %S
|
||||
%65 = OpTypeFunction %void
|
||||
%87 = OpTypeFunction %void
|
||||
%_ptr_Uniform__arr_S_uint_4 = OpTypePointer Uniform %_arr_S_uint_4
|
||||
%73 = OpConstantComposite %_arr_uint_uint_1 %uint_1
|
||||
%int_2 = OpConstant %int 2
|
||||
%95 = OpConstantComposite %_arr_uint_uint_1 %uint_1
|
||||
%_ptr_Uniform_S = OpTypePointer Uniform %S
|
||||
%int_3 = OpConstant %int 3
|
||||
%100 = OpConstantComposite %_arr_uint_uint_1 %uint_3
|
||||
%_ptr_Uniform_mat4v3float = OpTypePointer Uniform %mat4v3float
|
||||
%int_1 = OpConstant %int 1
|
||||
%_ptr_StorageBuffer_v3float = OpTypePointer StorageBuffer %v3float
|
||||
%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
|
||||
%assign_and_preserve_padding_1_s_X = OpFunction %void None %14
|
||||
%assign_and_preserve_padding_2_s_X_m = OpFunction %void None %14
|
||||
%dest = OpFunctionParameter %_arr_uint_uint_1
|
||||
%value = OpFunctionParameter %S
|
||||
%value = OpFunctionParameter %mat4v3float
|
||||
%21 = OpLabel
|
||||
%24 = OpCompositeExtract %uint %dest 0
|
||||
%26 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %24 %uint_0
|
||||
%27 = OpCompositeExtract %int %value 0
|
||||
OpStore %26 %27
|
||||
%28 = OpCompositeExtract %uint %dest 0
|
||||
%30 = OpAccessChain %_ptr_StorageBuffer_mat4v3float %s %uint_0 %28 %uint_1
|
||||
%31 = OpCompositeExtract %mat4v3float %value 1
|
||||
OpStore %30 %31
|
||||
%32 = OpCompositeExtract %uint %dest 0
|
||||
%34 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %32 %uint_2
|
||||
%35 = OpCompositeExtract %int %value 2
|
||||
OpStore %34 %35
|
||||
%26 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %24 %uint_1 %23
|
||||
%28 = OpCompositeExtract %v3float %value 0
|
||||
OpStore %26 %28
|
||||
%29 = OpCompositeExtract %uint %dest 0
|
||||
%31 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %29 %uint_1 %int_1
|
||||
%32 = OpCompositeExtract %v3float %value 1
|
||||
OpStore %31 %32
|
||||
%33 = OpCompositeExtract %uint %dest 0
|
||||
%35 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %33 %uint_1 %int_2
|
||||
%37 = OpCompositeExtract %v3float %value 2
|
||||
OpStore %35 %37
|
||||
%38 = OpCompositeExtract %uint %dest 0
|
||||
%40 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %38 %uint_1 %int_3
|
||||
%42 = OpCompositeExtract %v3float %value 3
|
||||
OpStore %40 %42
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%assign_and_preserve_padding_s = OpFunction %void None %36
|
||||
%value_0 = OpFunctionParameter %_arr_S_uint_4
|
||||
%39 = OpLabel
|
||||
%i = OpVariable %_ptr_Function_uint Function %40
|
||||
%var_for_index = OpVariable %_ptr_Function__arr_S_uint_4 Function %55
|
||||
OpStore %i %40
|
||||
OpBranch %43
|
||||
%43 = OpLabel
|
||||
OpLoopMerge %44 %45 None
|
||||
OpBranch %46
|
||||
%46 = OpLabel
|
||||
%48 = OpLoad %uint %i
|
||||
%49 = OpULessThan %bool %48 %uint_4
|
||||
%47 = OpLogicalNot %bool %49
|
||||
OpSelectionMerge %51 None
|
||||
OpBranchConditional %47 %52 %51
|
||||
%52 = OpLabel
|
||||
OpBranch %44
|
||||
%51 = OpLabel
|
||||
OpStore %var_for_index %value_0
|
||||
%57 = OpLoad %uint %i
|
||||
%58 = OpCompositeConstruct %_arr_uint_uint_1 %57
|
||||
%59 = OpLoad %uint %i
|
||||
%61 = OpAccessChain %_ptr_Function_S %var_for_index %59
|
||||
%62 = OpLoad %S %61
|
||||
%56 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %58 %62
|
||||
OpBranch %45
|
||||
%45 = OpLabel
|
||||
%63 = OpLoad %uint %i
|
||||
%64 = OpIAdd %uint %63 %uint_1
|
||||
OpStore %i %64
|
||||
OpBranch %43
|
||||
%44 = OpLabel
|
||||
%assign_and_preserve_padding_1_s_X = OpFunction %void None %43
|
||||
%dest_0 = OpFunctionParameter %_arr_uint_uint_1
|
||||
%value_0 = OpFunctionParameter %S
|
||||
%47 = OpLabel
|
||||
%48 = OpCompositeExtract %uint %dest_0 0
|
||||
%50 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %48 %uint_0
|
||||
%51 = OpCompositeExtract %int %value_0 0
|
||||
OpStore %50 %51
|
||||
%53 = OpCompositeExtract %uint %dest_0 0
|
||||
%54 = OpCompositeConstruct %_arr_uint_uint_1 %53
|
||||
%55 = OpCompositeExtract %mat4v3float %value_0 1
|
||||
%52 = OpFunctionCall %void %assign_and_preserve_padding_2_s_X_m %54 %55
|
||||
%56 = OpCompositeExtract %uint %dest_0 0
|
||||
%57 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %56 %uint_2
|
||||
%58 = OpCompositeExtract %int %value_0 2
|
||||
OpStore %57 %58
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %65
|
||||
%assign_and_preserve_padding_s = OpFunction %void None %59
|
||||
%value_1 = OpFunctionParameter %_arr_S_uint_4
|
||||
%62 = OpLabel
|
||||
%i = OpVariable %_ptr_Function_uint Function %27
|
||||
%var_for_index = OpVariable %_ptr_Function__arr_S_uint_4 Function %77
|
||||
OpStore %i %27
|
||||
OpBranch %65
|
||||
%65 = OpLabel
|
||||
OpLoopMerge %66 %67 None
|
||||
OpBranch %68
|
||||
%68 = OpLabel
|
||||
%70 = OpLoad %uint %i
|
||||
%71 = OpULessThan %bool %70 %uint_4
|
||||
%69 = OpLogicalNot %bool %71
|
||||
OpSelectionMerge %73 None
|
||||
OpBranchConditional %69 %74 %73
|
||||
%74 = OpLabel
|
||||
OpBranch %66
|
||||
%73 = OpLabel
|
||||
OpStore %var_for_index %value_1
|
||||
%79 = OpLoad %uint %i
|
||||
%80 = OpCompositeConstruct %_arr_uint_uint_1 %79
|
||||
%81 = OpLoad %uint %i
|
||||
%83 = OpAccessChain %_ptr_Function_S %var_for_index %81
|
||||
%84 = OpLoad %S %83
|
||||
%78 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %80 %84
|
||||
OpBranch %67
|
||||
%67 = OpLabel
|
||||
%70 = OpAccessChain %_ptr_Uniform__arr_S_uint_4 %u %uint_0
|
||||
%71 = OpLoad %_arr_S_uint_4 %70
|
||||
%68 = OpFunctionCall %void %assign_and_preserve_padding_s %71
|
||||
%76 = OpAccessChain %_ptr_Uniform_S %u %uint_0 %int_2
|
||||
%77 = OpLoad %S %76
|
||||
%72 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %73 %77
|
||||
%79 = OpAccessChain %_ptr_StorageBuffer_mat4v3float %s %uint_0 %int_3 %uint_1
|
||||
%81 = OpAccessChain %_ptr_Uniform_mat4v3float %u %uint_0 %int_2 %uint_1
|
||||
%82 = OpLoad %mat4v3float %81
|
||||
OpStore %79 %82
|
||||
%85 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1 %uint_1 %23
|
||||
%87 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %23 %uint_1 %int_1
|
||||
%88 = OpLoad %v3float %87
|
||||
%89 = OpVectorShuffle %v3float %88 %88 2 0 1
|
||||
OpStore %85 %89
|
||||
%85 = OpLoad %uint %i
|
||||
%86 = OpIAdd %uint %85 %uint_1
|
||||
OpStore %i %86
|
||||
OpBranch %65
|
||||
%66 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %87
|
||||
%89 = OpLabel
|
||||
%92 = OpAccessChain %_ptr_Uniform__arr_S_uint_4 %u %uint_0
|
||||
%93 = OpLoad %_arr_S_uint_4 %92
|
||||
%90 = OpFunctionCall %void %assign_and_preserve_padding_s %93
|
||||
%97 = OpAccessChain %_ptr_Uniform_S %u %uint_0 %int_2
|
||||
%98 = OpLoad %S %97
|
||||
%94 = OpFunctionCall %void %assign_and_preserve_padding_1_s_X %95 %98
|
||||
%102 = OpAccessChain %_ptr_Uniform_mat4v3float %u %uint_0 %int_2 %uint_1
|
||||
%103 = OpLoad %mat4v3float %102
|
||||
%99 = OpFunctionCall %void %assign_and_preserve_padding_2_s_X_m %100 %103
|
||||
%104 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1 %uint_1 %23
|
||||
%106 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %23 %uint_1 %int_1
|
||||
%107 = OpLoad %v3float %106
|
||||
%108 = OpVectorShuffle %v3float %107 %107 2 0 1
|
||||
OpStore %104 %108
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user