[Mesa-dev] Fixup: Use C++ style constant member functions for is_one and is_zero.

Eric Anholt eric at anholt.net
Mon Sep 19 13:20:05 PDT 2011


On Sun, 11 Sep 2011 13:05:38 +0200, Tolga Dalman <tolga.dalman at googlemail.com> wrote:
> Hi Kenneth,
> 
> On Fri,  9 Sep 2011 14:41:45 -0700
> Kenneth Graunke <kenneth at whitecape.org> wrote:
> 
> > -   if (reg->type == BRW_REGISTER_TYPE_F) {
> > -      return reg->imm.f == 0.0;
> > +   if (type == BRW_REGISTER_TYPE_F) {
> > +      return imm.f == 0.0;
> [...]
> > -   if (reg->type == BRW_REGISTER_TYPE_F) {
> > -      return reg->imm.f == 1.0;
> > +   if (type == BRW_REGISTER_TYPE_F) {
> > +      return imm.f == 1.0;
> 
> Shouldn't this rather be something like
> fabs(imm.f - 1.0) < std::numeric_limits<float>::eps() ?
> 
> Nevertheless, I like your patch.

I don't think so: (some variable equal to 1.0) * (1.0 + epsilon) should
return (1.0 + epsilon), while your change would optimize that to return
the variable's value of 1.0, right?  I wouldn't want to do that without
some clear reason to.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110919/632718ee/attachment.pgp>


More information about the mesa-dev mailing list