Skip to content

Commit 657f59a

Browse files
committed
materialsystem: set allocator alignment 16( fixes crash in release build )
1 parent e3edbc2 commit 657f59a

File tree

2 files changed

+7
-41
lines changed

2 files changed

+7
-41
lines changed

materialsystem/imaterialsysteminternal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class CMatCallQueue
3131
{
3232
MEM_ALLOC_CREDIT_( "CMatCallQueue.m_Allocator" );
3333
#ifdef SWDS
34-
m_Allocator.Init( 2*1024, 0, 0, 4 );
34+
m_Allocator.Init( 2*1024, 0, 0, 16 );
3535
#else
36-
m_Allocator.Init( IsX360() ? 2*1024*1024 : 8*1024*1024, 64*1024, 256*1024, 4 );
36+
m_Allocator.Init( IsX360() ? 2*1024*1024 : 8*1024*1024, 64*1024, 256*1024, 16 );
3737
#endif
3838
m_FunctorFactory.SetAllocator( &m_Allocator );
3939
m_pHead = m_pTail = NULL;

public/mathlib/mathlib.h

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
// FP exception clean so this not a turnkey operation.
3131
//#define FP_EXCEPTIONS_ENABLED
3232

33-
3433
#ifdef FP_EXCEPTIONS_ENABLED
3534
#include <float.h> // For _clearfp and _controlfp_s
3635
#endif
@@ -93,55 +92,22 @@ class FPExceptionEnabler
9392
FPExceptionEnabler& operator=(const FPExceptionEnabler&);
9493
};
9594

96-
97-
98-
#ifdef DEBUG // stop crashing edit-and-continue
99-
FORCEINLINE float clamp( float val, float minVal, float maxVal )
95+
inline float clamp( const float val, const float minVal, const float maxVal )
10096
{
101-
if ( maxVal < minVal )
102-
return maxVal;
103-
else if( val < minVal )
104-
return minVal;
105-
else if( val > maxVal )
106-
return maxVal;
107-
else
108-
return val;
97+
const float t = val < minVal ? minVal : val;
98+
return t > maxVal ? maxVal : t;
10999
}
110-
#else // DEBUG
111-
FORCEINLINE float clamp( float val, float minVal, float maxVal )
112-
{
113-
#if defined(__i386__) || defined(_M_IX86)
114-
_mm_store_ss( &val,
115-
_mm_min_ss(
116-
_mm_max_ss(
117-
_mm_load_ss(&val),
118-
_mm_load_ss(&minVal) ),
119-
_mm_load_ss(&maxVal) ) );
120-
#else
121-
val = fpmax(minVal, val);
122-
val = fpmin(maxVal, val);
123-
#endif
124-
return val;
125-
}
126-
#endif // DEBUG
127100

128101
//
129102
// Returns a clamped value in the range [min, max].
130103
//
131104
template< class T >
132105
inline T clamp( T const &val, T const &minVal, T const &maxVal )
133106
{
134-
if ( maxVal < minVal )
135-
return maxVal;
136-
else if( val < minVal )
137-
return minVal;
138-
else if( val > maxVal )
139-
return maxVal;
140-
else
141-
return val;
107+
const T t = val< minVal ? minVal : val;
108+
return t > maxVal ? maxVal : t;
142109
}
143110

144-
145111
// plane_t structure
146112
// !!! if this is changed, it must be changed in asm code too !!!
147113
// FIXME: does the asm code even exist anymore?

0 commit comments

Comments
 (0)