HLSL: fix for flattening assignments from non-symbol R-values.
If a member-wise assignment from a non-flattened struct to a flattened struct sees a complex R-value (not a symbol), it now creates a temporary to hold that value, to avoid repeating the R-value. This avoids, e.g, duplicating a whole function call. Also, it avoids re-using the AST node, making a new one for each member inside the member loop. The latter (re-use of AST node) was also an issue in the GetDimensions intrinsic decomposition, so this PR fixes that one too.
This commit is contained in:
18
Test/hlsl.flatten.return.frag
Normal file
18
Test/hlsl.flatten.return.frag
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 color : SV_Target0;
|
||||
float other_struct_member1;
|
||||
float other_struct_member2;
|
||||
float other_struct_member3;
|
||||
};
|
||||
|
||||
PS_OUTPUT Func1()
|
||||
{
|
||||
return PS_OUTPUT(float4(1), 2, 3, 4);
|
||||
}
|
||||
|
||||
PS_OUTPUT main()
|
||||
{
|
||||
return Func1();
|
||||
}
|
||||
Reference in New Issue
Block a user