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

@@ -8,8 +8,15 @@ layout(binding = 1, std430) buffer u_block_ssbo {
mat4x3 inner;
} s;
void assign_and_preserve_padding_s(mat4x3 value) {
s.inner[0] = value[0u];
s.inner[1] = value[1u];
s.inner[2] = value[2u];
s.inner[3] = value[3u];
}
void f() {
s.inner = u.inner;
assign_and_preserve_padding_s(u.inner);
s.inner[1] = u.inner[0];
s.inner[1] = u.inner[0].zxy;
s.inner[0][1] = u.inner[1][0];

View File

@@ -1,8 +1,15 @@
#include <metal_stdlib>
using namespace metal;
void assign_and_preserve_padding(device float4x3* const dest, float4x3 value) {
(*(dest))[0u] = value[0u];
(*(dest))[1u] = value[1u];
(*(dest))[2u] = value[2u];
(*(dest))[3u] = value[3u];
}
kernel void f(device float4x3* tint_symbol [[buffer(1)]], const constant float4x3* tint_symbol_1 [[buffer(0)]]) {
*(tint_symbol) = *(tint_symbol_1);
assign_and_preserve_padding(tint_symbol, *(tint_symbol_1));
(*(tint_symbol))[1] = (*(tint_symbol_1))[0];
(*(tint_symbol))[1] = float3((*(tint_symbol_1))[0]).zxy;
(*(tint_symbol))[0][1] = (*(tint_symbol_1))[1][0];

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 37
; Bound: 54
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -11,6 +11,8 @@
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %s "s"
OpName %assign_and_preserve_padding_s "assign_and_preserve_padding_s"
OpName %value "value"
OpName %f "f"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
@@ -30,36 +32,58 @@
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
%void = OpTypeVoid
%9 = OpTypeFunction %void
%9 = OpTypeFunction %void %mat4v3float
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_mat4v3float = OpTypePointer StorageBuffer %mat4v3float
%_ptr_Uniform_mat4v3float = OpTypePointer Uniform %mat4v3float
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%17 = OpConstantNull %int
%_ptr_StorageBuffer_v3float = OpTypePointer StorageBuffer %v3float
%24 = OpConstantNull %int
%20 = OpConstantNull %uint
%int_1 = OpConstant %int 1
%uint_1 = OpConstant %uint 1
%int_2 = OpConstant %int 2
%uint_2 = OpConstant %uint 2
%int_3 = OpConstant %int 3
%uint_3 = OpConstant %uint 3
%34 = OpTypeFunction %void
%_ptr_Uniform_mat4v3float = OpTypePointer Uniform %mat4v3float
%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
%_ptr_Uniform_float = OpTypePointer Uniform %float
%f = OpFunction %void None %9
%12 = OpLabel
%16 = OpAccessChain %_ptr_StorageBuffer_mat4v3float %s %uint_0
%18 = OpAccessChain %_ptr_Uniform_mat4v3float %u %uint_0
%19 = OpLoad %mat4v3float %18
OpStore %16 %19
%assign_and_preserve_padding_s = OpFunction %void None %9
%value = OpFunctionParameter %mat4v3float
%13 = OpLabel
%19 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %17
%21 = OpCompositeExtract %v3float %value 0
OpStore %19 %21
%23 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%26 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %24
%27 = OpLoad %v3float %26
OpStore %23 %27
%28 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%29 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %24
%30 = OpLoad %v3float %29
%31 = OpVectorShuffle %v3float %30 %30 2 0 1
OpStore %28 %31
%33 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_0 %24 %int_1
%35 = OpAccessChain %_ptr_Uniform_float %u %uint_0 %int_1 %24
%36 = OpLoad %float %35
OpStore %33 %36
%25 = OpCompositeExtract %v3float %value 1
OpStore %23 %25
%27 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_2
%29 = OpCompositeExtract %v3float %value 2
OpStore %27 %29
%31 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_3
%33 = OpCompositeExtract %v3float %value 3
OpStore %31 %33
OpReturn
OpFunctionEnd
%f = OpFunction %void None %34
%36 = OpLabel
%39 = OpAccessChain %_ptr_Uniform_mat4v3float %u %uint_0
%40 = OpLoad %mat4v3float %39
%37 = OpFunctionCall %void %assign_and_preserve_padding_s %40
%41 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%43 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %17
%44 = OpLoad %v3float %43
OpStore %41 %44
%45 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%46 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %17
%47 = OpLoad %v3float %46
%48 = OpVectorShuffle %v3float %47 %47 2 0 1
OpStore %45 %48
%50 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_0 %17 %int_1
%52 = OpAccessChain %_ptr_Uniform_float %u %uint_0 %int_1 %17
%53 = OpLoad %float %52
OpStore %50 %53
OpReturn
OpFunctionEnd