Skip to content

Commit 57fcefd

Browse files
committed
perf: fix code bugs with SSE2 compiler
with vectorization, more math optimizations, and alignment, the compiler is more sensitive to some forms of code bugs
1 parent f80e203 commit 57fcefd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/mathlib/mathlib_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ float SmoothCurve( float x )
14791479
inline float MovePeak( float x, float flPeakPos )
14801480
{
14811481
// Todo: make this higher-order?
1482-
if( x < flPeakPos )
1482+
if ( (x < flPeakPos || flPeakPos == 1) && flPeakPos != 0 )
14831483
return x * 0.5f / flPeakPos;
14841484
else
14851485
return 0.5 + 0.5 * (x - flPeakPos) / (1 - flPeakPos);

src/public/mathlib/mathlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ void BuildGammaTable( float gamma, float texGamma, float brightness, int overbri
954954
// convert texture to linear 0..1 value
955955
inline float TexLightToLinear( int c, int exponent )
956956
{
957-
extern float power2_n[256];
957+
extern ALIGN128 float power2_n[256];
958958
Assert( exponent >= -128 && exponent <= 127 );
959959
return ( float )c * power2_n[exponent+128];
960960
}

0 commit comments

Comments
 (0)