[Mesa-dev] [PATCH 02/11] i965/blorp: round to nearest when converting float to integer
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Tue Feb 10 23:00:38 PST 2015
On Tuesday 10 February 2015 11:32:32 Matt Turner wrote:
> On Tue, Feb 10, 2015 at 10:52 AM, Matt Turner <mattst88 at gmail.com> wrote:
> >> + /* Round floating point values to nearest integer to avoid "off by
> >> one texel" + * kind of errors when blitting.
> >> + */
> >> + x0 = wm_push_consts.dst_x0 = dst_x0 + 0.5;
> >> + y0 = wm_push_consts.dst_y0 = dst_y0 + 0.5;
> >> + x1 = wm_push_consts.dst_x1 = dst_x1 + 0.5;
> >> + y1 = wm_push_consts.dst_y1 = dst_y1 + 0.5;
> >
> > Can we use round(dst_??) here instead?
> >
> > x + 0.5 has the surprising property that nextafter(0.5, 0.0) (i.e.,
> > the largest value less than 0.5) + 0.5 is exactly half way between the
> > largest value less than 1.0 and 1.0, so it gets rounded to 1.0 instead
> > of down to 0.0. It's an uncommon case, but round() should better
> > describe what we want to do anyway.
>
> And just to short circuit the process, assuming round() works have a
>
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
>
> and feel free to commit. Shouldn't be necessary to resend.
Thanks for your review, Matt. I'll do the change and check that it works as
expected.
Sam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150211/9f179706/attachment.sig>
More information about the mesa-dev
mailing list