mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Implement normalization of binary expressions.
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.
This commit is contained in:
Notes:
Henri Verbeet
2024-12-11 15:37:25 +01:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1307
@@ -52,3 +52,19 @@ float4 main() : SV_TARGET
|
||||
[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)
|
||||
|
Reference in New Issue
Block a user