a905a78a96
vkd3d-shader/hlsl: Use a structure for matrix swizzles.
2024-12-12 17:11:27 +01:00
6c3a60cc54
vkd3d-shader/hlsl: Constant fold casts to boolean.
2024-12-12 16:41:34 +01:00
2c9cf7c78b
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.
2024-12-11 15:32:22 +01:00
a39227c79c
vkd3d-shader/hlsl: Fold logic AND and logic OR identities.
2024-09-03 15:11:16 +02:00
4e7d0faaf0
vkd3d-shader: Replace assert() with VKD3D_ASSERT() in hlsl_constant_ops.c.
2024-08-01 15:18:15 +02:00
2480eec98b
vkd3d-shader/hlsl: Move the "base_type" member to the class-specific union.
2024-05-06 22:12:41 +02:00
ee735e8eed
vkd3d-shader/hlsl: Fold x * 1 identities.
2024-04-30 16:31:05 +02:00
b14f935d0f
vkd3d-shader/hlsl: Fold x + 0 identities.
2024-04-30 16:31:02 +02:00
19fd43214b
vkd3d-shader/hlsl: Ensure that TERNARY condition is always bool.
...
Also, properly casting it to float in lower_ternary() for SM1
avoids creating ABS and NEG on bool types.
2024-04-09 12:26:59 -05:00
4778d051df
vkd3d-shader: Add constant folding for 'floor'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-11-08 22:49:40 +01:00
955932fb55
vkd3d-shader: Add constant folding for 'ceil'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-11-08 22:49:40 +01:00
f3389789b2
vkd3d-shader: Add constant folding for 'rsq'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-10-05 16:16:03 +02:00
a58c659b10
vkd3d-shader/hlsl: Add constant folding for binary complement operator.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-10-05 16:15:56 +02:00
8ebccad3c9
vkd3d-shader/hlsl: Add constant folding for rshift.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-10-05 16:15:54 +02:00
6e74819eb7
vkd3d-shader/hlsl: Add constant folding for lshift.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-10-05 16:15:52 +02:00
8c9d65d6b3
vkd3d-shader/hlsl: Add constant folding for logical 'not', for bools.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-10-05 16:15:50 +02:00
485cbe8cb7
vkd3d-shader/hlsl: Add constant folding for 'sat'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-09-22 11:06:35 +02:00
89c99cccce
vkd3d-shader/hlsl: Add constant folding for 'exp2'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-09-22 11:06:34 +02:00
c16c5caad8
vkd3d-shader/hlsl: Add constant folding for 'fract'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-09-22 11:06:33 +02:00
c69562128a
vkd3d-shader/hlsl: Correctly fold casts from double.
2023-09-22 11:06:29 +02:00
49bbd98a04
vkd3d-shader/hlsl: Correctly fold casts from float.
...
I.e., without invoking undefined behavior in the compiler. The rules
are desumed from the the MSDN documentation for ftoi and ftou.
2023-09-22 11:06:28 +02:00
d9c984c11a
vkd3d-shader/hlsl: Add constant folding for the ternary operator.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-09-22 11:06:23 +02:00
98f63c46f8
vkd3d-shader/hlsl: Use type width in fold_rcp().
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-08-14 18:38:21 +02:00
932c5e36dc
vkd3d-shader/hlsl: Add constant folding for 'log2'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-08-14 18:38:20 +02:00
58bc61e48d
vkd3d-shader/hlsl: Add constant folding for 'sqrt'.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com >
2023-08-14 18:38:18 +02:00