[Mesa-dev] [PATCH v3 01/24] mesa/format_utils: Fix a bug in unorm_to_float helper function
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Tue Dec 9 23:02:12 PST 2014
On Wednesday, December 10, 2014 03:53:57 PM Michel Dänzer wrote:
> On 09.12.2014 21:06, Iago Toral Quiroga wrote:
> > From: Jason Ekstrand <jason.ekstrand at intel.com>
> >
> > This patch fixes the return of a wrong value when x is lower than
> > -MAX_INT(src_bits) as the result would not be between [-1.0 1.0].
> >
> > v2 by Samuel Iglesias <siglesias at igalia.com>:
> > - Modify unorm_to_float() to avoid doing the division when
> >
> > x == -MAX_INT(src_bits)
> >
> > Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> > ---
> >
> > src/mesa/main/format_utils.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
> > index 93a0cea..5dd0848 100644
> > --- a/src/mesa/main/format_utils.c
> > +++ b/src/mesa/main/format_utils.c
> > @@ -152,7 +152,7 @@ unorm_to_float(unsigned x, unsigned src_bits)
> >
> > static inline float
> > snorm_to_float(int x, unsigned src_bits)
> > {
> >
> > - if (x == -MAX_INT(src_bits))
> > + if (x <= -MAX_INT(src_bits))
> >
> > return -1.0f;
> >
> > else
> >
> > return x * (1.0f / (float)MAX_INT(src_bits));
>
> The commit log talks about unorm_to_float, but the code modifies
> snorm_to_float. Also, I think something like
>
> mesa: Fix clamping to -1.0 in snorm_to_float
>
> would be a more useful shortlog.
>
Oh right! I will fix it.
>
> BTW, don't this function and unorm_to_float also need corresponding
> clamping to 1.0 for values >= MAX_INT(src_bits)?
Yes, it makes sense. I will add that check in both places.
Thanks!
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/20141210/4b5bdb1e/attachment.sig>
More information about the mesa-dev
mailing list