[Mesa-dev] [PATCH] intel/blorp: Increase the presision of coordinate transform calculations

Kenneth Graunke kenneth at whitecape.org
Sat Sep 3 18:44:15 UTC 2016


On Saturday, September 3, 2016 10:42:01 AM PDT Jason Ekstrand wrote:
> The result of this calculation goes into an fma() in the shader and we
> would like it to be as precise as possible.  The division in particular,
> was a source of inprecision whenever dst1 - dst0 was not a power of two.
> This fixes a bunch of the new Vulkan CTS tests for blitting using a
> filtering of NEAREST.
> 
> Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
> ---
>  src/intel/blorp/blorp_blit.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
> index f4d81e6..0cb8b1a 100644
> --- a/src/intel/blorp/blorp_blit.c
> +++ b/src/intel/blorp/blorp_blit.c
> @@ -1256,7 +1256,7 @@ brw_blorp_setup_coord_transform(struct brw_blorp_coord_transform *xform,
>                                  GLfloat dst0, GLfloat dst1,
>                                  bool mirror)
>  {
> -   float scale = (src1 - src0) / (dst1 - dst0);
> +   double scale = (double)(src1 - src0) / (double)(dst1 - dst0);
>     if (!mirror) {
>        /* When not mirroring a coordinate (say, X), we need:
>         *   src_x - src_x0 = (dst_x - dst_x0 + 0.5) * scale
> @@ -1269,7 +1269,7 @@ brw_blorp_setup_coord_transform(struct brw_blorp_coord_transform *xform,
>         * so 0.5 provides the necessary correction.
>         */
>        xform->multiplier = scale;
> -      xform->offset = src0 + (-dst0 + 0.5f) * scale;
> +      xform->offset = src0 + (-(double)dst0 + 0.5) * scale;
>     } else {
>        /* When mirroring X we need:
>         *   src_x - src_x0 = dst_x1 - dst_x - 0.5
> @@ -1277,7 +1277,7 @@ brw_blorp_setup_coord_transform(struct brw_blorp_coord_transform *xform,
>         *   src_x = src_x0 + (dst_x1 -dst_x - 0.5) * scale
>         */
>        xform->multiplier = -scale;
> -      xform->offset = src0 + (dst1 - 0.5f) * scale;
> +      xform->offset = src0 + ((double)dst1 - 0.5) * scale;
>     }
>  }

Sounds reasonable.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

(really more of an ack, but...)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160903/066534bd/attachment.sig>


More information about the mesa-dev mailing list