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

@@ -26,10 +26,10 @@ struct tint_array_wrapper_1 {
[numthreads(1, 1, 1)]
void main() {
const int x = 42;
const S1 empty = {0, 0, 0, 0};
const S1 empty = (S1)0;
const S1 nonempty = {1, 2, 3, 4};
const S1 nonempty_with_expr = {1, x, (x + 1), nonempty.d};
const S3 nested_empty = {0, {0, 0, 0, 0}, {0, {0, 0, 0, 0}}};
const S3 nested_empty = (S3)0;
const S1 tint_symbol = {2, 3, 4, 5};
const S1 tint_symbol_1 = {7, 8, 9, 10};
const S2 tint_symbol_2 = {6, tint_symbol_1};
@@ -37,13 +37,13 @@ void main() {
const S1 tint_symbol_3 = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_4 = {6, nonempty};
const S3 nested_nonempty_with_expr = {1, tint_symbol_3, tint_symbol_4};
const S1 tint_symbol_5 = {0, 0, 0, 0};
const S1 tint_symbol_5 = (S1)0;
const int subexpr_empty = tint_symbol_5.a;
const S1 tint_symbol_6 = {1, 2, 3, 4};
const int subexpr_nonempty = tint_symbol_6.b;
const S1 tint_symbol_7 = {1, x, (x + 1), nonempty.d};
const int subexpr_nonempty_with_expr = tint_symbol_7.c;
const S2 tint_symbol_8 = {0, {0, 0, 0, 0}};
const S2 tint_symbol_8 = (S2)0;
const S1 subexpr_nested_empty = tint_symbol_8.f;
const S1 tint_symbol_9 = {2, 3, 4, 5};
const S2 tint_symbol_10 = {1, tint_symbol_9};
@@ -51,7 +51,7 @@ void main() {
const S1 tint_symbol_11 = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_12 = {1, tint_symbol_11};
const S1 subexpr_nested_nonempty_with_expr = tint_symbol_12.f;
const tint_array_wrapper_1 aosoa_empty = {{{{{0, 0}}}, {{{0, 0}}}}};
const tint_array_wrapper_1 aosoa_empty = {(T[2])0};
const tint_array_wrapper tint_symbol_13 = {{1, 2}};
const T tint_symbol_14 = {tint_symbol_13};
const tint_array_wrapper tint_symbol_15 = {{3, 4}};