On my Nvidia GeForce GTX 1050 Ti `ddxddy.shader_test` doesn't pass because of considerably different numeric results.
As Giovanni pointed out, this is because my GPU uses the fine derivate and not the coarse derivate to implement ddx() and ddy().
For this reason, the result for ddx|ddy() is quantized so that the test passes if the GPU uses either coarse or fine derivates.
Additionally, tests for both ddx_coarse|ddy_coarse() and ddx_fine|ddy_fine() are added, that expect a more precise result.
From: Francisco Casas fcasas@codeweavers.com
--- tests/ddxddy.shader_test | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/tests/ddxddy.shader_test b/tests/ddxddy.shader_test index 6efb5ab6f..371bb85ff 100644 --- a/tests/ddxddy.shader_test +++ b/tests/ddxddy.shader_test @@ -24,3 +24,43 @@ probe (10, 11) rgba (-0.420000076, -0.164999843, 0.104999900, 0.0) 8 probe (11, 11) rgba (-0.574999928, -0.164999843, 0.104999900, 0.0) 8 probe (12, 10) rgba (-0.874999881, -0.205000162, 0.124999881, 0.0) 8 probe (150, 150) rgba (-7.52500916, -1.56500244, 1.50500488, 0.0) 40 + + +[require] +shader model >= 5.0 + + +[pixel shader todo] +float4 main(float4 pos : sv_position) : sv_target +{ + pos /= 10.0; + float nonlinear = pos.x * pos.y - pos.x * (pos.x + 0.5); + return float4(nonlinear, ddx_coarse(nonlinear), ddy_coarse(nonlinear), 0.0); +} + +[test] +todo draw quad +probe (10, 10) rgba (-0.524999976, -0.164999843, 0.104999900, 0.0) 8 +probe (11, 10) rgba (-0.689999819, -0.164999843, 0.104999900, 0.0) 8 +probe (10, 11) rgba (-0.420000076, -0.164999843, 0.104999900, 0.0) 8 +probe (11, 11) rgba (-0.574999928, -0.164999843, 0.104999900, 0.0) 8 +probe (12, 10) rgba (-0.874999881, -0.205000162, 0.124999881, 0.0) 8 +probe (150, 150) rgba (-7.52500916, -1.56500244, 1.50500488, 0.0) 40 + + +[pixel shader todo] +float4 main(float4 pos : sv_position) : sv_target +{ + pos /= 10.0; + float nonlinear = pos.x * pos.y - pos.x * (pos.x + 0.5); + return float4(nonlinear, ddx_fine(nonlinear), ddy_fine(nonlinear), 0.0); +} + +[test] +todo draw quad +probe (10, 10) rgba (-0.524999976, -0.164999843, 0.104999900, 0.0) 8 +probe (11, 10) rgba (-0.689999819, -0.164999843, 0.114999890, 0.0) 8 +probe (10, 11) rgba (-0.420000076, -0.154999852, 0.104999900, 0.0) 8 +probe (11, 11) rgba (-0.574999928, -0.154999852, 0.114999890, 0.0) 8 +probe (12, 10) rgba (-0.874999881, -0.205000162, 0.124999881, 0.0) 8 +probe (150, 150) rgba (-7.52500916, -1.56500244, 1.50500488, 0.0) 40
From: Francisco Casas fcasas@codeweavers.com
--- tests/ddxddy.shader_test | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/tests/ddxddy.shader_test b/tests/ddxddy.shader_test index 371bb85ff..8e68ce587 100644 --- a/tests/ddxddy.shader_test +++ b/tests/ddxddy.shader_test @@ -1,3 +1,7 @@ +% NOTE: Only allowed from shader model ps_2_1 +[require] +shader model >= 4.0 + [pixel shader] float4 main(float4 pos : sv_position) : sv_target { @@ -13,17 +17,21 @@ float4 main(float4 pos : sv_position) : sv_target { pos /= 10.0; float nonlinear = pos.x * pos.y - pos.x * (pos.x + 0.5); - return float4(nonlinear, ddx(nonlinear), ddy(nonlinear), 0.0); + float4 res = float4(nonlinear, ddx(nonlinear), ddy(nonlinear), 0.0); + + // Each device may use either the coarse or the fine derivate, so use quantization. + return round(30 * res); }
[test] draw quad -probe (10, 10) rgba (-0.524999976, -0.164999843, 0.104999900, 0.0) 8 -probe (11, 10) rgba (-0.689999819, -0.164999843, 0.104999900, 0.0) 8 -probe (10, 11) rgba (-0.420000076, -0.164999843, 0.104999900, 0.0) 8 -probe (11, 11) rgba (-0.574999928, -0.164999843, 0.104999900, 0.0) 8 -probe (12, 10) rgba (-0.874999881, -0.205000162, 0.124999881, 0.0) 8 -probe (150, 150) rgba (-7.52500916, -1.56500244, 1.50500488, 0.0) 40 +probe (10, 10) rgba (-16.0, -5.0, 3.0, 0.0) +probe (11, 10) rgba (-21.0, -5.0, 3.0, 0.0) +probe (10, 11) rgba (-13.0, -5.0, 3.0, 0.0) +probe (11, 11) rgba (-17.0, -5.0, 3.0, 0.0) +probe (12, 10) rgba (-26.0, -6.0, 4.0, 0.0) +probe (16, 16) rgba (-25.0, -7.0, 5.0, 0.0) +probe (150, 150) rgba (-226.0, -47.0, 45.0, 0.0)
[require]
Zebediah Figura (@zfigura) commented about tests/ddxddy.shader_test:
+% NOTE: Only allowed from shader model ps_2_1 +[require] +shader model >= 4.0
That would be unfortunate, do we really need this?
On Tue Jun 6 17:57:18 2023 +0000, Zebediah Figura wrote:
That would be unfortunate, do we really need this?
Well, only if we want to keep the crosstests from failing. ``` shader_runner:1237: Running tests from a Windows cross build shader_runner:1239: Compiling shaders with d3dcompiler_47.dll and executing with d3d9.dll shader_runner:95: Driver string: d3d10warp.dll. shader_runner:96: Device: Microsoft Basic Render Driver, 1414:008c. shader_runner:99: Using WARP device. shader_runner:73: Section [test], line 9: Test failed: Failed to compile shader, hr 0x80004005. shader_runner:73: Section [test], line 28: Test failed: Failed to compile shader, hr 0x80004005. ```
Ideally we would be able to specify
``` [require] shader model >= 2.1 ```
Ideally we would be able to specify
[require] shader model >= 2.1
That should be simple enough to add :-)
Do you already have implementations for the coarse and fine derivatives? They should rather simple to add. If you can add them to the MR we can actually check that the test values for coarse and fine derivatives are accepted on different devices, to minimize the probability we have to edit them again in the futures.