vkd3d-shader/hlsl: Fold some general unary identities.

The following unary identities are applied:

  ||x|| -> |x|
  |-x| -> |x|
  ~(~x) -> x
  f(g(x)) -> g(x), where f(), g() are floor() or ceil() functions.
  -(-x) -> x
  !!x -> x
  !(x == y) -> x != y, !(x < y) -> x >= y, etc (for integers).
This commit is contained in:
Shaun Ren
2025-07-28 21:51:09 -04:00
committed by Henri Verbeet
parent 45e549c1b2
commit 245430002a
Notes: Henri Verbeet 2025-08-21 16:34:36 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1648
5 changed files with 197 additions and 2 deletions

View File

@@ -179,3 +179,25 @@ if(sm>=4) uniform 0 int -1
if(sm>=4) uniform 1 int 3
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.0, 1.0, 0.0, 0.0)
[pixel shader]
int a, b;
float4 main() : SV_TARGET
{
return float4(!(a == b), !(a != b), !(a < b), !(a >= b));
}
[test]
if(sm<4) uniform 0 float 0
if(sm<4) uniform 4 float 5
if(sm>=4) uniform 0 int 0
if(sm>=4) uniform 1 int 5
todo(msl & sm>=6) draw quad
probe (0, 0) f32(1.0, 0.0, 0.0, 1.0)
if(sm<4) uniform 0 float -1
if(sm<4) uniform 4 float -1
if(sm>=4) uniform 0 int -1
if(sm>=4) uniform 1 int -1
todo(msl & sm>=6) draw quad
probe (0, 0) f32(0.0, 1.0, 1.0, 0.0)