diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4544fc6..66f5418 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,10 +2,7 @@ name: CI Build on: - push: - branches: [ main ] - pull_request: - branches: [ main ] + workflow_dispatch: env: BUILD_TYPE: Debug diff --git a/samples/renderer.cpp b/samples/renderer.cpp index 5373313..2b1f7a0 100644 --- a/samples/renderer.cpp +++ b/samples/renderer.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/src/simd.h b/src/simd.h index ee9d1d4..ac7e9e8 100644 --- a/src/simd.h +++ b/src/simd.h @@ -59,22 +59,13 @@ static inline b3V32 b3NegV( b3V32 a ) return _mm_sub_ps( _mm_setzero_ps(), a ); } -// Unaligned loads are much faster on recent hardware with little to no penalty -// Note: This may read one extra float beyond a b3Vec3 for performance. Address sanitizer -// is disabled for this function as the extra read is intentional and safe. -#if defined( __linux__ ) || defined( __APPLE__ ) || defined( __clang__ ) -__attribute__( ( no_sanitize_address ) ) -#elif defined( _MSC_VER ) -__declspec( no_sanitize_address ) -#endif -static inline b3V32 -b3LoadV( const float* src ) +static inline b3V32 b3LoadV( const float* src ) { - const __m128i masK3 = _mm_setr_epi32( 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0 ); - - // Read an extra float which gets zeroed (to avoid NaN or Inf) - b3V32 a = _mm_loadu_ps( src ); - return _mm_and_ps( a, _mm_castsi128_ps( masK3 ) ); + // Loads exactly 12 bytes: 8 via movsd, 4 via movss. + // Result lane 3 is implicitly zero from the partial loads. + __m128 xy = _mm_castpd_ps( _mm_load_sd( (const double*)( src ) ) ); + __m128 z = _mm_load_ss( src + 2 ); + return _mm_movelh_ps( xy, z ); // { src[0], src[1], src[2], 0.0f } } static inline b3V32 b3ZeroV( void ) diff --git a/src/timer.c b/src/timer.c index 3f02bf1..07ad30e 100644 --- a/src/timer.c +++ b/src/timer.c @@ -15,6 +15,8 @@ #include #include +#define NAME_LENGTH 16 + #if defined( _WIN32 ) #ifndef WIN32_LEAN_AND_MEAN @@ -139,7 +141,7 @@ typedef struct b3Thread HANDLE thread; b3ThreadFunction* function; void* context; - char name[32]; + char name[NAME_LENGTH]; } b3Thread; typedef HRESULT( WINAPI* b3SetThreadDescriptionFn )( HANDLE, PCWSTR ); @@ -176,7 +178,7 @@ static void b3SetCurrentThreadName( const char* name ) return; } - wchar_t wide[32]; + wchar_t wide[NAME_LENGTH]; int n = MultiByteToWideChar( CP_UTF8, 0, name, -1, wide, (int)( sizeof( wide ) / sizeof( wide[0] ) ) ); if ( n > 0 ) { @@ -314,7 +316,7 @@ typedef struct b3Thread pthread_t thread; b3ThreadFunction* function; void* context; - char name[32]; + char name[NAME_LENGTH]; } b3Thread; static void b3SetCurrentThreadName( const char* name ) @@ -326,7 +328,7 @@ static void b3SetCurrentThreadName( const char* name ) #if defined( __linux__ ) // Linux caps thread names at 15 chars + null terminator. - char truncated[16]; + char truncated[NAME_LENGTH]; snprintf( truncated, sizeof( truncated ), "%s", name ); pthread_setname_np( pthread_self(), truncated ); #else @@ -490,7 +492,7 @@ typedef struct b3Thread pthread_t thread; b3ThreadFunction* function; void* context; - char name[32]; + char name[NAME_LENGTH]; } b3Thread; // macOS pthread_setname_np takes only the name — it always names the calling thread.