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

Michal Krol michal at vmware.com
Tue Sep 20 00:17:37 PDT 2011


----- Original Message -----
> 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.
> 

And this is still the case since the optimisation applies for deltas that are *less* than epsilon, not *less-or-equal* as you imply.

-- 
michal


More information about the mesa-dev mailing list