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

@@ -20,7 +20,7 @@ struct tint_array_wrapper {
tint_symbol_2 vs_main(tint_symbol_1 tint_symbol) {
const uint VertexIndex = tint_symbol.VertexIndex;
tint_array_wrapper texcoord = {{float2(-0.5f, 0.0f), float2(1.5f, 0.0f), float2(0.5f, 2.0f)}};
VertexOutputs output = {float2(0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
VertexOutputs output = (VertexOutputs)0;
output.position = float4(((texcoord.arr[VertexIndex] * 2.0f) - float2(1.0f, 1.0f)), 0.0f, 1.0f);
const int scalar_offset = (4u) / 4;
bool flipY = (asfloat(uniforms[scalar_offset / 4][scalar_offset % 4]) < 0.0f);

View File

@@ -33,7 +33,7 @@ struct tint_array_wrapper {
tint_symbol_2 main(tint_symbol_1 tint_symbol) {
const uint gl_VertexIndex = tint_symbol.gl_VertexIndex;
tint_array_wrapper indexable = {{float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f)}};
tint_array_wrapper indexable = (tint_array_wrapper)0;
const float2x2 x_23 = tint_symbol_4(x_20, 0u);
const float2x2 x_28 = tint_symbol_6(x_26, 0u);
const uint x_46 = gl_VertexIndex;

View File

@@ -5,7 +5,7 @@ struct QuicksortObject {
tint_array_wrapper numbers;
};
static QuicksortObject obj = {{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}};
static QuicksortObject obj = (QuicksortObject)0;
static float4 gl_FragCoord = float4(0.0f, 0.0f, 0.0f, 0.0f);
cbuffer cbuffer_x_188 : register(b0, space0) {
uint4 x_188[1];
@@ -363,7 +363,7 @@ void quicksort_() {
int p = 0;
int l_1 = 0;
int top = 0;
tint_array_wrapper stack = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
tint_array_wrapper stack = (tint_array_wrapper)0;
int param_5 = 0;
l_1 = 0;
const int x_1007 = param_5;

View File

@@ -8,7 +8,7 @@ struct tint_array_wrapper {
};
void foo() {
tint_array_wrapper tint_symbol = {{0, 0}};
tint_array_wrapper implict = {{0, 0}};
tint_array_wrapper tint_symbol = (tint_array_wrapper)0;
tint_array_wrapper implict = (tint_array_wrapper)0;
implict = tint_symbol;
}

View File

@@ -22,7 +22,7 @@ tint_symbol_2 main(tint_symbol_1 tint_symbol) {
const uint InstanceIndex = tint_symbol.InstanceIndex;
tint_array_wrapper zv = {{float2(0.200000003f, 0.200000003f), float2(0.300000012f, 0.300000012f), float2(-0.100000001f, -0.100000001f), float2(1.100000024f, 1.100000024f)}};
const float z = zv.arr[InstanceIndex].x;
Output output = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Output output = (Output)0;
output.Position = float4(0.5f, 0.5f, z, 1.0f);
tint_array_wrapper_1 colors = {{float4(1.0f, 0.0f, 0.0f, 1.0f), float4(0.0f, 1.0f, 0.0f, 1.0f), float4(0.0f, 0.0f, 1.0f, 1.0f), float4(1.0f, 1.0f, 1.0f, 1.0f)}};
output.color = colors.arr[InstanceIndex];

View File

@@ -10,7 +10,7 @@ tint_array_wrapper tint_symbol_1(ByteAddressBuffer buffer, uint offset) {
ByteAddressBuffer sspp962805860buildInformation : register(t2, space0);
void main_1() {
tint_array_wrapper orientation = {{0, 0, 0, 0, 0, 0}};
tint_array_wrapper orientation = (tint_array_wrapper)0;
const tint_array_wrapper x_23 = tint_symbol_1(sspp962805860buildInformation, 36u);
orientation.arr[0] = x_23.arr[0u];
orientation.arr[1] = x_23.arr[1u];

File diff suppressed because one or more lines are too long

View File

@@ -63,7 +63,7 @@ static float2 v_TexCoord = float2(0.0f, 0.0f);
static float4 gl_Position = float4(0.0f, 0.0f, 0.0f, 0.0f);
float3 Mat4x3GetCol0_(Mat4x3_ m) {
Mat4x3_ m1 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ m1 = (Mat4x3_)0;
m1 = m;
const Mat4x3_ _e2 = m1;
const Mat4x3_ _e5 = m1;
@@ -72,7 +72,7 @@ float3 Mat4x3GetCol0_(Mat4x3_ m) {
}
float3 Mat4x3GetCol1_(Mat4x3_ m2) {
Mat4x3_ m3 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ m3 = (Mat4x3_)0;
m3 = m2;
const Mat4x3_ _e2 = m3;
const Mat4x3_ _e5 = m3;
@@ -81,7 +81,7 @@ float3 Mat4x3GetCol1_(Mat4x3_ m2) {
}
float3 Mat4x3GetCol2_(Mat4x3_ m4) {
Mat4x3_ m5 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ m5 = (Mat4x3_)0;
m5 = m4;
const Mat4x3_ _e2 = m5;
const Mat4x3_ _e5 = m5;
@@ -90,7 +90,7 @@ float3 Mat4x3GetCol2_(Mat4x3_ m4) {
}
float3 Mat4x3GetCol3_(Mat4x3_ m6) {
Mat4x3_ m7 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ m7 = (Mat4x3_)0;
m7 = m6;
const Mat4x3_ _e2 = m7;
const Mat4x3_ _e5 = m7;
@@ -99,7 +99,7 @@ float3 Mat4x3GetCol3_(Mat4x3_ m6) {
}
float4 Mul(Mat4x4_ m8, float4 v) {
Mat4x4_ m9 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x4_ m9 = (Mat4x4_)0;
float4 v1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
m9 = m8;
v1 = v;
@@ -115,7 +115,7 @@ float4 Mul(Mat4x4_ m8, float4 v) {
}
float3 Mul1(Mat4x3_ m10, float4 v2) {
Mat4x3_ m11 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ m11 = (Mat4x3_)0;
float4 v3 = float4(0.0f, 0.0f, 0.0f, 0.0f);
m11 = m10;
v3 = v2;
@@ -129,7 +129,7 @@ float3 Mul1(Mat4x3_ m10, float4 v2) {
}
float2 Mul2(Mat4x2_ m12, float4 v4) {
Mat4x2_ m13 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x2_ m13 = (Mat4x2_)0;
float4 v5 = float4(0.0f, 0.0f, 0.0f, 0.0f);
m13 = m12;
v5 = v4;
@@ -142,7 +142,7 @@ float2 Mul2(Mat4x2_ m12, float4 v4) {
float4 Mul3(float3 v6, Mat4x3_ m14) {
float3 v7 = float3(0.0f, 0.0f, 0.0f);
Mat4x3_ m15 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ m15 = (Mat4x3_)0;
v7 = v6;
m15 = m14;
const Mat4x3_ _e5 = m15;
@@ -162,7 +162,7 @@ float4 Mul3(float3 v6, Mat4x3_ m14) {
Mat4x4_ _Mat4x4_(float n) {
float n1 = 0.0f;
Mat4x4_ o = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x4_ o = (Mat4x4_)0;
n1 = n;
const float _e4 = n1;
o.mx = float4(_e4, 0.0f, 0.0f, 0.0f);
@@ -177,8 +177,8 @@ Mat4x4_ _Mat4x4_(float n) {
}
Mat4x4_ _Mat4x4_1(Mat4x3_ m16) {
Mat4x3_ m17 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x4_ o1 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ m17 = (Mat4x3_)0;
Mat4x4_ o1 = (Mat4x4_)0;
m17 = m16;
const Mat4x4_ _e4 = _Mat4x4_(1.0f);
o1 = _e4;
@@ -193,8 +193,8 @@ Mat4x4_ _Mat4x4_1(Mat4x3_ m16) {
}
Mat4x4_ _Mat4x4_2(Mat4x2_ m18) {
Mat4x2_ m19 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x4_ o2 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x2_ m19 = (Mat4x2_)0;
Mat4x4_ o2 = (Mat4x4_)0;
m19 = m18;
const Mat4x4_ _e4 = _Mat4x4_(1.0f);
o2 = _e4;
@@ -208,7 +208,7 @@ Mat4x4_ _Mat4x4_2(Mat4x2_ m18) {
Mat4x3_ _Mat4x3_(float n2) {
float n3 = 0.0f;
Mat4x3_ o3 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ o3 = (Mat4x3_)0;
n3 = n2;
const float _e4 = n3;
o3.mx = float4(_e4, 0.0f, 0.0f, 0.0f);
@@ -221,8 +221,8 @@ Mat4x3_ _Mat4x3_(float n2) {
}
Mat4x3_ _Mat4x3_1(Mat4x4_ m20) {
Mat4x4_ m21 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ o4 = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x4_ m21 = (Mat4x4_)0;
Mat4x3_ o4 = (Mat4x3_)0;
m21 = m20;
const Mat4x4_ _e4 = m21;
o4.mx = _e4.mx;
@@ -235,7 +235,7 @@ Mat4x3_ _Mat4x3_1(Mat4x4_ m20) {
}
void main1() {
Mat4x3_ t_PosMtx = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
Mat4x3_ t_PosMtx = (Mat4x3_)0;
float2 t_TexSpaceCoord = float2(0.0f, 0.0f);
const float _e15 = a_PosMtxIdx1;
const Mat4x3_ _e18 = tint_symbol_5(global2, (48u * uint(int(_e15))));