Add support for AVX2 and runtime feature detection (#174)

- [x] run unit tests
- [x] run all samples
This commit is contained in:
Ethan Rutherford 2026-10-04 00:14:34 +02:00 • committed by GitHub
commit e77352cd60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 4681 additions and 3376 deletions

View file

@ -177,6 +177,9 @@ B3_API bool b3IsDoublePrecision( void );
/// an ABI test.
B3_API int b3GetMaxManifoldPoints( void );
/// @return true if the current CPU has the AVX2 instruction set.
B3_API bool b3IsAVX2Available( void );
/**@}*/
//! @cond

View file

@ -219,6 +219,10 @@ B3_API void b3World_EnableWarmStarting( b3WorldId worldId, bool flag );
/// Is constraint warm starting enabled?
B3_API bool b3World_IsWarmStartingEnabled( b3WorldId worldId );
/// Enable the SSE2 fallback even when AVX2 is present. This is for testing.
/// Normally you should use the CMake build settings to disable AVX2.
B3_API void b3World_EnableSSE2Fallback( b3WorldId worldId, bool flag );
/// Get the number of awake bodies
B3_API int b3World_GetAwakeBodyCount( b3WorldId worldId );

View file

@ -188,7 +188,7 @@ B3_INLINE const b3HullFace* b3GetHullFaces( const b3HullData* hull )
/// Get read only SOA vertices. This is an array of vertices with all x values,
/// y values, and z values as separate arrays. The array lengths are padded to
/// a multiple of 4. The padded values are repeats of the first value.
/// a multiple of 8. The padded values are repeats of the first value.
B3_INLINE const float* b3GetHullSoaVertices( const b3HullData* hull )
{
if ( hull->soaVertexOffset == 0 )
@ -201,7 +201,7 @@ B3_INLINE const float* b3GetHullSoaVertices( const b3HullData* hull )
/// Get read only SOA unit normal vectors. This is an array of normals with all x values,
/// y values, and z values as separate arrays. The array lengths are padded to
/// a multiple of 4. The padded values are 0.
/// a multiple of 8. The padded values are 0.
B3_INLINE const float* b3GetHullSoaNormals( const b3HullData* hull )
{
if ( hull->soaNormalOffset == 0 )

View file

@ -2019,7 +2019,7 @@ typedef struct b3HullFace
} b3HullFace;
/// 64-bit hull version. Useful for validating serialized data.
#define B3_HULL_VERSION 0x9D3E61B7C2A4F085ull
#define B3_HULL_VERSION 0x6B1E39D4A87C25F3ull
/// A convex hull.
/// @note This data structure has data hanging off the end and cannot be directly copied.
@ -2105,9 +2105,9 @@ typedef struct b3BoxHull
float vx[8]; ///< vertex x
float vy[8]; ///< vertex y
float vz[8]; ///< vertex z
float nx[8]; ///< normal x, padded to multiple of 4
float ny[8]; ///< normal y, padded to multiple of 4
float nz[8]; ///< normal z, padded to multiple of 4
float nx[8]; ///< normal x, padded to multiple of 8
float ny[8]; ///< normal y, padded to multiple of 8
float nz[8]; ///< normal z, padded to multiple of 8
float edgeCosines[12]; ///< dot(n1, n2) for each full edge.
} b3BoxHull;