[Mesa-dev] [PATCH 12/29] tnl: Use bitmask/ffs to iterate enabled lights

Matt Turner mattst88 at gmail.com
Wed May 25 19:57:02 UTC 2016


On Wed, May 25, 2016 at 9:17 AM, Ian Romanick <idr at freedesktop.org> wrote:
> On 05/23/2016 11:42 PM, Mathias.Froehlich at gmx.net wrote:
>> From: Mathias Fröhlich <mathias.froehlich at web.de>
>>
>> Replaces loops that iterate all lights and test
>> which of them is enabled by a loop only iterating over
>> the bits set in the enabled bitmask.
>> ---
>>  src/mesa/tnl/t_vb_light.c    |  2 +-
>>  src/mesa/tnl/t_vb_lighttmp.h | 27 ++++++++++++++++++++-------
>>  2 files changed, 21 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
>> index 029265a..0cdb925 100644
>> --- a/src/mesa/tnl/t_vb_light.c
>> +++ b/src/mesa/tnl/t_vb_light.c
>> @@ -394,7 +394,7 @@ static void validate_lighting( struct gl_context *ctx,
>>        tab = _tnl_light_tab;
>>     }
>>     else {
>> -      if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
>> +      if (_mesa_bitcount(ctx->Light._EnabledLights) == 1)
>
> I think using an is_pow2() predicate here would be better.  It looks
> like the only one in Mesa is in src/intel/isl/isl_priv.h, but it should
> be easy enough to add that to somewhere in src/util.

_mesa_is_pow_two in imports.h.


More information about the mesa-dev mailing list