[Mesa-dev] [PATCH 12/29] tnl: Use bitmask/ffs to iterate enabled lights
Ilia Mirkin
imirkin at alum.mit.edu
Wed May 25 16:21:19 UTC 2016
On Wed, May 25, 2016 at 12:17 PM, 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.
There's also a util_is_power_of_two in gallium -
src/gallium/auxiliary/util/u_math.h. I guess the math helper functions
never made it through the helper unification bikeshed.
More information about the mesa-dev
mailing list