writer/hlsl: Zero initialize with (T) 0

For structures and arrays.
This behaves identically to the per-element zero-initialization, but can be significantly less verbose.

Change-Id: I380ef86f16c2b3f37a9de2820e707f368955b761
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56764
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2021-07-02 19:27:42 +00:00
parent efc46c1873
commit 2bb45389b7
54 changed files with 132 additions and 158 deletions

View File

@@ -27,7 +27,7 @@ tint_array_wrapper tint_symbol_4(RWByteAddressBuffer buffer, uint offset) {
return tint_symbol_6;
}
static tint_array_wrapper src_private = {{{0}, {0}, {0}, {0}}};
static tint_array_wrapper src_private = (tint_array_wrapper)0;
groupshared tint_array_wrapper src_workgroup;
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
@@ -35,12 +35,12 @@ cbuffer cbuffer_src_uniform : register(b0, space0) {
RWByteAddressBuffer src_storage : register(u1, space0);
tint_array_wrapper ret_arr() {
const tint_array_wrapper tint_symbol_7 = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper tint_symbol_7 = {(tint_padded_array_element[4])0};
return tint_symbol_7;
}
S ret_struct_arr() {
const S tint_symbol_8 = {{{{0}, {0}, {0}, {0}}}};
const S tint_symbol_8 = (S)0;
return tint_symbol_8;
}
@@ -55,13 +55,13 @@ struct tint_array_wrapper_1 {
};
void foo(tint_array_wrapper src_param) {
tint_array_wrapper src_function = {{{0}, {0}, {0}, {0}}};
tint_array_wrapper tint_symbol = {{{0}, {0}, {0}, {0}}};
tint_array_wrapper src_function = (tint_array_wrapper)0;
tint_array_wrapper tint_symbol = (tint_array_wrapper)0;
const tint_array_wrapper tint_symbol_9 = {{{1}, {2}, {3}, {3}}};
tint_symbol = tint_symbol_9;
tint_symbol = src_param;
tint_symbol = ret_arr();
const tint_array_wrapper src_let = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper src_let = {(tint_padded_array_element[4])0};
tint_symbol = src_let;
tint_symbol = src_function;
tint_symbol = src_private;
@@ -69,7 +69,7 @@ void foo(tint_array_wrapper src_param) {
tint_symbol = ret_struct_arr().arr;
tint_symbol = tint_symbol_2(src_uniform, 0u);
tint_symbol = tint_symbol_4(src_storage, 0u);
tint_array_wrapper_1 dst_nested = {{{{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}}};
tint_array_wrapper_1 src_nested = {{{{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}}};
tint_array_wrapper_1 dst_nested = (tint_array_wrapper_1)0;
tint_array_wrapper_1 src_nested = (tint_array_wrapper_1)0;
dst_nested = src_nested;
}

View File

@@ -27,13 +27,13 @@ tint_array_wrapper tint_symbol_4(RWByteAddressBuffer buffer, uint offset) {
return tint_symbol_6;
}
static tint_array_wrapper src_private = {{{0}, {0}, {0}, {0}}};
static tint_array_wrapper src_private = (tint_array_wrapper)0;
groupshared tint_array_wrapper src_workgroup;
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
};
RWByteAddressBuffer src_storage : register(u1, space0);
static tint_array_wrapper tint_symbol = {{{0}, {0}, {0}, {0}}};
static tint_array_wrapper tint_symbol = (tint_array_wrapper)0;
struct tint_array_wrapper_3 {
int arr[2];
@@ -45,25 +45,25 @@ struct tint_array_wrapper_1 {
tint_array_wrapper_2 arr[4];
};
static tint_array_wrapper_1 dst_nested = {{{{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}}};
static tint_array_wrapper_1 dst_nested = (tint_array_wrapper_1)0;
tint_array_wrapper ret_arr() {
const tint_array_wrapper tint_symbol_7 = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper tint_symbol_7 = {(tint_padded_array_element[4])0};
return tint_symbol_7;
}
S ret_struct_arr() {
const S tint_symbol_8 = {{{{0}, {0}, {0}, {0}}}};
const S tint_symbol_8 = (S)0;
return tint_symbol_8;
}
void foo(tint_array_wrapper src_param) {
tint_array_wrapper src_function = {{{0}, {0}, {0}, {0}}};
tint_array_wrapper src_function = (tint_array_wrapper)0;
const tint_array_wrapper tint_symbol_9 = {{{1}, {2}, {3}, {3}}};
tint_symbol = tint_symbol_9;
tint_symbol = src_param;
tint_symbol = ret_arr();
const tint_array_wrapper src_let = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper src_let = {(tint_padded_array_element[4])0};
tint_symbol = src_let;
tint_symbol = src_function;
tint_symbol = src_private;
@@ -71,6 +71,6 @@ void foo(tint_array_wrapper src_param) {
tint_symbol = ret_struct_arr().arr;
tint_symbol = tint_symbol_2(src_uniform, 0u);
tint_symbol = tint_symbol_4(src_storage, 0u);
tint_array_wrapper_1 src_nested = {{{{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}}};
tint_array_wrapper_1 src_nested = (tint_array_wrapper_1)0;
dst_nested = src_nested;
}

View File

@@ -62,7 +62,7 @@ void tint_symbol_10(RWByteAddressBuffer buffer, uint offset, tint_array_wrapper_
tint_symbol_9(buffer, (offset + 72u), value.arr[3u]);
}
static tint_array_wrapper src_private = {{{0}, {0}, {0}, {0}}};
static tint_array_wrapper src_private = (tint_array_wrapper)0;
groupshared tint_array_wrapper src_workgroup;
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
@@ -72,22 +72,22 @@ RWByteAddressBuffer tint_symbol : register(u2, space0);
RWByteAddressBuffer dst_nested : register(u3, space0);
tint_array_wrapper ret_arr() {
const tint_array_wrapper tint_symbol_13 = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper tint_symbol_13 = {(tint_padded_array_element[4])0};
return tint_symbol_13;
}
S ret_struct_arr() {
const S tint_symbol_14 = {{{{0}, {0}, {0}, {0}}}};
const S tint_symbol_14 = (S)0;
return tint_symbol_14;
}
void foo(tint_array_wrapper src_param) {
tint_array_wrapper src_function = {{{0}, {0}, {0}, {0}}};
tint_array_wrapper src_function = (tint_array_wrapper)0;
const tint_array_wrapper tint_symbol_15 = {{{1}, {2}, {3}, {3}}};
tint_symbol_6(tint_symbol, 0u, tint_symbol_15);
tint_symbol_6(tint_symbol, 0u, src_param);
tint_symbol_6(tint_symbol, 0u, ret_arr());
const tint_array_wrapper src_let = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper src_let = {(tint_padded_array_element[4])0};
tint_symbol_6(tint_symbol, 0u, src_let);
tint_symbol_6(tint_symbol, 0u, src_function);
tint_symbol_6(tint_symbol, 0u, src_private);
@@ -95,6 +95,6 @@ void foo(tint_array_wrapper src_param) {
tint_symbol_6(tint_symbol, 0u, ret_struct_arr().arr);
tint_symbol_6(tint_symbol, 0u, tint_symbol_2(src_uniform, 0u));
tint_symbol_6(tint_symbol, 0u, tint_symbol_4(src_storage, 0u));
tint_array_wrapper_1 src_nested = {{{{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}}};
tint_array_wrapper_1 src_nested = (tint_array_wrapper_1)0;
tint_symbol_10(dst_nested, 0u, src_nested);
}

View File

@@ -14,10 +14,10 @@ struct tint_array_wrapper_1 {
};
void foo() {
const tint_array_wrapper src = {{0, 0, 0, 0}};
tint_array_wrapper tint_symbol = {{0, 0, 0, 0}};
S dst_struct = {{{0, 0, 0, 0}}};
tint_array_wrapper_1 dst_array = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
const tint_array_wrapper src = {(int[4])0};
tint_array_wrapper tint_symbol = (tint_array_wrapper)0;
S dst_struct = (S)0;
tint_array_wrapper_1 dst_array = (tint_array_wrapper_1)0;
dst_struct.arr = src;
dst_array.arr[1] = src;
tint_symbol = src;

View File

@@ -27,7 +27,7 @@ tint_array_wrapper tint_symbol_4(RWByteAddressBuffer buffer, uint offset) {
return tint_symbol_6;
}
static tint_array_wrapper src_private = {{{0}, {0}, {0}, {0}}};
static tint_array_wrapper src_private = (tint_array_wrapper)0;
groupshared tint_array_wrapper src_workgroup;
cbuffer cbuffer_src_uniform : register(b0, space0) {
uint4 src_uniform[4];
@@ -48,22 +48,22 @@ struct tint_array_wrapper_1 {
groupshared tint_array_wrapper_1 dst_nested;
tint_array_wrapper ret_arr() {
const tint_array_wrapper tint_symbol_7 = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper tint_symbol_7 = {(tint_padded_array_element[4])0};
return tint_symbol_7;
}
S ret_struct_arr() {
const S tint_symbol_8 = {{{{0}, {0}, {0}, {0}}}};
const S tint_symbol_8 = (S)0;
return tint_symbol_8;
}
void foo(tint_array_wrapper src_param) {
tint_array_wrapper src_function = {{{0}, {0}, {0}, {0}}};
tint_array_wrapper src_function = (tint_array_wrapper)0;
const tint_array_wrapper tint_symbol_9 = {{{1}, {2}, {3}, {3}}};
tint_symbol = tint_symbol_9;
tint_symbol = src_param;
tint_symbol = ret_arr();
const tint_array_wrapper src_let = {{{0}, {0}, {0}, {0}}};
const tint_array_wrapper src_let = {(tint_padded_array_element[4])0};
tint_symbol = src_let;
tint_symbol = src_function;
tint_symbol = src_private;
@@ -71,6 +71,6 @@ void foo(tint_array_wrapper src_param) {
tint_symbol = ret_struct_arr().arr;
tint_symbol = tint_symbol_2(src_uniform, 0u);
tint_symbol = tint_symbol_4(src_storage, 0u);
tint_array_wrapper_1 src_nested = {{{{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}, {{{{0, 0}}, {{0, 0}}, {{0, 0}}}}}};
tint_array_wrapper_1 src_nested = (tint_array_wrapper_1)0;
dst_nested = src_nested;
}

View File

@@ -24,9 +24,9 @@ float f3(tint_array_wrapper_2 a) {
[numthreads(1, 1, 1)]
void main() {
const tint_array_wrapper a1 = {{0.0f, 0.0f, 0.0f, 0.0f}};
const tint_array_wrapper_1 a2 = {{{{0.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}}};
const tint_array_wrapper_2 a3 = {{{{{{0.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}}}, {{{{0.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}}}}};
const tint_array_wrapper a1 = {(float[4])0};
const tint_array_wrapper_1 a2 = {(tint_array_wrapper[3])0};
const tint_array_wrapper_2 a3 = {(tint_array_wrapper_1[2])0};
const float v1 = f1(a1);
const float v2 = f2(a2);
const float v3 = f3(a3);

View File

@@ -3,7 +3,7 @@ struct tint_array_wrapper {
};
tint_array_wrapper f1() {
const tint_array_wrapper tint_symbol = {{0.0f, 0.0f, 0.0f, 0.0f}};
const tint_array_wrapper tint_symbol = {(float[4])0};
return tint_symbol;
}

View File

@@ -14,10 +14,10 @@ struct tint_array_wrapper_3 {
[numthreads(1, 1, 1)]
void main() {
const int x = 42;
const tint_array_wrapper empty = {{0, 0, 0, 0}};
const tint_array_wrapper empty = {(int[4])0};
const tint_array_wrapper nonempty = {{1, 2, 3, 4}};
const tint_array_wrapper nonempty_with_expr = {{1, x, (x + 1), nonempty.arr[3]}};
const tint_array_wrapper_1 nested_empty = {{{{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}, {{0, 0, 0, 0}}}}, {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}, {{0, 0, 0, 0}}}}}};
const tint_array_wrapper_1 nested_empty = {(tint_array_wrapper_2[2])0};
const tint_array_wrapper tint_symbol = {{1, 2, 3, 4}};
const tint_array_wrapper tint_symbol_1 = {{5, 6, 7, 8}};
const tint_array_wrapper tint_symbol_2 = {{9, 10, 11, 12}};
@@ -31,13 +31,13 @@ void main() {
const tint_array_wrapper tint_symbol_9 = {{5, 6, nonempty.arr[2], (nonempty.arr[3] + 1)}};
const tint_array_wrapper_2 tint_symbol_10 = {{tint_symbol_8, tint_symbol_9, nonempty}};
const tint_array_wrapper_1 nested_nonempty_with_expr = {{tint_symbol_10, nested_nonempty.arr[1]}};
const tint_array_wrapper tint_symbol_11 = {{0, 0, 0, 0}};
const tint_array_wrapper tint_symbol_11 = {(int[4])0};
const int subexpr_empty = tint_symbol_11.arr[1];
const tint_array_wrapper tint_symbol_12 = {{1, 2, 3, 4}};
const int subexpr_nonempty = tint_symbol_12.arr[2];
const tint_array_wrapper tint_symbol_13 = {{1, x, (x + 1), nonempty.arr[3]}};
const int subexpr_nonempty_with_expr = tint_symbol_13.arr[2];
const tint_array_wrapper_3 tint_symbol_14 = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
const tint_array_wrapper_3 tint_symbol_14 = {(tint_array_wrapper[2])0};
const tint_array_wrapper subexpr_nested_empty = tint_symbol_14.arr[1];
const tint_array_wrapper tint_symbol_15 = {{1, 2, 3, 4}};
const tint_array_wrapper tint_symbol_16 = {{5, 6, 7, 8}};