Skip to content

Commit ff2da09

Browse files
committed
fix some discrepancies in mathlib
1 parent aac15a4 commit ff2da09

6 files changed

Lines changed: 18 additions & 10 deletions

File tree

src/mathlib/3dnow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// memdbgon must be the last include file in a .cpp file!!!
1717
#include "tier0/memdbgon.h"
1818

19-
#if !defined(COMPILER_MSVC64) && !defined(LINUX)
19+
#if 0 && !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined( LINUX )
2020
// Implement for 64-bit Windows if needed.
2121
// Clang hits "fatal error: error in backend:" and other errors when trying
2222
// to compile the inline assembly below. 3DNow support is highly unlikely to
@@ -194,4 +194,4 @@ float _3DNow_InvRSquared(const float* v)
194194
return r2;
195195
}
196196

197-
#endif // COMPILER_MSVC64
197+
#endif // PLATFORM_WINDOWS_PC64

src/mathlib/mathlib_base.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3321,20 +3321,22 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
33213321
pfFastSinCos = SinCos;
33223322
pfFastCos = cosf;
33233323

3324+
#if 0
33243325
if ( bAllowMMX && pi.m_bMMX )
33253326
{
33263327
// Select the MMX specific routines if available
33273328
// (MMX routines were used by SW span fillers - not currently used for HW)
33283329
s_bMMXEnabled = true;
33293330
}
33303331
else
3332+
#endif
33313333
{
33323334
s_bMMXEnabled = false;
33333335
}
33343336

33353337
// SSE Generally performs better than 3DNow when present, so this is placed
33363338
// first to allow SSE to override these settings.
3337-
#if !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(LINUX)
3339+
#if 0 && !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined( LINUX )
33383340
if ( bAllow3DNow && pi.m_b3DNow )
33393341
{
33403342
s_b3DNowEnabled = true;
@@ -3357,6 +3359,7 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
33573359
{
33583360
s_bSSEEnabled = true;
33593361

3362+
#if 0
33603363
#ifndef PLATFORM_WINDOWS_PC64
33613364
// These are not yet available.
33623365
// Select the SSE specific routines if available
@@ -3370,6 +3373,7 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
33703373
#ifdef PLATFORM_WINDOWS_PC32
33713374
pfFastSinCos = _SSE_SinCos;
33723375
pfFastCos = _SSE_cos;
3376+
#endif
33733377
#endif
33743378
}
33753379
else
@@ -3380,9 +3384,11 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
33803384
if ( bAllowSSE2 && pi.m_bSSE2 )
33813385
{
33823386
s_bSSE2Enabled = true;
3387+
#if 0
33833388
#ifdef PLATFORM_WINDOWS_PC32
33843389
pfFastSinCos = _SSE2_SinCos;
33853390
pfFastCos = _SSE2_cos;
3391+
#endif
33863392
#endif
33873393
}
33883394
else

src/mathlib/sse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// memdbgon must be the last include file in a .cpp file!!!
1717
#include "tier0/memdbgon.h"
1818

19-
#ifndef COMPILER_MSVC64
19+
#if 0 && !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined( LINUX )
2020
// Implement for 64-bit Windows if needed.
2121

2222
static const uint32 _sincos_masks[] = { (uint32)0x0, (uint32)~0x0 };
@@ -1104,4 +1104,4 @@ vec_t DotProduct (const vec_t *a, const vec_t *c)
11041104
}
11051105
*/
11061106

1107-
#endif // COMPILER_MSVC64
1107+
#endif // PLATFORM_WINDOWS_PC64

src/mathlib/sse.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef _SSE_H
88
#define _SSE_H
99

10+
#if 0
1011
float _SSE_Sqrt(float x);
1112
float _SSE_RSqrtAccurate(float a);
1213
float _SSE_RSqrtFast(float x);
@@ -23,5 +24,6 @@ float _SSE2_cos(float x);
2324
void VectorTransformSSE(const float *in1, const matrix3x4_t& in2, float *out1);
2425
void VectorRotateSSE( const float *in1, const matrix3x4_t& in2, float *out1 );
2526
#endif
27+
#endif
2628

2729
#endif // _SSE_H

src/public/mathlib/ssemath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2509,7 +2509,7 @@ FORCEINLINE i32x4 IntShiftLeftWordSIMD(const i32x4 &vSrcA, const i32x4 &vSrcB)
25092509
// like this.
25102510
FORCEINLINE void ConvertStoreAsIntsSIMD(intx4 * RESTRICT pDest, const fltx4 &vSrc)
25112511
{
2512-
#if defined( COMPILER_MSVC64 )
2512+
#if 1 || defined( COMPILER_MSVC64 )
25132513

25142514
(*pDest)[0] = SubFloat( vSrc, 0 );
25152515
(*pDest)[1] = SubFloat( vSrc, 1 );

src/public/mathlib/vector.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,20 +2207,20 @@ inline void AngularImpulseToQAngle( const AngularImpulse &impulse, QAngle &angle
22072207
FORCEINLINE vec_t InvRSquared( float const *v )
22082208
{
22092209
// The compiler will make it good
2210-
return 1.f / ( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] + 1.0e-10f );
2210+
return 1.f / ( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] + FLT_EPSILON );
22112211
}
22122212

22132213
FORCEINLINE vec_t InvRSquared( const Vector &v )
22142214
{
22152215
// The compiler will make it good
2216-
return 1.0f / ( v.x * v.x + v.y * v.y + v.z * v.z + 1.0e-10f );
2216+
return 1.0f / ( v.x * v.x + v.y * v.y + v.z * v.z + FLT_EPSILON );
22172217
}
22182218

22192219
// FIXME: Change this back to a #define once we get rid of the vec_t version
22202220
FORCEINLINE float VectorNormalize( Vector& vec )
22212221
{
22222222
// The compiler will make it good
2223-
const float len = sqrtf(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + 1.0e-10f);
2223+
const float len = sqrtf(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + FLT_EPSILON );
22242224
const float invlen = 1.0f / len;
22252225
vec.x *= invlen;
22262226
vec.y *= invlen;
@@ -2237,7 +2237,7 @@ FORCEINLINE float VectorNormalize( float * v )
22372237
FORCEINLINE void VectorNormalizeFast( Vector &vec )
22382238
{
22392239
// The previous version just called VectorNormalize but it's significant to be able to do a rsqrtss here.
2240-
const float invlen = 1.0f / sqrtf( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + 1.0e-10f );
2240+
const float invlen = 1.0f / sqrtf( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + FLT_EPSILON );
22412241
vec.x *= invlen;
22422242
vec.y *= invlen;
22432243
vec.z *= invlen;

0 commit comments

Comments
 (0)