From ea6104cf5e9dccbe1dd8c07d1ef08165e4ce2420 Mon Sep 17 00:00:00 2001 From: Petrichor Park Date: Mon, 8 Jul 2024 13:32:59 -0500 Subject: [PATCH] tests/hlsl: Add some tests for the frexp() intrinsic. --- Makefile.am | 1 + tests/hlsl/frexp.shader_test | 116 +++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 tests/hlsl/frexp.shader_test diff --git a/Makefile.am b/Makefile.am index 35035a9f6..dccd89dd3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -140,6 +140,7 @@ vkd3d_shader_tests = \ tests/hlsl/fog.shader_test \ tests/hlsl/for.shader_test \ tests/hlsl/frac.shader_test \ + tests/hlsl/frexp.shader_test \ tests/hlsl/function-cast.shader_test \ tests/hlsl/function-overload.shader_test \ tests/hlsl/function-return.shader_test \ diff --git a/tests/hlsl/frexp.shader_test b/tests/hlsl/frexp.shader_test new file mode 100644 index 000000000..41e065374 --- /dev/null +++ b/tests/hlsl/frexp.shader_test @@ -0,0 +1,116 @@ +[pixel shader todo(sm<6)] +uniform float4 f; + +float4 main() : sv_target +{ + float exp; + float mantissa = frexp(f.x, exp); + return float4(exp, mantissa, 0.0, 0.0); +} + +[test] +uniform 0 float4 3.1415927 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +probe (0, 0) f32(2.0, 0.785398185, 0.0, 0.0) + +uniform 0 float4 -3.1415927 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +if(sm<4) probe (0, 0) f32(2.0, -0.785398185, 0.0, 0.0) +% Starting with shader model 4, negative inputs give positive mantissa. +if(sm>=4) probe (0, 0) f32(2.0, 0.785398185, 0.0, 0.0) + +uniform 0 float4 7604.123 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +probe (0, 0) f32(13.0, 0.92823765, 0.0, 0.0) + +uniform 0 float4 0.00001234 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +probe (0, 0) f32(-16.0, 0.8087142, 0.0, 0.0) + +uniform 0 float4 0.0 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +probe (0, 0) f32(0.0, 0.0, 0.0, 0.0) + +uniform 0 float4 -0.0 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +probe (0, 0) f32(0.0, 0.0, 0.0, 0.0) + +uniform 0 float4 INF 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +if(sm<4) probe (0, 0) f32(-NAN, -NAN, 0, 0) +if(sm>=4) probe (0, 0) f32(129, 0.5, 0, 0) + +uniform 0 float4 -INF 0.0 0.0 0.0 +todo(sm<6 | msl) draw quad +if(sm<4) probe (0, 0) f32(-NAN, -NAN, 0, 0) +if(sm>=4) probe (0, 0) f32(129, 0.5, 0, 0) + +uniform 0 float4 NAN 0 0 0 +todo(sm<6 | msl) draw quad +if(sm<4) probe (0, 0) f32(NAN, NAN, 0, 0) +if(sm>=4) probe (0, 0) f32(129, 0.75, 0, 0) + +% Subnormals. +uniform 0 uint4 0x0007ffff 0 0 0 +todo(sm<6 | msl) draw quad +probe (0, 0) f32(0, 0, 0, 0) + +[pixel shader todo(sm<6)] +float4 main() : sv_target +{ + int arg = 7604; + int exp; + /* Integers are promoted to floats. */ + int mantissa = frexp(arg, exp); + return float4(exp, mantissa, 0, 0); +} + +[test] +todo(sm<6) draw quad +probe (0, 0) f32(13.0, 0.0, 0.0, 0.0) + +[pixel shader todo(sm<6)] +float4 main() : sv_target +{ + bool arg = true; + bool exp; + /* Bools are promoted to floats. */ + bool mantissa = frexp(arg, exp); + return float4(exp, mantissa, 0, 0); +} + +[test] +todo(sm<6) draw quad +if(sm<4) probe (0, 0) f32(0.0, 1.0, 0.0, 0.0) +if(sm>=4) probe (0, 0) f32(1.0, 1.0, 0.0, 0.0) + +[pixel shader todo(sm<6)] +float4 main() : sv_target +{ + half arg = 3.141; + half exp; + /* Halfs are promoted to floats. */ + half mantissa = frexp(arg, exp); + return float4(exp, mantissa, 0, 0); +} + +[test] +todo(sm<6) draw quad +probe (0, 0) f32(2.0, 0.785250008, 0.0, 0.0) + +[require] +shader model >= 5.0 +float64 + +[pixel shader todo] +float4 main() : sv_target +{ + double arg = 3.14156265358979323; + double exp; + double mantissa = frexp(arg, exp); + return float4(exp, mantissa, 0, 0); +} + +[test] +todo(sm<6) draw quad +probe (0, 0) f32(2.0, 0.785390675, 0.0, 0.0)