Tint/transform: make AddBlockAttribute always do wrapping if possible

This CL make transform AddBlockAttribute always try to wrap types used
by buffer variables into a struct, in order to generate valid GLSL code
for assigning one buffer struct variable to another buffer struct
variable.

Fixed: tint:1735
Change-Id: I009d8a9ca7ecea1dc0ad6164275c964a18acb33f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108023
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
Zhaoming Jiang
2022-11-02 02:25:38 +00:00
committed by Dawn LUCI CQ
parent 2bea9055f4
commit 6ab5d3c151
465 changed files with 15681 additions and 12853 deletions

View File

@@ -4,7 +4,7 @@ struct Inner {
int x;
};
layout(binding = 0, std430) buffer S_ssbo {
struct S {
ivec3 a;
int b;
uvec3 c;
@@ -16,19 +16,23 @@ layout(binding = 0, std430) buffer S_ssbo {
Inner i;
Inner j[4];
uint pad;
};
layout(binding = 0, std430) buffer s_block_ssbo {
S inner;
} s;
void tint_symbol() {
ivec3 a = s.a;
int b = s.b;
uvec3 c = s.c;
uint d = s.d;
vec3 e = s.e;
float f = s.f;
mat2x3 g = s.g;
mat3x2 h = s.h;
Inner i = s.i;
Inner j[4] = s.j;
ivec3 a = s.inner.a;
int b = s.inner.b;
uvec3 c = s.inner.c;
uint d = s.inner.d;
vec3 e = s.inner.e;
float f = s.inner.f;
mat2x3 g = s.inner.g;
mat3x2 h = s.inner.h;
Inner i = s.inner.i;
Inner j[4] = s.inner.j;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@@ -1,12 +1,14 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 59
; Bound: 60
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %s_block "s_block"
OpMemberName %s_block 0 "inner"
OpName %S "S"
OpMemberName %S 0 "a"
OpMemberName %S 1 "b"
@@ -22,7 +24,8 @@
OpMemberName %S 9 "j"
OpName %s "s"
OpName %main "main"
OpDecorate %S Block
OpDecorate %s_block Block
OpMemberDecorate %s_block 0 Offset 0
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %S 1 Offset 12
OpMemberDecorate %S 2 Offset 16
@@ -55,10 +58,11 @@
%uint_4 = OpConstant %uint 4
%_arr_Inner_uint_4 = OpTypeArray %Inner %uint_4
%S = OpTypeStruct %v3int %int %v3uint %uint %v3float %float %mat2v3float %mat3v2float %Inner %_arr_Inner_uint_4
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
%s = OpVariable %_ptr_StorageBuffer_S StorageBuffer
%s_block = OpTypeStruct %S
%_ptr_StorageBuffer_s_block = OpTypePointer StorageBuffer %s_block
%s = OpVariable %_ptr_StorageBuffer_s_block StorageBuffer
%void = OpTypeVoid
%16 = OpTypeFunction %void
%17 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v3int = OpTypePointer StorageBuffer %v3int
%uint_1 = OpConstant %uint 1
@@ -78,27 +82,27 @@
%_ptr_StorageBuffer_Inner = OpTypePointer StorageBuffer %Inner
%uint_9 = OpConstant %uint 9
%_ptr_StorageBuffer__arr_Inner_uint_4 = OpTypePointer StorageBuffer %_arr_Inner_uint_4
%main = OpFunction %void None %16
%19 = OpLabel
%22 = OpAccessChain %_ptr_StorageBuffer_v3int %s %uint_0
%23 = OpLoad %v3int %22
%26 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_1
%27 = OpLoad %int %26
%30 = OpAccessChain %_ptr_StorageBuffer_v3uint %s %uint_2
%31 = OpLoad %v3uint %30
%34 = OpAccessChain %_ptr_StorageBuffer_uint %s %uint_3
%35 = OpLoad %uint %34
%37 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_4
%38 = OpLoad %v3float %37
%41 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_5
%42 = OpLoad %float %41
%45 = OpAccessChain %_ptr_StorageBuffer_mat2v3float %s %uint_6
%46 = OpLoad %mat2v3float %45
%49 = OpAccessChain %_ptr_StorageBuffer_mat3v2float %s %uint_7
%50 = OpLoad %mat3v2float %49
%53 = OpAccessChain %_ptr_StorageBuffer_Inner %s %uint_8
%54 = OpLoad %Inner %53
%57 = OpAccessChain %_ptr_StorageBuffer__arr_Inner_uint_4 %s %uint_9
%58 = OpLoad %_arr_Inner_uint_4 %57
%main = OpFunction %void None %17
%20 = OpLabel
%23 = OpAccessChain %_ptr_StorageBuffer_v3int %s %uint_0 %uint_0
%24 = OpLoad %v3int %23
%27 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %uint_1
%28 = OpLoad %int %27
%31 = OpAccessChain %_ptr_StorageBuffer_v3uint %s %uint_0 %uint_2
%32 = OpLoad %v3uint %31
%35 = OpAccessChain %_ptr_StorageBuffer_uint %s %uint_0 %uint_3
%36 = OpLoad %uint %35
%38 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %uint_4
%39 = OpLoad %v3float %38
%42 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_0 %uint_5
%43 = OpLoad %float %42
%46 = OpAccessChain %_ptr_StorageBuffer_mat2v3float %s %uint_0 %uint_6
%47 = OpLoad %mat2v3float %46
%50 = OpAccessChain %_ptr_StorageBuffer_mat3v2float %s %uint_0 %uint_7
%51 = OpLoad %mat3v2float %50
%54 = OpAccessChain %_ptr_StorageBuffer_Inner %s %uint_0 %uint_8
%55 = OpLoad %Inner %54
%58 = OpAccessChain %_ptr_StorageBuffer__arr_Inner_uint_4 %s %uint_0 %uint_9
%59 = OpLoad %_arr_Inner_uint_4 %58
OpReturn
OpFunctionEnd

View File

@@ -4,7 +4,7 @@ struct Inner {
int x;
};
layout(binding = 0, std430) buffer S_ssbo {
struct S {
ivec3 a;
int b;
uvec3 c;
@@ -16,21 +16,25 @@ layout(binding = 0, std430) buffer S_ssbo {
Inner i;
Inner j[4];
uint pad;
};
layout(binding = 0, std430) buffer s_block_ssbo {
S inner;
} s;
void tint_symbol() {
s.a = ivec3(0);
s.b = 0;
s.c = uvec3(0u);
s.d = 0u;
s.e = vec3(0.0f);
s.f = 0.0f;
s.g = mat2x3(vec3(0.0f), vec3(0.0f));
s.h = mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f));
s.inner.a = ivec3(0);
s.inner.b = 0;
s.inner.c = uvec3(0u);
s.inner.d = 0u;
s.inner.e = vec3(0.0f);
s.inner.f = 0.0f;
s.inner.g = mat2x3(vec3(0.0f), vec3(0.0f));
s.inner.h = mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f));
Inner tint_symbol_1 = Inner(0);
s.i = tint_symbol_1;
s.inner.i = tint_symbol_1;
Inner tint_symbol_2[4] = Inner[4](Inner(0), Inner(0), Inner(0), Inner(0));
s.j = tint_symbol_2;
s.inner.j = tint_symbol_2;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@@ -1,12 +1,14 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 59
; Bound: 60
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %s_block "s_block"
OpMemberName %s_block 0 "inner"
OpName %S "S"
OpMemberName %S 0 "a"
OpMemberName %S 1 "b"
@@ -22,7 +24,8 @@
OpMemberName %S 9 "j"
OpName %s "s"
OpName %main "main"
OpDecorate %S Block
OpDecorate %s_block Block
OpMemberDecorate %s_block 0 Offset 0
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %S 1 Offset 12
OpMemberDecorate %S 2 Offset 16
@@ -54,60 +57,61 @@
%uint_4 = OpConstant %uint 4
%_arr_Inner_uint_4 = OpTypeArray %Inner %uint_4
%S = OpTypeStruct %v3int %int %v3uint %uint %v3float %float %mat2v3float %mat3v2float %Inner %_arr_Inner_uint_4
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
%s = OpVariable %_ptr_StorageBuffer_S StorageBuffer
%s_block = OpTypeStruct %S
%_ptr_StorageBuffer_s_block = OpTypePointer StorageBuffer %s_block
%s = OpVariable %_ptr_StorageBuffer_s_block StorageBuffer
%void = OpTypeVoid
%16 = OpTypeFunction %void
%17 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v3int = OpTypePointer StorageBuffer %v3int
%23 = OpConstantNull %v3int
%24 = OpConstantNull %v3int
%uint_1 = OpConstant %uint 1
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
%27 = OpConstantNull %int
%28 = OpConstantNull %int
%uint_2 = OpConstant %uint 2
%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint
%31 = OpConstantNull %v3uint
%32 = OpConstantNull %v3uint
%uint_3 = OpConstant %uint 3
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
%35 = OpConstantNull %uint
%36 = OpConstantNull %uint
%_ptr_StorageBuffer_v3float = OpTypePointer StorageBuffer %v3float
%38 = OpConstantNull %v3float
%39 = OpConstantNull %v3float
%uint_5 = OpConstant %uint 5
%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
%42 = OpConstantNull %float
%43 = OpConstantNull %float
%uint_6 = OpConstant %uint 6
%_ptr_StorageBuffer_mat2v3float = OpTypePointer StorageBuffer %mat2v3float
%46 = OpConstantNull %mat2v3float
%47 = OpConstantNull %mat2v3float
%uint_7 = OpConstant %uint 7
%_ptr_StorageBuffer_mat3v2float = OpTypePointer StorageBuffer %mat3v2float
%50 = OpConstantNull %mat3v2float
%51 = OpConstantNull %mat3v2float
%uint_8 = OpConstant %uint 8
%_ptr_StorageBuffer_Inner = OpTypePointer StorageBuffer %Inner
%54 = OpConstantNull %Inner
%55 = OpConstantNull %Inner
%uint_9 = OpConstant %uint 9
%_ptr_StorageBuffer__arr_Inner_uint_4 = OpTypePointer StorageBuffer %_arr_Inner_uint_4
%58 = OpConstantNull %_arr_Inner_uint_4
%main = OpFunction %void None %16
%19 = OpLabel
%22 = OpAccessChain %_ptr_StorageBuffer_v3int %s %uint_0
OpStore %22 %23
%26 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_1
OpStore %26 %27
%30 = OpAccessChain %_ptr_StorageBuffer_v3uint %s %uint_2
OpStore %30 %31
%34 = OpAccessChain %_ptr_StorageBuffer_uint %s %uint_3
OpStore %34 %35
%37 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_4
OpStore %37 %38
%41 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_5
OpStore %41 %42
%45 = OpAccessChain %_ptr_StorageBuffer_mat2v3float %s %uint_6
OpStore %45 %46
%49 = OpAccessChain %_ptr_StorageBuffer_mat3v2float %s %uint_7
OpStore %49 %50
%53 = OpAccessChain %_ptr_StorageBuffer_Inner %s %uint_8
OpStore %53 %54
%57 = OpAccessChain %_ptr_StorageBuffer__arr_Inner_uint_4 %s %uint_9
OpStore %57 %58
%59 = OpConstantNull %_arr_Inner_uint_4
%main = OpFunction %void None %17
%20 = OpLabel
%23 = OpAccessChain %_ptr_StorageBuffer_v3int %s %uint_0 %uint_0
OpStore %23 %24
%27 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 %uint_1
OpStore %27 %28
%31 = OpAccessChain %_ptr_StorageBuffer_v3uint %s %uint_0 %uint_2
OpStore %31 %32
%35 = OpAccessChain %_ptr_StorageBuffer_uint %s %uint_0 %uint_3
OpStore %35 %36
%38 = OpAccessChain %_ptr_StorageBuffer_v3float %s %uint_0 %uint_4
OpStore %38 %39
%42 = OpAccessChain %_ptr_StorageBuffer_float %s %uint_0 %uint_5
OpStore %42 %43
%46 = OpAccessChain %_ptr_StorageBuffer_mat2v3float %s %uint_0 %uint_6
OpStore %46 %47
%50 = OpAccessChain %_ptr_StorageBuffer_mat3v2float %s %uint_0 %uint_7
OpStore %50 %51
%54 = OpAccessChain %_ptr_StorageBuffer_Inner %s %uint_0 %uint_8
OpStore %54 %55
%58 = OpAccessChain %_ptr_StorageBuffer__arr_Inner_uint_4 %s %uint_0 %uint_9
OpStore %58 %59
OpReturn
OpFunctionEnd