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

@@ -10,12 +10,17 @@ layout(binding = 1, std430) buffer u_block_ssbo {
f16mat2x3 inner;
} s;
void assign_and_preserve_padding_s(f16mat2x3 value) {
s.inner[0] = value[0u];
s.inner[1] = value[1u];
}
f16mat2x3 load_u_inner() {
return f16mat2x3(u.inner_0, u.inner_1);
}
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];

View File

@@ -1,8 +1,13 @@
#include <metal_stdlib>
using namespace metal;
void assign_and_preserve_padding(device half2x3* const dest, half2x3 value) {
(*(dest))[0u] = value[0u];
(*(dest))[1u] = value[1u];
}
kernel void f(device half2x3* tint_symbol [[buffer(1)]], const constant half2x3* 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];

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 49
; Bound: 56
; Schema: 0
OpCapability Shader
OpCapability Float16
@@ -18,6 +18,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
@@ -41,47 +43,57 @@
%u_block = OpTypeStruct %mat2v3half
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
%10 = OpTypeFunction %mat2v3half
%void = OpTypeVoid
%10 = OpTypeFunction %void %mat2v3half
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid
%25 = OpTypeFunction %void
%_ptr_StorageBuffer_mat2v3half = OpTypePointer StorageBuffer %mat2v3half
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%18 = OpConstantNull %int
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
%42 = OpConstantNull %int
%21 = OpConstantNull %uint
%int_1 = OpConstant %int 1
%uint_1 = OpConstant %uint 1
%27 = OpTypeFunction %mat2v3half
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%39 = OpTypeFunction %void
%_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half
%45 = OpConstantNull %uint
%_ptr_Uniform_half = OpTypePointer Uniform %half
%load_u_inner = OpFunction %mat2v3half 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
%24 = OpCompositeConstruct %mat2v3half %19 %23
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25
%28 = OpLabel
%30 = OpAccessChain %_ptr_StorageBuffer_mat2v3half %s %uint_0
%31 = OpFunctionCall %mat2v3half %load_u_inner
OpStore %30 %31
%35 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%36 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%37 = OpLoad %v3half %36
OpStore %35 %37
%38 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%39 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%40 = OpLoad %v3half %39
%41 = OpVectorShuffle %v3half %40 %40 2 0 1
OpStore %38 %41
%44 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %42 %int_1
%47 = OpAccessChain %_ptr_Uniform_half %u %uint_1 %45
%48 = OpLoad %half %47
OpStore %44 %48
%assign_and_preserve_padding_s = OpFunction %void None %10
%value = OpFunctionParameter %mat2v3half
%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
OpReturn
OpFunctionEnd
%load_u_inner = OpFunction %mat2v3half None %27
%29 = OpLabel
%33 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%34 = OpLoad %v3half %33
%36 = OpAccessChain %_ptr_Uniform_v3half %u %uint_1
%37 = OpLoad %v3half %36
%38 = OpCompositeConstruct %mat2v3half %34 %37
OpReturnValue %38
OpFunctionEnd
%f = OpFunction %void None %39
%41 = OpLabel
%43 = OpFunctionCall %mat2v3half %load_u_inner
%42 = OpFunctionCall %void %assign_and_preserve_padding_s %43
%44 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%45 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%46 = OpLoad %v3half %45
OpStore %44 %46
%47 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%48 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%49 = OpLoad %v3half %48
%50 = OpVectorShuffle %v3half %49 %49 2 0 1
OpStore %47 %50
%52 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %18 %int_1
%54 = OpAccessChain %_ptr_Uniform_half %u %uint_1 %21
%55 = OpLoad %half %54
OpStore %52 %55
OpReturn
OpFunctionEnd

View File

@@ -8,8 +8,13 @@ layout(binding = 1, std430) buffer u_block_ssbo {
mat2x3 inner;
} s;
void assign_and_preserve_padding_s(mat2x3 value) {
s.inner[0] = value[0u];
s.inner[1] = value[1u];
}
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,13 @@
#include <metal_stdlib>
using namespace metal;
void assign_and_preserve_padding(device float2x3* const dest, float2x3 value) {
(*(dest))[0u] = value[0u];
(*(dest))[1u] = value[1u];
}
kernel void f(device float2x3* tint_symbol [[buffer(1)]], const constant float2x3* 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: 46
; 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,48 @@
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
%void = OpTypeVoid
%9 = OpTypeFunction %void
%9 = OpTypeFunction %void %mat2v3float
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_mat2v3float = OpTypePointer StorageBuffer %mat2v3float
%_ptr_Uniform_mat2v3float = OpTypePointer Uniform %mat2v3float
%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
%26 = OpTypeFunction %void
%_ptr_Uniform_mat2v3float = OpTypePointer Uniform %mat2v3float
%_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_mat2v3float %s %uint_0
%18 = OpAccessChain %_ptr_Uniform_mat2v3float %u %uint_0
%19 = OpLoad %mat2v3float %18
OpStore %16 %19
%assign_and_preserve_padding_s = OpFunction %void None %9
%value = OpFunctionParameter %mat2v3float
%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
OpReturn
OpFunctionEnd
%f = OpFunction %void None %26
%28 = OpLabel
%31 = OpAccessChain %_ptr_Uniform_mat2v3float %u %uint_0
%32 = OpLoad %mat2v3float %31
%29 = OpFunctionCall %void %assign_and_preserve_padding_s %32
%33 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%35 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %17
%36 = OpLoad %v3float %35
OpStore %33 %36
%37 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%38 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %17
%39 = OpLoad %v3float %38
%40 = OpVectorShuffle %v3float %39 %39 2 0 1
OpStore %37 %40
%42 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_0 %17 %int_1
%44 = OpAccessChain %_ptr_Uniform_float %u %uint_0 %int_1 %17
%45 = OpLoad %float %44
OpStore %42 %45
OpReturn
OpFunctionEnd

View File

@@ -11,12 +11,18 @@ layout(binding = 1, std430) buffer u_block_ssbo {
f16mat3 inner;
} s;
void assign_and_preserve_padding_s(f16mat3 value) {
s.inner[0] = value[0u];
s.inner[1] = value[1u];
s.inner[2] = value[2u];
}
f16mat3 load_u_inner() {
return f16mat3(u.inner_0, u.inner_1, u.inner_2);
}
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];

View File

@@ -1,8 +1,14 @@
#include <metal_stdlib>
using namespace metal;
void assign_and_preserve_padding(device half3x3* const dest, half3x3 value) {
(*(dest))[0u] = value[0u];
(*(dest))[1u] = value[1u];
(*(dest))[2u] = value[2u];
}
kernel void f(device half3x3* tint_symbol [[buffer(1)]], const constant half3x3* 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];

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 53
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float16
@@ -19,6 +19,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
@@ -43,50 +45,64 @@
%u_block = OpTypeStruct %mat3v3half
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
%10 = OpTypeFunction %mat3v3half
%void = OpTypeVoid
%10 = OpTypeFunction %void %mat3v3half
%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
%void = OpTypeVoid
%29 = OpTypeFunction %void
%_ptr_StorageBuffer_mat3v3half = OpTypePointer StorageBuffer %mat3v3half
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%18 = OpConstantNull %int
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
%46 = 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
%31 = OpTypeFunction %mat3v3half
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%46 = OpTypeFunction %void
%_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half
%49 = OpConstantNull %uint
%_ptr_Uniform_half = OpTypePointer Uniform %half
%load_u_inner = OpFunction %mat3v3half 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
%28 = OpCompositeConstruct %mat3v3half %19 %23 %27
OpReturnValue %28
OpFunctionEnd
%f = OpFunction %void None %29
%32 = OpLabel
%34 = OpAccessChain %_ptr_StorageBuffer_mat3v3half %s %uint_0
%35 = OpFunctionCall %mat3v3half %load_u_inner
OpStore %34 %35
%39 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%40 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%41 = OpLoad %v3half %40
OpStore %39 %41
%42 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%43 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%44 = OpLoad %v3half %43
%45 = OpVectorShuffle %v3half %44 %44 2 0 1
OpStore %42 %45
%48 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %46 %int_1
%51 = OpAccessChain %_ptr_Uniform_half %u %uint_1 %49
%52 = OpLoad %half %51
OpStore %48 %52
%assign_and_preserve_padding_s = OpFunction %void None %10
%value = OpFunctionParameter %mat3v3half
%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
OpReturn
OpFunctionEnd
%load_u_inner = OpFunction %mat3v3half None %31
%33 = OpLabel
%37 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%38 = OpLoad %v3half %37
%40 = OpAccessChain %_ptr_Uniform_v3half %u %uint_1
%41 = OpLoad %v3half %40
%43 = OpAccessChain %_ptr_Uniform_v3half %u %uint_2
%44 = OpLoad %v3half %43
%45 = OpCompositeConstruct %mat3v3half %38 %41 %44
OpReturnValue %45
OpFunctionEnd
%f = OpFunction %void None %46
%48 = OpLabel
%50 = OpFunctionCall %mat3v3half %load_u_inner
%49 = OpFunctionCall %void %assign_and_preserve_padding_s %50
%51 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%52 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%53 = OpLoad %v3half %52
OpStore %51 %53
%54 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1
%55 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0
%56 = OpLoad %v3half %55
%57 = OpVectorShuffle %v3half %56 %56 2 0 1
OpStore %54 %57
%59 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %18 %int_1
%61 = OpAccessChain %_ptr_Uniform_half %u %uint_1 %21
%62 = OpLoad %half %61
OpStore %59 %62
OpReturn
OpFunctionEnd

View File

@@ -8,8 +8,14 @@ layout(binding = 1, std430) buffer u_block_ssbo {
mat3 inner;
} s;
void assign_and_preserve_padding_s(mat3 value) {
s.inner[0] = value[0u];
s.inner[1] = value[1u];
s.inner[2] = value[2u];
}
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,14 @@
#include <metal_stdlib>
using namespace metal;
void assign_and_preserve_padding(device float3x3* const dest, float3x3 value) {
(*(dest))[0u] = value[0u];
(*(dest))[1u] = value[1u];
(*(dest))[2u] = value[2u];
}
kernel void f(device float3x3* tint_symbol [[buffer(1)]], const constant float3x3* 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: 50
; 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,53 @@
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
%void = OpTypeVoid
%9 = OpTypeFunction %void
%9 = OpTypeFunction %void %mat3v3float
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_mat3v3float = OpTypePointer StorageBuffer %mat3v3float
%_ptr_Uniform_mat3v3float = OpTypePointer Uniform %mat3v3float
%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
%30 = OpTypeFunction %void
%_ptr_Uniform_mat3v3float = OpTypePointer Uniform %mat3v3float
%_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_mat3v3float %s %uint_0
%18 = OpAccessChain %_ptr_Uniform_mat3v3float %u %uint_0
%19 = OpLoad %mat3v3float %18
OpStore %16 %19
%assign_and_preserve_padding_s = OpFunction %void None %9
%value = OpFunctionParameter %mat3v3float
%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
OpReturn
OpFunctionEnd
%f = OpFunction %void None %30
%32 = OpLabel
%35 = OpAccessChain %_ptr_Uniform_mat3v3float %u %uint_0
%36 = OpLoad %mat3v3float %35
%33 = OpFunctionCall %void %assign_and_preserve_padding_s %36
%37 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%39 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %17
%40 = OpLoad %v3float %39
OpStore %37 %40
%41 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %int_1
%42 = OpAccessChain %_ptr_Uniform_v3float %u %uint_0 %17
%43 = OpLoad %v3float %42
%44 = OpVectorShuffle %v3float %43 %43 2 0 1
OpStore %41 %44
%46 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_0 %17 %int_1
%48 = OpAccessChain %_ptr_Uniform_float %u %uint_0 %int_1 %17
%49 = OpLoad %float %48
OpStore %46 %49
OpReturn
OpFunctionEnd

View File

@@ -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];

View File

@@ -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];

View File

@@ -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

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