tests/hlsl: Test integer modulus with big integers.

Note that in d3dbc target profiles it gives different results when this
operation is constant folded compared to when it is not.

This suggests that whatever pass lowers the modulus operation to d3dbc
operations doesn't do it before constant folding.

Also note that when constant folded, d3dbc results differ from tpf
results for negative operands, because of the loss of precision that
happens when NEG is constant folded.

So the same integer modulus expression can have 3 different results
depending on the context.
This commit is contained in:
Francisco Casas
2025-02-28 13:25:21 -03:00
committed by Henri Verbeet
parent a3f80061b1
commit 080672478d
Notes: Henri Verbeet 2025-03-18 16:03:46 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1427
2 changed files with 31 additions and 0 deletions

View File

@@ -120,6 +120,23 @@ uniform 4 float4 3.0 8.0 2.0 5.0
todo(sm<4 | glsl | msl) draw quad todo(sm<4 | glsl | msl) draw quad
probe (0, 0) rgba (9.0, 5.0, 1.0, 3.0) probe (0, 0) rgba (9.0, 5.0, 1.0, 3.0)
[pixel shader todo(sm<4)]
float f;
float4 main() : sv_target
{
int a = 16777217; // This rounds down to 16777216 when converted to float.
int b = f;
return float4(a % b, a % (-b), (-a) % b, (-a) % (-b));
}
[test]
uniform 0 float 10.0
todo(sm<4 | glsl | msl) draw quad
if(sm<4) probe (0, 0) rgba(6, 6, -6, -6)
if(sm>=4) probe (0, 0) rgba(7, 7, -7, -7)
[require] [require]
shader model >= 6.0 shader model >= 6.0
int64 int64

View File

@@ -165,3 +165,17 @@ float4 main() : sv_target
draw quad draw quad
todo if(sm<4) probe (0, 0) rgba(16782202, 16782200, 0, 0) todo if(sm<4) probe (0, 0) rgba(16782202, 16782200, 0, 0)
if(sm>=4) probe (0, 0) rgba(16782202, 16782202, 0, 0) if(sm>=4) probe (0, 0) rgba(16782202, 16782202, 0, 0)
[pixel shader]
float4 main() : sv_target
{
int a = 16777217; // This rounds down to 16777216 when converted to float.
int b = 10;
return float4(a % b, a % (-b), (-a) % b, (-a) % (-b));
}
[test]
draw quad
todo if(sm<4) probe (0, 0) rgba(7, 7, -6, -6)
if(sm>=4) probe (0, 0) rgba(7, 7, -7, -7)