mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +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
@@ -12,12 +12,19 @@ layout(binding = 1, std430) buffer u_block_ssbo {
|
||||
f16mat4x3 inner;
|
||||
} s;
|
||||
|
||||
void assign_and_preserve_padding_s(f16mat4x3 value) {
|
||||
s.inner[0] = value[0u];
|
||||
s.inner[1] = value[1u];
|
||||
s.inner[2] = value[2u];
|
||||
s.inner[3] = value[3u];
|
||||
}
|
||||
|
||||
f16mat4x3 load_u_inner() {
|
||||
return f16mat4x3(u.inner_0, u.inner_1, u.inner_2, u.inner_3);
|
||||
}
|
||||
|
||||
void f() {
|
||||
s.inner = load_u_inner();
|
||||
assign_and_preserve_padding_s(load_u_inner());
|
||||
s.inner[1] = u.inner_0;
|
||||
s.inner[1] = u.inner_0.zxy;
|
||||
s.inner[0][1] = u.inner_1[0u];
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void assign_and_preserve_padding(device half4x3* const dest, half4x3 value) {
|
||||
(*(dest))[0u] = value[0u];
|
||||
(*(dest))[1u] = value[1u];
|
||||
(*(dest))[2u] = value[2u];
|
||||
(*(dest))[3u] = value[3u];
|
||||
}
|
||||
|
||||
kernel void f(device half4x3* tint_symbol [[buffer(1)]], const constant half4x3* 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] = half3((*(tint_symbol_1))[0]).zxy;
|
||||
(*(tint_symbol))[0][1] = (*(tint_symbol_1))[1][0];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 57
|
||||
; Bound: 70
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpCapability Float16
|
||||
@@ -20,6 +20,8 @@
|
||||
OpName %u_block "u_block"
|
||||
OpMemberName %u_block 0 "inner"
|
||||
OpName %s "s"
|
||||
OpName %assign_and_preserve_padding_s "assign_and_preserve_padding_s"
|
||||
OpName %value "value"
|
||||
OpName %load_u_inner "load_u_inner"
|
||||
OpName %f "f"
|
||||
OpDecorate %u_block_std140 Block
|
||||
@@ -45,53 +47,71 @@
|
||||
%u_block = OpTypeStruct %mat4v3half
|
||||
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
|
||||
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
|
||||
%10 = OpTypeFunction %mat4v3half
|
||||
%void = OpTypeVoid
|
||||
%10 = OpTypeFunction %void %mat4v3half
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%void = OpTypeVoid
|
||||
%33 = OpTypeFunction %void
|
||||
%_ptr_StorageBuffer_mat4v3half = OpTypePointer StorageBuffer %mat4v3half
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%18 = OpConstantNull %int
|
||||
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
|
||||
%50 = OpConstantNull %int
|
||||
%21 = 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
|
||||
%35 = OpTypeFunction %mat4v3half
|
||||
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
|
||||
%53 = OpTypeFunction %void
|
||||
%_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half
|
||||
%53 = OpConstantNull %uint
|
||||
%_ptr_Uniform_half = OpTypePointer Uniform %half
|
||||
%load_u_inner = OpFunction %mat4v3half None %10
|
||||
%12 = OpLabel
|
||||
%18 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
|
||||
%19 = OpLoad %v3half %18
|
||||
%22 = OpAccessChain %_ptr_Uniform_v3half %u %uint_1
|
||||
%23 = OpLoad %v3half %22
|
||||
%26 = OpAccessChain %_ptr_Uniform_v3half %u %uint_2
|
||||
%27 = OpLoad %v3half %26
|
||||
%30 = OpAccessChain %_ptr_Uniform_v3half %u %uint_3
|
||||
%31 = OpLoad %v3half %30
|
||||
%32 = OpCompositeConstruct %mat4v3half %19 %23 %27 %31
|
||||
OpReturnValue %32
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %33
|
||||
%36 = OpLabel
|
||||
%38 = OpAccessChain %_ptr_StorageBuffer_mat4v3half %s %uint_0
|
||||
%39 = OpFunctionCall %mat4v3half %load_u_inner
|
||||
OpStore %38 %39
|
||||
%43 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
|
||||
%44 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
|
||||
%45 = OpLoad %v3half %44
|
||||
OpStore %43 %45
|
||||
%46 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
|
||||
%47 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
|
||||
%48 = OpLoad %v3half %47
|
||||
%49 = OpVectorShuffle %v3half %48 %48 2 0 1
|
||||
OpStore %46 %49
|
||||
%52 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %50 %int_1
|
||||
%55 = OpAccessChain %_ptr_Uniform_half %u %uint_1 %53
|
||||
%56 = OpLoad %half %55
|
||||
OpStore %52 %56
|
||||
%assign_and_preserve_padding_s = OpFunction %void None %10
|
||||
%value = OpFunctionParameter %mat4v3half
|
||||
%14 = OpLabel
|
||||
%20 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %18
|
||||
%22 = OpCompositeExtract %v3half %value 0
|
||||
OpStore %20 %22
|
||||
%24 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
|
||||
%26 = OpCompositeExtract %v3half %value 1
|
||||
OpStore %24 %26
|
||||
%28 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_2
|
||||
%30 = OpCompositeExtract %v3half %value 2
|
||||
OpStore %28 %30
|
||||
%32 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_3
|
||||
%34 = OpCompositeExtract %v3half %value 3
|
||||
OpStore %32 %34
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%load_u_inner = OpFunction %mat4v3half None %35
|
||||
%37 = OpLabel
|
||||
%41 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
|
||||
%42 = OpLoad %v3half %41
|
||||
%44 = OpAccessChain %_ptr_Uniform_v3half %u %uint_1
|
||||
%45 = OpLoad %v3half %44
|
||||
%47 = OpAccessChain %_ptr_Uniform_v3half %u %uint_2
|
||||
%48 = OpLoad %v3half %47
|
||||
%50 = OpAccessChain %_ptr_Uniform_v3half %u %uint_3
|
||||
%51 = OpLoad %v3half %50
|
||||
%52 = OpCompositeConstruct %mat4v3half %42 %45 %48 %51
|
||||
OpReturnValue %52
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %53
|
||||
%55 = OpLabel
|
||||
%57 = OpFunctionCall %mat4v3half %load_u_inner
|
||||
%56 = OpFunctionCall %void %assign_and_preserve_padding_s %57
|
||||
%58 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
|
||||
%59 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
|
||||
%60 = OpLoad %v3half %59
|
||||
OpStore %58 %60
|
||||
%61 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
|
||||
%62 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
|
||||
%63 = OpLoad %v3half %62
|
||||
%64 = OpVectorShuffle %v3half %63 %63 2 0 1
|
||||
OpStore %61 %64
|
||||
%66 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %18 %int_1
|
||||
%68 = OpAccessChain %_ptr_Uniform_half %u %uint_1 %21
|
||||
%69 = OpLoad %half %68
|
||||
OpStore %66 %69
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user