mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
2c9cf7c78b
We normalize binary expressions by attempting to group constants together, in order to facilitate further simplification of the expressions. For any binary operator OP, non-constants x, y, and constants a, b, we apply the following rewrite rules: a OP x -> x OP a, if OP is commutative. (x OP a) OP b -> x OP (a OP b), if OP is associative. (x OP a) OP y -> (x OP y) OP a, if OP is associative and commutative. x OP (y OP a) -> (x OP y) OP a, if OP is associative. Note that we consider floating point operations to be non-associative.
71 lines
985 B
Plaintext
71 lines
985 B
Plaintext
[require]
|
|
shader model >= 4.0
|
|
|
|
[pixel shader]
|
|
float4 main() : SV_TARGET
|
|
{
|
|
uint x = 5;
|
|
uint y = 15;
|
|
|
|
return float4(x + y, x - y, x * y, x / y);
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0, 0) rgba (20.0, 4294967296.0, 75.0, 0.0)
|
|
|
|
[pixel shader]
|
|
float4 main() : SV_TARGET
|
|
{
|
|
uint x = 5;
|
|
uint y = 15;
|
|
|
|
return float4(x % y, +x, -x, y / x);
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0, 0) rgba (5.0, 5.0, 4294967296.0, 3.0)
|
|
|
|
[pixel shader fail(sm<6)]
|
|
float4 main() : SV_TARGET
|
|
{
|
|
uint x = 1;
|
|
uint y = 0;
|
|
|
|
return x / y;
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0)
|
|
|
|
[pixel shader fail(sm<6)]
|
|
float4 main() : SV_TARGET
|
|
{
|
|
uint x = 1;
|
|
uint y = 0;
|
|
|
|
return x % y;
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0)
|
|
|
|
|
|
% Test expression normalization and simplification.
|
|
|
|
[pixel shader]
|
|
uniform uint4 x;
|
|
|
|
float4 main() : SV_TARGET
|
|
{
|
|
return 6 + (2 * x * 3) - 5;
|
|
}
|
|
|
|
[test]
|
|
uniform 0 uint4 0 1 2 3
|
|
todo(msl) draw quad
|
|
probe (0, 0) rgba (1.0, 7.0, 13.0, 19.0)
|