From: Petrichor Park ppark@codeweavers.com
Extracted by Conor McCarthy from an HLSL patch, and modified to include SM 6 variations. --- Makefile.am | 1 + tests/hlsl/inverse-trig.shader_test | 91 +++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tests/hlsl/inverse-trig.shader_test
diff --git a/Makefile.am b/Makefile.am index bfd11fdb4..959d0f6ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -121,6 +121,7 @@ vkd3d_shader_tests = \ tests/hlsl/initializer-struct.shader_test \ tests/hlsl/intrinsic-override.shader_test \ tests/hlsl/invalid.shader_test \ + tests/hlsl/inverse-trig.shader_test \ tests/hlsl/is-front-face.shader_test \ tests/hlsl/ldexp.shader_test \ tests/hlsl/length.shader_test \ diff --git a/tests/hlsl/inverse-trig.shader_test b/tests/hlsl/inverse-trig.shader_test new file mode 100644 index 000000000..e2661fbaf --- /dev/null +++ b/tests/hlsl/inverse-trig.shader_test @@ -0,0 +1,91 @@ +% Microsoft natively outputs values that are slightly mathematically wrong. +% VKD3D faithfully does the same. +[pixel shader todo] +uniform float4 a; + +float4 main() : sv_target +{ + return float4(acos(a.x), 0.0, 0.0, 0.0); +} + +[test] +uniform 0 float4 -1.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (3.14159274, 0.0, 0.0, 0.0) 128 + +uniform 0 float4 -0.5 0.0 0.0 0.0 +todo draw quad +probe all rgba (2.094441441, 0.0, 0.0, 0.0) 128 + +uniform 0 float4 0.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (1.57072878, 0.0, 0.0, 0.0) 1024 + +uniform 0 float4 0.5 0.0 0.0 0.0 +todo draw quad +probe all rgba (1.04715133, 0.0, 0.0, 0.0) 256 + +uniform 0 float4 1.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (0.0, 0.0, 0.0, 0.0) 128 + +[pixel shader todo] +uniform float4 a; + +float4 main() : sv_target +{ + return float4(asin(a.x), 0.0, 0.0, 0.0); +} + +[test] +uniform 0 float4 -1.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (-1.57079637, 0.0, 0.0, 0.0) 128 + +[require] +shader model < 6.0 + +[test] +uniform 0 float4 -0.5 0.0 0.0 0.0 +todo draw quad +probe all rgba (-0.523645043, 0.0, 0.0, 0.0) 128 + +% Because sqrt isn't identical across platforms, there is some inaccuracy +% here even with an identical algorithm, and because it's so near zero, +% each ulp is really small. So, in order to pass there needs to be this +% enormous margin. +uniform 0 float4 0.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (0.0000675916672, 0.0, 0.0, 0.0) 131072 + +uniform 0 float4 0.5 0.0 0.0 0.0 +todo draw quad +probe all rgba (0.523645043, 0.0, 0.0, 0.0) 128 + +[require] +shader model >= 6.0 + +% SM 6.0 has instructions for inverse trig, which we implement using the native +% equivalents available in SPIR-V. The values below are from the AMD Windows +% drivers, which are very close to those from Ubuntu's calculator app. Results +% from RADV are a bit lower than these, hence the large max ulp difference. +[test] +uniform 0 float4 -0.5 0.0 0.0 0.0 +todo draw quad +probe all rgba (-0.523598731, 0.0, 0.0, 0.0) 4096 + +uniform 0 float4 0.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (0.0, 0.0, 0.0, 0.0) 128 + +uniform 0 float4 0.5 0.0 0.0 0.0 +todo draw quad +probe all rgba (0.523598731, 0.0, 0.0, 0.0) 4096 + +[require] +% reset requirements + +[test] +uniform 0 float4 1.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (1.57079637, 0.0, 0.0, 0.0) 128