vkd3d-shader/hlsl: Use conditional moves for arithmetic operators instead of branching.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov
2023-09-09 20:08:52 +02:00
committed by Alexandre Julliard
parent 34b1c0fe5d
commit 6d1ba83856
Notes: Alexandre Julliard 2023-09-22 22:46:41 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/336
5 changed files with 69 additions and 26 deletions

View File

@@ -58,6 +58,20 @@ uniform 0 float4 45.0 5.0 0.0 0.0
draw quad
probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader]
float4 x, y;
float4 main() : sv_target
{
return x % y;
}
[test]
uniform 0 float4 5.0 -42.1 4.0 45.0
uniform 4 float4 15.0 -5.0 4.1 5.0
draw quad
probe all rgba (5.0, -2.1, 4.0, 0.0) 4
[require]
% Infinities are not allowed in SM1
shader model >= 4.0

View File

@@ -50,6 +50,19 @@ float4 main() : SV_TARGET
draw quad
probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader]
float4 main() : sv_target
{
float4 x = {5.0, -42.1, 4.0, 45.0};
float4 y = {15.0, -5.0, 4.1, 5.0};
return x % y;
}
[test]
draw quad
probe all rgba (5.0, -2.1, 4.0, 0.0) 4
[require]
% Infinities are not allowed in SM1
shader model >= 4.0

View File

@@ -100,3 +100,22 @@ float4 main() : SV_TARGET
uniform 0 float4 5.0 -7.0 0.0 -10.0
draw quad
probe all rgba (5.0, 7.0, 0.0, 10.0)
[pixel shader]
uniform float4 a;
uniform float4 b;
float4 main() : sv_target
{
int2 x = a.xz;
int2 y = a.yw;
int2 z = b.xy;
int2 w = b.zw;
return float4(x / y, z % w);
}
[test]
uniform 0 float4 45.0 5.0 50.0 10.0
uniform 4 float4 3.0 8.0 2.0 5.0
draw quad
probe all rgba (9.0, 5.0, 1.0, 3.0)

View File

@@ -109,3 +109,17 @@ float4 main() : SV_TARGET
[test]
draw quad
probe all rgba (-2147483648.0, -2147483648.0, -2147483648.0, -2147483648.0)
[pixel shader]
float4 main() : sv_target
{
int2 x = {5, 15};
int2 y = {2, 5};
int2 z = {3, 8};
return float4(x / y, z % y);
}
[test]
draw quad
probe all rgba (2.0, 3.0, 1.0, 3.0)