mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-25 11:45:53 +01:00
RSBinToGroups() use __builtin_clz() instead of manual bsr if available
should be faster.
This commit is contained in:
parent
46353ffc5d
commit
c58328d881
|
@ -499,18 +499,27 @@ static void RSBinToGroups( ScenePolygon *pspoFirst)
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// emulate x86's bsr opcode...not fast. :/
|
// emulate x86's bsr opcode...
|
||||||
register DWORD val = _ctGroupsCount;
|
|
||||||
register INDEX bsr = 31;
|
// GCC and clang have an architecture-independent intrinsic for this
|
||||||
if (val != 0)
|
// (it counts leading zeros starting at MSB and is undefined for 0)
|
||||||
{
|
#ifdef __GNUC__
|
||||||
while (bsr > 0)
|
INDEX bsr = 31;
|
||||||
{
|
if(_ctGroupsCount != 0) bsr -= __builtin_clz(_ctGroupsCount);
|
||||||
if (val & (1l << bsr))
|
else bsr = 0;
|
||||||
break;
|
#else // another compiler - doing it manually.. not fast. :/
|
||||||
bsr--;
|
register DWORD val = _ctGroupsCount;
|
||||||
}
|
register INDEX bsr = 31;
|
||||||
}
|
if (val != 0)
|
||||||
|
{
|
||||||
|
while (bsr > 0)
|
||||||
|
{
|
||||||
|
if (val & (1l << bsr))
|
||||||
|
break;
|
||||||
|
bsr--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_ctGroupsCount = 2 << bsr;
|
_ctGroupsCount = 2 << bsr;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user