<div dir="ltr">On 27 September 2013 14:18, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>On 09/20/2013 10:15 AM, Paul Berry wrote:<br>
> Mesa/i965 currently (as of commit 1cc3b90) has an inaccurate<br>
> implementation of dFdy() which produces the same results for every<br>
> pixel in an aligned 2x2 block.  This piglit test exposes the<br>
> inaccuracy.<br>
<br>
</div>Two questions:<br>
<br>
 - How did you come up with the error metric values?<br>
<br>
 - Why are the different?<br></blockquote><div><br></div><div>Oops, I was experimenting with the tests while I was debugging and I forgot to restore the original error metrics.  I intended for both error metrics to be 1.0e-3.<br>

<br></div><div>There's a huge amount of leeway for choosing the error metric, though, since the i965 driver is currently so bad--it has an error of 1.0 for dFdy.  With my RFC patch "i965/fs: Improve accuracy of dFdy()." applied, the error is 0.0 for both dFdy and dFdx (the test does computations based on window coordinates, which are always exactly representable as floats on i965, so no numerical errors occur).  So I don't particularly care what error bound we use; I just pulled 1.0e-3 out of the air.<br>
<br></div><div>Note: based on a conversation we had on Thursday, it sounded like you were going to recommend to Chia-I that we go ahead and use his less-accurate dFdx formula as the default, but switch back to the accurate version if GL_FRAGMENT_SHADER_DERIVATIVE_HINT is set to GL_NICEST or a driconf variable is set.  (I haven't seen that email yet--did you forget or are you still weighing options?)  If we decide to go ahead with that plan, then I should probably modify these tests so that they set GL_FRAGMENT_SHADER_DERIVATIVE_HINT to GL_NICEST.<br>
</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div><br>
> ---<br>
>  .../execution/fs-dfdx-accuracy.shader_test         | 35 ++++++++++++++++++++++<br>
>  .../execution/fs-dfdy-accuracy.shader_test         | 35 ++++++++++++++++++++++<br>
>  2 files changed, 70 insertions(+)<br>
>  create mode 100644 tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test<br>
>  create mode 100644 tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test<br>
><br>
> diff --git a/tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test b/tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test<br>
> new file mode 100644<br>
> index 0000000..b8d471c<br>
> --- /dev/null<br>
> +++ b/tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test<br>
> @@ -0,0 +1,35 @@<br>
> +# The spec allows considerable leeway in how dFdx() is calculated,<br>
> +# however the expected implementation is via forward or backward<br>
> +# differencing.  (Implementations are permitted, for instance, to use<br>
> +# forward differencing for some pixels and backward differencing for<br>
> +# other pixels).<br>
> +#<br>
> +# This test computes dFdx(x*y), which should exactly equal y at every<br>
> +# pixel, regardless of whether forward or backward differencing is<br>
> +# used.<br>
> +<br>
> +[require]<br>
> +GLSL >= 1.10<br>
> +<br>
> +[vertex shader]<br>
> +void main()<br>
> +{<br>
> +     gl_Position = gl_Vertex;<br>
> +}<br>
> +<br>
> +[fragment shader]<br>
> +void main()<br>
> +{<br>
> +     float x = gl_FragCoord.x;<br>
> +     float y = gl_FragCoord.y;<br>
> +     float xy = x * y;<br>
> +     float dxydx = dFdx(xy);<br>
> +     if (distance(dxydx, y) > 1.0e-3)<br>
> +             gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);<br>
> +     else<br>
> +             gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);<br>
> +}<br>
> +<br>
> +[test]<br>
> +draw rect -1 -1 2 2<br>
> +probe all rgba 0.0 1.0 0.0 1.0<br>
> diff --git a/tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test b/tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test<br>
> new file mode 100644<br>
> index 0000000..5c02680<br>
> --- /dev/null<br>
> +++ b/tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test<br>
> @@ -0,0 +1,35 @@<br>
> +# The spec allows considerable leeway in how dFdy() is calculated,<br>
> +# however the expected implementation is via forward or backward<br>
> +# differencing.  (Implementations are permitted, for instance, to use<br>
> +# forward differencing for some pixels and backward differencing for<br>
> +# other pixels).<br>
> +#<br>
> +# This test computes dFdy(x*y), which should exactly equal x at every<br>
> +# pixel, regardless of whether forward or backward differencing is<br>
> +# used.<br>
> +<br>
> +[require]<br>
> +GLSL >= 1.10<br>
> +<br>
> +[vertex shader]<br>
> +void main()<br>
> +{<br>
> +     gl_Position = gl_Vertex;<br>
> +}<br>
> +<br>
> +[fragment shader]<br>
> +void main()<br>
> +{<br>
> +     float x = gl_FragCoord.x;<br>
> +     float y = gl_FragCoord.y;<br>
> +     float xy = x * y;<br>
> +     float dxydy = dFdy(xy);<br>
> +     if (distance(dxydy, x) > 1.0e-1)<br>
> +             gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);<br>
> +     else<br>
> +             gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);<br>
> +}<br>
> +<br>
> +[test]<br>
> +draw rect -1 -1 2 2<br>
> +probe all rgba 0.0 1.0 0.0 1.0<br>
><br>
<br>
</div></div></blockquote></div><br></div></div>