From f9d12e5596c1b8697b3036e6d211e90ce6ca850b Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Fri, 10 Oct 2025 13:11:24 +1000 Subject: [PATCH] tests/hlsl: Add a precise MAD test where the first component is not x. --- .../hlsl/arithmetic-float-uniform.shader_test | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/hlsl/arithmetic-float-uniform.shader_test b/tests/hlsl/arithmetic-float-uniform.shader_test index 9e814db2c..ccc30602d 100644 --- a/tests/hlsl/arithmetic-float-uniform.shader_test +++ b/tests/hlsl/arithmetic-float-uniform.shader_test @@ -154,6 +154,55 @@ uniform 0 float4 1.5 1.5 -1.5 -1.5 draw quad probe (0, 0) f32(1.0, 2.0, -2.0, -1.0) +% precise mad() where the first component is not x. +[pixel shader fail(sm<2)] +uniform float4 a, b, c; + +float4 main() : sv_target +{ + precise float4 r = float4(c.zw * c.zw, mad(b.xy, b.zw, c.xy)); + + return r * a; +} + +[test] +uniform 0 float4 1.5 1.5 1.5 1.5 +uniform 4 float4 1.00000007 -42.1 1.625 -5.0 +uniform 8 float4 1.00000007 -1.0 2.0 2.0 +todo(msl & sm>=6) draw quad +probe (0, 0) f32(6.0, 6.0, 3.93750072, 314.25) 1 + +[require] +shader model >= 5.0 +shader model < 5.1 + +[pixel shader dxbc-tpf-hex] +% precise mad() where the first component is not x. +43425844 94c81680 cb1272b3 157657b2 1c94b136 00000001 00000120 % DXBC header +00000003 0000002c 0000003c 00000070 % +4e475349 00000008 00000000 00000008 % .input +4e47534f 0000002c 00000001 00000008 % .output +00000020 00000000 00000000 00000003 00000000 0000000f % .param sv_target.xyzw, o0.xyzw, float, TARGET +745f7673 65677261 abab0074 % +58454853 000000a8 00000050 0000002a % .text ps_5_0 +0100086a % dcl_globalFlags refactoringAllowed +04000059 00208e46 00000000 00000003 % dcl_constantBuffer cb0[1], immediateIndexed +03000065 001020f2 00000000 % dcl_output o0.xyzw +02000068 00000001 % dcl_temps 1 +09180038 00100032 00000000 00208ae6 00000000 00000002 % mul [precise(xy)] r0.xy, cb0[2].zwzz, + 00208ae6 00000000 00000002 % cb0[2].zwzz +0c600032 001000c2 00000000 00208406 00000000 00000001 % mad [precise(zw)] r0.zw, cb0[1].xxxy, + 00208ea6 00000000 00000001 00208406 00000000 00000002 % cb0[1].zzzw, cb0[2].xxxy +08000038 001020f2 00000000 00100e46 00000000 00208e46 00000000 00000000 % mul o0.xyzw, r0.xyzw, cb0[0].xyzw +0100003e % ret + +[test] +uniform 0 float4 1.5 1.5 1.5 1.5 +uniform 4 float4 1.00000007 -42.1 1.625 -5.0 +uniform 8 float4 1.00000007 -1.0 2.0 2.0 +todo(glsl | msl) draw quad +todo probe (0, 0) f32(6.0, 6.0, 3.93750072, 314.25) 1 + [require] shader model >= 5.0 float64