From 3a498520754a6dc5ad30ab021e88f10a6126cadd Mon Sep 17 00:00:00 2001 From: Petrichor Park Date: Mon, 29 Apr 2024 12:45:52 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Implement tests for the rcp() intrinsic. --- Makefile.am | 1 + tests/hlsl/rcp.shader_test | 76 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/hlsl/rcp.shader_test diff --git a/Makefile.am b/Makefile.am index 2b655fa4..1d736d25 100644 --- a/Makefile.am +++ b/Makefile.am @@ -176,6 +176,7 @@ vkd3d_shader_tests = \ tests/hlsl/pow.shader_test \ tests/hlsl/precise-modifier.shader_test \ tests/hlsl/rasteriser-ordered-views.shader_test \ + tests/hlsl/rcp.shader_test \ tests/hlsl/reflect.shader_test \ tests/hlsl/refract.shader_test \ tests/hlsl/register-reservations-numeric.shader_test \ diff --git a/tests/hlsl/rcp.shader_test b/tests/hlsl/rcp.shader_test new file mode 100644 index 00000000..dcfeb924 --- /dev/null +++ b/tests/hlsl/rcp.shader_test @@ -0,0 +1,76 @@ +[pixel shader todo] +uniform float4 f; + +float4 main() : sv_target +{ + return rcp(f); +} + +[test] +uniform 0 float4 1.0 2.0 3.0 4.0 +todo(sm<6) draw quad +probe (0, 0) rgba (1.0, 0.5, 0.3333333, 0.25) 8 + +uniform 0 float4 -1.0 -2.0 -3.0 -4.0 +todo(sm<6) draw quad +probe (0, 0) rgba (-1.0, -0.5, -0.3333333, -0.25) 8 + +uniform 0 float4 12.34 56.78 -90.12 -34.56 +todo(sm<6) draw quad +probe (0, 0) rgba (0.081037275, 0.017611835, -0.011096316, -0.028935184) 8 + +uniform 0 float4 0.25 0.125 0.0625 0.3333333 +todo(sm<6) draw quad +probe (0, 0) rgba (4.0, 8.0, 16.0, 3.0) 8 + +% Degenerate cases +uniform 0 float4 0.0 -0.0 1.0e39 -1.0e39 +todo(sm<6) draw quad +probe (0, 0) rgba (1.0e39, -1.0e39, 0.0, -0.0) 8 + + +[pixel shader todo] +% Check invertibility +uniform float4 f; + +float4 main() : sv_target +{ + return rcp(rcp(f)); +} + +[test] +uniform 0 float4 1.0 2.0 3.0 4.0 +todo(sm<6) draw quad +probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0) 8 + +uniform 0 float4 7.604 3.1415 2.72 9.876 +todo(sm<6) draw quad +probe (0, 0) rgba (7.604, 3.1415, 2.72, 9.876) 8 + +uniform 0 float4 0.0 -0.0 1.0e39 -1.0e39 +todo(sm<6) draw quad +probe (0, 0) rgba (0.0, -0.0, 1.0e39, -1.0e39) + + +[pixel shader todo] +% Make sure swizzling works +uniform float4 f; + +float4 main() : sv_target +{ + float a = rcp(f.x); + float2 b = rcp(f.zy); + float3 c = rcp(f.wxz); + float4 d = rcp(f.zyxw); + + return float4(a, b.y, c.z, d.w); +} + +[test] +uniform 0 float4 1.0 2.0 3.0 4.0 +todo(sm<6) draw quad +probe (0, 0) rgba (1.0, 0.5, 0.3333333, 0.25) 8 + +uniform 0 float4 -1.0 -2.0 -3.0 -4.0 +todo(sm<6) draw quad +probe (0, 0) rgba (-1.0, -0.5, -0.3333333, -0.25) 8