[Mesa-dev] [PATCH 11/29] mesa: Use bitmask/ffs to iterate enabled lights for building ff shader keys.

Ilia Mirkin imirkin at alum.mit.edu
Wed May 25 13:14:27 UTC 2016


On May 25, 2016 6:06 AM, "Erik Faye-Lund" <kusmabite at gmail.com> wrote:
>
> On Tue, May 24, 2016 at 8:42 AM,  <Mathias.Froehlich at gmx.net> wrote:
> > From: Mathias Fröhlich <mathias.froehlich at web.de>
> >
> > Replaces a loop that iterates all lights and test
> > which of them is enabled by a loop only iterating over
> > the bits set in the enabled bitmask.
>
> This takes the code from something very obvious and easy to follow to
> something you'll have to think twice about the correctness of...
>
> Since MAX_LIGHTS is 8, this seems a bit like a premature optimization
> to me. Does this patch yield any measurable improvement in speed in
> any real-world applications?

It's a pretty common pattern... the first time you see it, you have to
think about it, but after that, it's pretty obvious. A lot of little gains
can add up to a big gain, so I'd say this is worthwhile.

> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160525/2dd34ad7/attachment.html>


More information about the mesa-dev mailing list