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