Add support for AVX2 and runtime feature detection (#174)
- [x] run unit tests - [x] run all samples
This commit is contained in:
parent
51f056e0a9
commit
e77352cd60
53 changed files with 4681 additions and 3376 deletions
21
src/solver.c
21
src/solver.c
|
|
@ -1434,15 +1434,11 @@ static void b3BulletBodyTask( int startIndex, int endIndex, int workerIndex, voi
|
|||
b3TracyCZoneEnd( bullet_body_task );
|
||||
}
|
||||
|
||||
#if B3_SIMD_WIDTH == 4
|
||||
#define B3_SIMD_SHIFT 2
|
||||
#else
|
||||
#define B3_SIMD_SHIFT 0
|
||||
#endif
|
||||
|
||||
// Solve with graph coloring
|
||||
void b3Solve( b3World* world, b3StepContext* stepContext )
|
||||
{
|
||||
int simdShift = world->simdWidth == 8 ? 3 : 2;
|
||||
|
||||
// Only count steps that advance the simulation
|
||||
world->stepIndex += 1;
|
||||
|
||||
|
|
@ -1526,8 +1522,7 @@ void b3Solve( b3World* world, b3StepContext* stepContext )
|
|||
activeColorIndices[c] = i;
|
||||
|
||||
// Ceiling for wide constraint count
|
||||
int colorWideConstraintCount =
|
||||
colorConvexContactCount > 0 ? ( ( colorConvexContactCount - 1 ) >> B3_SIMD_SHIFT ) + 1 : 0;
|
||||
int colorWideConstraintCount = colorConvexContactCount > 0 ? ( ( colorConvexContactCount - 1 ) >> simdShift ) + 1 : 0;
|
||||
wideContactCount += colorWideConstraintCount;
|
||||
colorWideContactCounts[c] = colorWideConstraintCount;
|
||||
|
||||
|
|
@ -1561,9 +1556,8 @@ void b3Solve( b3World* world, b3StepContext* stepContext )
|
|||
b3BlockDim meshPrepareDim = b3ComputeBlockCount( contactCount, minContactsPerBlock, maxBlockCount );
|
||||
b3BlockDim jointPrepareDim = b3ComputeBlockCount( jointCount, minJointsPerBlock, maxBlockCount );
|
||||
|
||||
int wideContactByteCount = b3GetWideContactConstraintByteCount();
|
||||
b3ContactConstraintWide* wideConstraints =
|
||||
(b3ContactConstraintWide*)b3StackAlloc( &world->stack, wideContactCount * wideContactByteCount, "wide contacts" );
|
||||
int wideContactByteCount = b3GetWideContactConstraintByteCount( world->simdWidth );
|
||||
void* wideConstraints = b3StackAlloc( &world->stack, wideContactCount * wideContactByteCount, "wide contacts" );
|
||||
b3ContactConstraint* contactConstraints =
|
||||
(b3ContactConstraint*)b3StackAlloc( &world->stack, contactCount * sizeof( b3ContactConstraint ), "contacts" );
|
||||
b3ManifoldConstraint* manifoldConstraints = (b3ManifoldConstraint*)b3StackAlloc(
|
||||
|
|
@ -1613,10 +1607,9 @@ void b3Solve( b3World* world, b3StepContext* stepContext )
|
|||
}
|
||||
else
|
||||
{
|
||||
color->wideConstraints =
|
||||
(b3ContactConstraintWide*)( (uint8_t*)wideConstraints + wideBase * wideContactByteCount );
|
||||
color->wideConstraints = ( (uint8_t*)wideConstraints + wideBase * wideContactByteCount );
|
||||
|
||||
int colorContactCountW = ( ( colorConvexContactCount - 1 ) >> B3_SIMD_SHIFT ) + 1;
|
||||
int colorContactCountW = ( ( colorConvexContactCount - 1 ) >> simdShift ) + 1;
|
||||
color->wideConstraintCount = colorContactCountW;
|
||||
wideBase += colorContactCountW;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue