From a3f80061b14db47c95ec2ef113248eecabb1f771 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Thu, 13 Mar 2025 02:35:01 -0300 Subject: [PATCH] tests/hlsl: Test for loss of precision on integer negation in d3dbc target profiles. --- tests/hlsl/arithmetic-int.shader_test | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/hlsl/arithmetic-int.shader_test b/tests/hlsl/arithmetic-int.shader_test index e9e247e3..84edb276 100644 --- a/tests/hlsl/arithmetic-int.shader_test +++ b/tests/hlsl/arithmetic-int.shader_test @@ -137,3 +137,31 @@ float4 main() : sv_target [test] draw quad probe (0, 0) rgba (2.0, 3.0, 1.0, 3.0) + +% On SM1, negation constant folding is performed with float arithmetic. +[pixel shader] +float4 main() : sv_target +{ + int a = -2147483648; + + return int4(a, -a, 0, 0); +} + +[test] +draw quad +todo if(sm<4) probe (0, 0) rgba(-2147483648.0, 2147483648.0, 0, 0) +if(sm>=4) probe (0, 0) rgba(-2147483648.0, -2147483648.0, 0, 0) + +% Note that the negation here causes loss of precision on SM1. +[pixel shader] +float4 main() : sv_target +{ + int a = 16782201; // This rounds down to 16782200 when converted to float. + + return float4(a + 1, (-(-a)) + 1, 0, 0); +} + +[test] +draw quad +todo if(sm<4) probe (0, 0) rgba(16782202, 16782200, 0, 0) +if(sm>=4) probe (0, 0) rgba(16782202, 16782202, 0, 0)