vkd3d/tests/hlsl/initializer-multi.shader_test
Francisco Casas 62c891b796 vkd3d-shader/hlsl: Declare vars individually when parsing regular declarations.
In a declaration with multiple variables, the variables must be created
before the initializer of the next variable is parsed. This is required
for initializers such as:

    float a = 1, b = a, c = b + 1;

A requisite for this is that the type information is parsed in the same
rule as the first variable (as a variable_def_typed) so it is
immediately available to declare the first variable. Then, the next
untyped variable declaration is parsed, and the type from the first
variable can be used to declare the second, before the third is parsed,
and so on.
2023-07-04 22:39:21 +02:00

53 lines
833 B
Plaintext

[pixel shader]
float4 main() : sv_target
{
float a = 2.0, b = a + 1.0, c = b;
return float4(a, b, c, 0);
}
[test]
draw quad
probe all rgba (2, 3, 3, 0)
[pixel shader fail]
float4 main() : sv_target
{
float a = 2.0, b = c + 1.0, c = b;
return float4(0);
}
[pixel shader todo]
float4 main() : sv_target
{
struct apple {
float a;
int b;
} apple1 = {7.2, 8.1}, apple2 = apple1;
return float4(apple1.a, apple1.b, apple2.a, apple2.b);
}
[test]
todo draw quad
probe all rgba (7.2, 8.0, 7.2, 8.0)
[pixel shader todo]
float4 main() : sv_target
{
struct apple {
float a;
int b;
} apple1 = {5.2, 9.1}, apples[2] = {apple1, apple1};
return float4(apples[0].a, apples[0].b, apples[1].a, apples[1].b);
}
[test]
todo draw quad
probe all rgba (5.2, 9.0, 5.2, 9.0)