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

@@ -23,9 +23,9 @@ void main() {
const float4 v4f32_let = float4(0.0f, 0.0f, 0.0f, 0.0f);
float2x3 m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
const float3x4 m3x4_let = float3x4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
tint_array_wrapper arr_var = {{0.0f, 0.0f, 0.0f, 0.0f}};
const tint_array_wrapper arr_let = {{0.0f, 0.0f, 0.0f, 0.0f}};
S struct_var = {0.0f};
const S struct_let = {0.0f};
tint_array_wrapper arr_var = {(float[4])0};
const tint_array_wrapper arr_let = {(float[4])0};
S struct_var = (S)0;
const S struct_let = (S)0;
return;
}

View File

@@ -15,8 +15,8 @@ struct tint_array_wrapper {
float arr[4];
};
static const tint_array_wrapper arr_let = {{0.0f, 0.0f, 0.0f, 0.0f}};
static const S struct_let = {0.0f};
static const tint_array_wrapper arr_let = {(float[4])0};
static const S struct_let = (S)0;
[numthreads(1, 1, 1)]
void main() {

View File

@@ -15,8 +15,8 @@ struct tint_array_wrapper {
float arr[4];
};
static tint_array_wrapper arr_var = {{0.0f, 0.0f, 0.0f, 0.0f}};
static S struct_var = {0.0f};
static tint_array_wrapper arr_var = (tint_array_wrapper)0;
static S struct_var = (S)0;
[numthreads(1, 1, 1)]
void main() {
@@ -28,9 +28,9 @@ void main() {
v3u32_var = uint3(0u, 0u, 0u);
v4f32_var = float4(0.0f, 0.0f, 0.0f, 0.0f);
m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
const tint_array_wrapper tint_symbol = {{0.0f, 0.0f, 0.0f, 0.0f}};
const tint_array_wrapper tint_symbol = {(float[4])0};
arr_var = tint_symbol;
const S tint_symbol_1 = {0.0f};
const S tint_symbol_1 = (S)0;
struct_var = tint_symbol_1;
return;
}

View File

@@ -15,8 +15,8 @@ struct tint_array_wrapper {
float arr[4];
};
static tint_array_wrapper arr_var = {{0.0f, 0.0f, 0.0f, 0.0f}};
static S struct_var = {0.0f};
static tint_array_wrapper arr_var = {(float[4])0};
static S struct_var = (S)0;
[numthreads(1, 1, 1)]
void main() {
@@ -28,9 +28,9 @@ void main() {
v3u32_var = uint3(0u, 0u, 0u);
v4f32_var = float4(0.0f, 0.0f, 0.0f, 0.0f);
m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
const tint_array_wrapper tint_symbol = {{0.0f, 0.0f, 0.0f, 0.0f}};
const tint_array_wrapper tint_symbol = {(float[4])0};
arr_var = tint_symbol;
const S tint_symbol_1 = {0.0f};
const S tint_symbol_1 = (S)0;
struct_var = tint_symbol_1;
return;
}

View File

@@ -39,12 +39,12 @@ struct tint_array_wrapper {
};
tint_array_wrapper ret_arr() {
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;
}
S ret_struct() {
const S tint_symbol_1 = {0.0f};
const S tint_symbol_1 = (S)0;
return tint_symbol_1;
}

View File

@@ -19,6 +19,6 @@ struct S {
[numthreads(1, 1, 1)]
void main() {
const S s = {false, 0, 0u, 0.0f, int2(0, 0), uint3(0u, 0u, 0u), float4(0.0f, 0.0f, 0.0f, 0.0f), float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), {{0.0f, 0.0f, 0.0f, 0.0f}}, {0.0f}};
const S s = (S)0;
return;
}