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

@@ -34,27 +34,35 @@ struct Inner_std140 {
ivec4 k[4];
};
layout(binding = 0, std140) uniform S_std140_ubo {
struct S {
Inner arr[8];
};
struct S_std140 {
Inner_std140 arr[8];
};
layout(binding = 0, std140) uniform s_block_std140_ubo {
S_std140 inner;
} s;
mat3x2 load_s_arr_p0_j(uint p0) {
mat3x2 load_s_inner_arr_p0_j(uint p0) {
uint s_save = p0;
return mat3x2(s.arr[s_save].j_0, s.arr[s_save].j_1, s.arr[s_save].j_2);
return mat3x2(s.inner.arr[s_save].j_0, s.inner.arr[s_save].j_1, s.inner.arr[s_save].j_2);
}
void tint_symbol(uint idx) {
ivec3 a = s.arr[idx].a;
int b = s.arr[idx].b;
uvec3 c = s.arr[idx].c;
uint d = s.arr[idx].d;
vec3 e = s.arr[idx].e;
float f = s.arr[idx].f;
ivec2 g = s.arr[idx].g;
ivec2 h = s.arr[idx].h;
mat2x3 i = s.arr[idx].i;
mat3x2 j = load_s_arr_p0_j(uint(idx));
ivec4 k[4] = s.arr[idx].k;
ivec3 a = s.inner.arr[idx].a;
int b = s.inner.arr[idx].b;
uvec3 c = s.inner.arr[idx].c;
uint d = s.inner.arr[idx].d;
vec3 e = s.inner.arr[idx].e;
float f = s.inner.arr[idx].f;
ivec2 g = s.inner.arr[idx].g;
ivec2 h = s.inner.arr[idx].h;
mat2x3 i = s.inner.arr[idx].i;
mat3x2 j = load_s_inner_arr_p0_j(uint(idx));
ivec4 k[4] = s.inner.arr[idx].k;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@@ -1,13 +1,15 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 92
; Bound: 93
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %idx_1
OpExecutionMode %main LocalSize 1 1 1
OpName %idx_1 "idx_1"
OpName %s_block_std140 "s_block_std140"
OpMemberName %s_block_std140 0 "inner"
OpName %S_std140 "S_std140"
OpMemberName %S_std140 0 "arr"
OpName %Inner_std140 "Inner_std140"
@@ -25,13 +27,14 @@
OpMemberName %Inner_std140 11 "j_2"
OpMemberName %Inner_std140 12 "k"
OpName %s "s"
OpName %load_s_arr_p0_j "load_s_arr_p0_j"
OpName %load_s_inner_arr_p0_j "load_s_inner_arr_p0_j"
OpName %p0 "p0"
OpName %main_inner "main_inner"
OpName %idx "idx"
OpName %main "main"
OpDecorate %idx_1 BuiltIn LocalInvocationIndex
OpDecorate %S_std140 Block
OpDecorate %s_block_std140 Block
OpMemberDecorate %s_block_std140 0 Offset 0
OpMemberDecorate %S_std140 0 Offset 0
OpMemberDecorate %Inner_std140 0 Offset 0
OpMemberDecorate %Inner_std140 1 Offset 12
@@ -71,10 +74,11 @@
%uint_8 = OpConstant %uint 8
%_arr_Inner_std140_uint_8 = OpTypeArray %Inner_std140 %uint_8
%S_std140 = OpTypeStruct %_arr_Inner_std140_uint_8
%_ptr_Uniform_S_std140 = OpTypePointer Uniform %S_std140
%s = OpVariable %_ptr_Uniform_S_std140 Uniform
%s_block_std140 = OpTypeStruct %S_std140
%_ptr_Uniform_s_block_std140 = OpTypePointer Uniform %s_block_std140
%s = OpVariable %_ptr_Uniform_s_block_std140 Uniform
%mat3v2float = OpTypeMatrix %v2float 3
%21 = OpTypeFunction %mat3v2float %uint
%22 = OpTypeFunction %mat3v2float %uint
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_Inner_std140 = OpTypePointer Uniform %Inner_std140
%uint_9 = OpConstant %uint 9
@@ -82,7 +86,7 @@
%uint_10 = OpConstant %uint 10
%uint_11 = OpConstant %uint 11
%void = OpTypeVoid
%44 = OpTypeFunction %void %uint
%45 = OpTypeFunction %void %uint
%_ptr_Uniform_v3int = OpTypePointer Uniform %v3int
%uint_1 = OpConstant %uint 1
%_ptr_Uniform_int = OpTypePointer Uniform %int
@@ -99,49 +103,49 @@
%_ptr_Uniform_mat2v3float = OpTypePointer Uniform %mat2v3float
%uint_12 = OpConstant %uint 12
%_ptr_Uniform__arr_v4int_uint_4 = OpTypePointer Uniform %_arr_v4int_uint_4
%87 = OpTypeFunction %void
%load_s_arr_p0_j = OpFunction %mat3v2float None %21
%88 = OpTypeFunction %void
%load_s_inner_arr_p0_j = OpFunction %mat3v2float None %22
%p0 = OpFunctionParameter %uint
%25 = OpLabel
%29 = OpAccessChain %_ptr_Uniform_Inner_std140 %s %uint_0 %p0
%33 = OpAccessChain %_ptr_Uniform_v2float %29 %uint_9
%34 = OpLoad %v2float %33
%37 = OpAccessChain %_ptr_Uniform_v2float %29 %uint_10
%38 = OpLoad %v2float %37
%41 = OpAccessChain %_ptr_Uniform_v2float %29 %uint_11
%42 = OpLoad %v2float %41
%43 = OpCompositeConstruct %mat3v2float %34 %38 %42
OpReturnValue %43
%26 = OpLabel
%30 = OpAccessChain %_ptr_Uniform_Inner_std140 %s %uint_0 %uint_0 %p0
%34 = OpAccessChain %_ptr_Uniform_v2float %30 %uint_9
%35 = OpLoad %v2float %34
%38 = OpAccessChain %_ptr_Uniform_v2float %30 %uint_10
%39 = OpLoad %v2float %38
%42 = OpAccessChain %_ptr_Uniform_v2float %30 %uint_11
%43 = OpLoad %v2float %42
%44 = OpCompositeConstruct %mat3v2float %35 %39 %43
OpReturnValue %44
OpFunctionEnd
%main_inner = OpFunction %void None %44
%main_inner = OpFunction %void None %45
%idx = OpFunctionParameter %uint
%48 = OpLabel
%50 = OpAccessChain %_ptr_Uniform_v3int %s %uint_0 %idx %uint_0
%51 = OpLoad %v3int %50
%54 = OpAccessChain %_ptr_Uniform_int %s %uint_0 %idx %uint_1
%55 = OpLoad %int %54
%58 = OpAccessChain %_ptr_Uniform_v3uint %s %uint_0 %idx %uint_2
%59 = OpLoad %v3uint %58
%62 = OpAccessChain %_ptr_Uniform_uint %s %uint_0 %idx %uint_3
%63 = OpLoad %uint %62
%65 = OpAccessChain %_ptr_Uniform_v3float %s %uint_0 %idx %uint_4
%66 = OpLoad %v3float %65
%69 = OpAccessChain %_ptr_Uniform_float %s %uint_0 %idx %uint_5
%70 = OpLoad %float %69
%73 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %idx %uint_6
%74 = OpLoad %v2int %73
%76 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %idx %uint_7
%77 = OpLoad %v2int %76
%79 = OpAccessChain %_ptr_Uniform_mat2v3float %s %uint_0 %idx %uint_8
%80 = OpLoad %mat2v3float %79
%81 = OpFunctionCall %mat3v2float %load_s_arr_p0_j %idx
%85 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %s %uint_0 %idx %uint_12
%86 = OpLoad %_arr_v4int_uint_4 %85
%49 = OpLabel
%51 = OpAccessChain %_ptr_Uniform_v3int %s %uint_0 %uint_0 %idx %uint_0
%52 = OpLoad %v3int %51
%55 = OpAccessChain %_ptr_Uniform_int %s %uint_0 %uint_0 %idx %uint_1
%56 = OpLoad %int %55
%59 = OpAccessChain %_ptr_Uniform_v3uint %s %uint_0 %uint_0 %idx %uint_2
%60 = OpLoad %v3uint %59
%63 = OpAccessChain %_ptr_Uniform_uint %s %uint_0 %uint_0 %idx %uint_3
%64 = OpLoad %uint %63
%66 = OpAccessChain %_ptr_Uniform_v3float %s %uint_0 %uint_0 %idx %uint_4
%67 = OpLoad %v3float %66
%70 = OpAccessChain %_ptr_Uniform_float %s %uint_0 %uint_0 %idx %uint_5
%71 = OpLoad %float %70
%74 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %uint_0 %idx %uint_6
%75 = OpLoad %v2int %74
%77 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %uint_0 %idx %uint_7
%78 = OpLoad %v2int %77
%80 = OpAccessChain %_ptr_Uniform_mat2v3float %s %uint_0 %uint_0 %idx %uint_8
%81 = OpLoad %mat2v3float %80
%82 = OpFunctionCall %mat3v2float %load_s_inner_arr_p0_j %idx
%86 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %s %uint_0 %uint_0 %idx %uint_12
%87 = OpLoad %_arr_v4int_uint_4 %86
OpReturn
OpFunctionEnd
%main = OpFunction %void None %87
%89 = OpLabel
%91 = OpLoad %uint %idx_1
%90 = OpFunctionCall %void %main_inner %91
%main = OpFunction %void None %88
%90 = OpLabel
%92 = OpLoad %uint %idx_1
%91 = OpFunctionCall %void %main_inner %92
OpReturn
OpFunctionEnd

View File

@@ -7,7 +7,24 @@ struct Inner {
uint pad_2;
};
layout(binding = 0, std140) uniform S_std140_ubo {
struct S {
ivec3 a;
int b;
uvec3 c;
uint d;
vec3 e;
float f;
ivec2 g;
ivec2 h;
mat2x3 i;
mat3x2 j;
uint pad_3;
uint pad_4;
Inner k;
Inner l[4];
};
struct S_std140 {
ivec3 a;
int b;
uvec3 c;
@@ -24,25 +41,29 @@ layout(binding = 0, std140) uniform S_std140_ubo {
uint pad_4;
Inner k;
Inner l[4];
};
layout(binding = 0, std140) uniform s_block_std140_ubo {
S_std140 inner;
} s;
mat3x2 load_s_j() {
return mat3x2(s.j_0, s.j_1, s.j_2);
mat3x2 load_s_inner_j() {
return mat3x2(s.inner.j_0, s.inner.j_1, s.inner.j_2);
}
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;
ivec2 g = s.g;
ivec2 h = s.h;
mat2x3 i = s.i;
mat3x2 j = load_s_j();
Inner k = s.k;
Inner l[4] = s.l;
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;
ivec2 g = s.inner.g;
ivec2 h = s.inner.h;
mat2x3 i = s.inner.i;
mat3x2 j = load_s_inner_j();
Inner k = s.inner.k;
Inner l[4] = s.inner.l;
}
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: 82
; Bound: 85
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %s_block_std140 "s_block_std140"
OpMemberName %s_block_std140 0 "inner"
OpName %S_std140 "S_std140"
OpMemberName %S_std140 0 "a"
OpMemberName %S_std140 1 "b"
@@ -25,9 +27,10 @@
OpMemberName %Inner 0 "x"
OpMemberName %S_std140 13 "l"
OpName %s "s"
OpName %load_s_j "load_s_j"
OpName %load_s_inner_j "load_s_inner_j"
OpName %main "main"
OpDecorate %S_std140 Block
OpDecorate %s_block_std140 Block
OpMemberDecorate %s_block_std140 0 Offset 0
OpMemberDecorate %S_std140 0 Offset 0
OpMemberDecorate %S_std140 1 Offset 12
OpMemberDecorate %S_std140 2 Offset 16
@@ -62,17 +65,19 @@
%uint_4 = OpConstant %uint 4
%_arr_Inner_uint_4 = OpTypeArray %Inner %uint_4
%S_std140 = OpTypeStruct %v3int %int %v3uint %uint %v3float %float %v2int %v2int %mat2v3float %v2float %v2float %v2float %Inner %_arr_Inner_uint_4
%_ptr_Uniform_S_std140 = OpTypePointer Uniform %S_std140
%s = OpVariable %_ptr_Uniform_S_std140 Uniform
%s_block_std140 = OpTypeStruct %S_std140
%_ptr_Uniform_s_block_std140 = OpTypePointer Uniform %s_block_std140
%s = OpVariable %_ptr_Uniform_s_block_std140 Uniform
%mat3v2float = OpTypeMatrix %v2float 3
%16 = OpTypeFunction %mat3v2float
%17 = OpTypeFunction %mat3v2float
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_S_std140 = OpTypePointer Uniform %S_std140
%uint_9 = OpConstant %uint 9
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%uint_10 = OpConstant %uint 10
%uint_11 = OpConstant %uint 11
%void = OpTypeVoid
%35 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%39 = OpTypeFunction %void
%_ptr_Uniform_v3int = OpTypePointer Uniform %v3int
%uint_1 = OpConstant %uint 1
%_ptr_Uniform_int = OpTypePointer Uniform %int
@@ -92,41 +97,42 @@
%_ptr_Uniform_Inner = OpTypePointer Uniform %Inner
%uint_13 = OpConstant %uint 13
%_ptr_Uniform__arr_Inner_uint_4 = OpTypePointer Uniform %_arr_Inner_uint_4
%load_s_j = OpFunction %mat3v2float None %16
%19 = OpLabel
%24 = OpAccessChain %_ptr_Uniform_v2float %s %uint_9
%25 = OpLoad %v2float %24
%28 = OpAccessChain %_ptr_Uniform_v2float %s %uint_10
%load_s_inner_j = OpFunction %mat3v2float None %17
%20 = OpLabel
%24 = OpAccessChain %_ptr_Uniform_S_std140 %s %uint_0
%28 = OpAccessChain %_ptr_Uniform_v2float %24 %uint_9
%29 = OpLoad %v2float %28
%32 = OpAccessChain %_ptr_Uniform_v2float %s %uint_11
%32 = OpAccessChain %_ptr_Uniform_v2float %24 %uint_10
%33 = OpLoad %v2float %32
%34 = OpCompositeConstruct %mat3v2float %25 %29 %33
OpReturnValue %34
%36 = OpAccessChain %_ptr_Uniform_v2float %24 %uint_11
%37 = OpLoad %v2float %36
%38 = OpCompositeConstruct %mat3v2float %29 %33 %37
OpReturnValue %38
OpFunctionEnd
%main = OpFunction %void None %35
%38 = OpLabel
%41 = OpAccessChain %_ptr_Uniform_v3int %s %uint_0
%42 = OpLoad %v3int %41
%45 = OpAccessChain %_ptr_Uniform_int %s %uint_1
%46 = OpLoad %int %45
%49 = OpAccessChain %_ptr_Uniform_v3uint %s %uint_2
%50 = OpLoad %v3uint %49
%53 = OpAccessChain %_ptr_Uniform_uint %s %uint_3
%54 = OpLoad %uint %53
%56 = OpAccessChain %_ptr_Uniform_v3float %s %uint_4
%57 = OpLoad %v3float %56
%60 = OpAccessChain %_ptr_Uniform_float %s %uint_5
%61 = OpLoad %float %60
%64 = OpAccessChain %_ptr_Uniform_v2int %s %uint_6
%65 = OpLoad %v2int %64
%67 = OpAccessChain %_ptr_Uniform_v2int %s %uint_7
%main = OpFunction %void None %39
%42 = OpLabel
%44 = OpAccessChain %_ptr_Uniform_v3int %s %uint_0 %uint_0
%45 = OpLoad %v3int %44
%48 = OpAccessChain %_ptr_Uniform_int %s %uint_0 %uint_1
%49 = OpLoad %int %48
%52 = OpAccessChain %_ptr_Uniform_v3uint %s %uint_0 %uint_2
%53 = OpLoad %v3uint %52
%56 = OpAccessChain %_ptr_Uniform_uint %s %uint_0 %uint_3
%57 = OpLoad %uint %56
%59 = OpAccessChain %_ptr_Uniform_v3float %s %uint_0 %uint_4
%60 = OpLoad %v3float %59
%63 = OpAccessChain %_ptr_Uniform_float %s %uint_0 %uint_5
%64 = OpLoad %float %63
%67 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %uint_6
%68 = OpLoad %v2int %67
%71 = OpAccessChain %_ptr_Uniform_mat2v3float %s %uint_8
%72 = OpLoad %mat2v3float %71
%73 = OpFunctionCall %mat3v2float %load_s_j
%76 = OpAccessChain %_ptr_Uniform_Inner %s %uint_12
%77 = OpLoad %Inner %76
%80 = OpAccessChain %_ptr_Uniform__arr_Inner_uint_4 %s %uint_13
%81 = OpLoad %_arr_Inner_uint_4 %80
%70 = OpAccessChain %_ptr_Uniform_v2int %s %uint_0 %uint_7
%71 = OpLoad %v2int %70
%74 = OpAccessChain %_ptr_Uniform_mat2v3float %s %uint_0 %uint_8
%75 = OpLoad %mat2v3float %74
%76 = OpFunctionCall %mat3v2float %load_s_inner_j
%79 = OpAccessChain %_ptr_Uniform_Inner %s %uint_0 %uint_12
%80 = OpLoad %Inner %79
%83 = OpAccessChain %_ptr_Uniform__arr_Inner_uint_4 %s %uint_0 %uint_13
%84 = OpLoad %_arr_Inner_uint_4 %83
OpReturn
OpFunctionEnd