Skip to content

Commit

Permalink
[hlsl-out] zero init struct constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed May 3, 2022
1 parent 9c8a518 commit 1869c68
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/back/hlsl/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ impl<'a, W: Write> super::Writer<'a, W> {
let struct_name = &self.names[&NameKey::Type(constructor.ty)];
writeln!(
self.out,
"{}{} {};",
INDENT, struct_name, RETURN_VARIABLE_NAME
"{}{} {} = ({})0;",
INDENT, struct_name, RETURN_VARIABLE_NAME, struct_name
)?;
for (i, member) in members.iter().enumerate() {
let field_name = &self.names[&NameKey::StructMember(constructor.ty, i as u32)];
Expand Down
2 changes: 1 addition & 1 deletion tests/out/hlsl/access.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void SetMatScalarmOnBaz(Baz obj, float scalar, uint mat_idx, uint vec_idx) {
}

Baz ConstructBaz(float3x2 arg0) {
Baz ret;
Baz ret = (Baz)0;
ret.m_0 = arg0[0];
ret.m_1 = arg0[1];
ret.m_2 = arg0[2];
Expand Down
4 changes: 2 additions & 2 deletions tests/out/hlsl/interface.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct FragmentInput_fragment {
};

VertexOutput ConstructVertexOutput(float4 arg0, float arg1) {
VertexOutput ret;
VertexOutput ret = (VertexOutput)0;
ret.position = arg0;
ret._varying = arg1;
return ret;
Expand All @@ -55,7 +55,7 @@ VertexOutput_vertex vertex(uint vertex_index : SV_VertexID, uint instance_index
}

FragmentOutput ConstructFragmentOutput(float arg0, uint arg1, float arg2) {
FragmentOutput ret;
FragmentOutput ret = (FragmentOutput)0;
ret.depth = arg0;
ret.sample_mask = arg1;
ret.color = arg2;
Expand Down
2 changes: 1 addition & 1 deletion tests/out/hlsl/operators.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Foo {
};

Foo ConstructFoo(float4 arg0, int arg1) {
Foo ret;
Foo ret = (Foo)0;
ret.a = arg0;
ret.b = arg1;
return ret;
Expand Down
4 changes: 2 additions & 2 deletions tests/out/hlsl/quad-vert.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ float Constructarray1_float_(float arg0)[1] {
}

gl_PerVertex Constructgl_PerVertex(float4 arg0, float arg1, float arg2[1], float arg3[1]) {
gl_PerVertex ret;
gl_PerVertex ret = (gl_PerVertex)0;
ret.gl_Position = arg0;
ret.gl_PointSize = arg1;
ret.gl_ClipDistance = arg2;
Expand Down Expand Up @@ -45,7 +45,7 @@ void main_1()
}

type_9 Constructtype_9(float2 arg0, float4 arg1) {
type_9 ret;
type_9 ret = (type_9)0;
ret.member = arg0;
ret.gl_Position = arg1;
return ret;
Expand Down
2 changes: 1 addition & 1 deletion tests/out/hlsl/quad.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct FragmentInput_frag_main {
};

VertexOutput ConstructVertexOutput(float2 arg0, float4 arg1) {
VertexOutput ret;
VertexOutput ret = (VertexOutput)0;
ret.uv = arg0;
ret.position = arg1;
return ret;
Expand Down
2 changes: 1 addition & 1 deletion tests/out/hlsl/skybox.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct FragmentInput_fs_main {
};

VertexOutput ConstructVertexOutput(float4 arg0, float3 arg1) {
VertexOutput ret;
VertexOutput ret = (VertexOutput)0;
ret.position = arg0;
ret.uv = arg1;
return ret;
Expand Down

0 comments on commit 1869c68

Please sign in to comment.