mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2024-12-23 01:59:43 +08:00
Removed 3DNow support from mathlib.
This commit is contained in:
parent
94844b1d99
commit
e0fe50f9f5
@ -30,7 +30,6 @@ DO_CC += -o $@ -c $<
|
||||
#####################################################################
|
||||
|
||||
LIB_OBJS= \
|
||||
$(LIB_OBJ_DIR)/3dnow.o \
|
||||
$(LIB_OBJ_DIR)/anorms.o \
|
||||
$(LIB_OBJ_DIR)/bumpvects.o \
|
||||
$(LIB_OBJ_DIR)/color_conversion.o \
|
||||
|
@ -1,193 +0,0 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: 3DNow Math primitives.
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h> // Needed for FLT_EPSILON
|
||||
#include "basetypes.h"
|
||||
#include <memory.h>
|
||||
#include "tier0/dbg.h"
|
||||
#include "mathlib/mathlib.h"
|
||||
#include "mathlib/amd3dx.h"
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4244) // "conversion from 'const int' to 'float', possible loss of data"
|
||||
#pragma warning(disable:4730) // "mixing _m64 and floating point expressions may result in incorrect code"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 3D Now Implementations of optimized routines:
|
||||
//-----------------------------------------------------------------------------
|
||||
float _3DNow_Sqrt(float x)
|
||||
{
|
||||
Assert( s_bMathlibInitialized );
|
||||
float root = 0.f;
|
||||
#ifdef _WIN32
|
||||
_asm
|
||||
{
|
||||
femms
|
||||
movd mm0, x
|
||||
PFRSQRT (mm1,mm0)
|
||||
punpckldq mm0, mm0
|
||||
PFMUL (mm0, mm1)
|
||||
movd root, mm0
|
||||
femms
|
||||
}
|
||||
#elif defined _LINUX || defined __APPLE__
|
||||
__asm __volatile__( "femms" );
|
||||
__asm __volatile__
|
||||
(
|
||||
"pfrsqrt %y0, %y1 \n\t"
|
||||
"punpckldq %y1, %y1 \n\t"
|
||||
"pfmul %y1, %y0 \n\t"
|
||||
: "=y" (root), "=y" (x)
|
||||
:"0" (x)
|
||||
);
|
||||
__asm __volatile__( "femms" );
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
// NJS FIXME: Need to test Recripricol squareroot performance and accuraccy
|
||||
// on AMD's before using the specialized instruction.
|
||||
float _3DNow_RSqrt(float x)
|
||||
{
|
||||
Assert( s_bMathlibInitialized );
|
||||
|
||||
return 1.f / _3DNow_Sqrt(x);
|
||||
}
|
||||
|
||||
|
||||
float FASTCALL _3DNow_VectorNormalize (Vector& vec)
|
||||
{
|
||||
Assert( s_bMathlibInitialized );
|
||||
float *v = &vec[0];
|
||||
float radius = 0.f;
|
||||
|
||||
if ( v[0] || v[1] || v[2] )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_asm
|
||||
{
|
||||
mov eax, v
|
||||
femms
|
||||
movq mm0, QWORD PTR [eax]
|
||||
movd mm1, DWORD PTR [eax+8]
|
||||
movq mm2, mm0
|
||||
movq mm3, mm1
|
||||
PFMUL (mm0, mm0)
|
||||
PFMUL (mm1, mm1)
|
||||
PFACC (mm0, mm0)
|
||||
PFADD (mm1, mm0)
|
||||
PFRSQRT (mm0, mm1)
|
||||
punpckldq mm1, mm1
|
||||
PFMUL (mm1, mm0)
|
||||
PFMUL (mm2, mm0)
|
||||
PFMUL (mm3, mm0)
|
||||
movq QWORD PTR [eax], mm2
|
||||
movd DWORD PTR [eax+8], mm3
|
||||
movd radius, mm1
|
||||
femms
|
||||
}
|
||||
#elif defined _LINUX || defined __APPLE__
|
||||
long long a,c;
|
||||
int b,d;
|
||||
memcpy(&a,&vec[0],sizeof(a));
|
||||
memcpy(&b,&vec[2],sizeof(b));
|
||||
memcpy(&c,&vec[0],sizeof(c));
|
||||
memcpy(&d,&vec[2],sizeof(d));
|
||||
|
||||
__asm __volatile__( "femms" );
|
||||
__asm __volatile__
|
||||
(
|
||||
"pfmul %y3, %y3\n\t"
|
||||
"pfmul %y0, %y0 \n\t"
|
||||
"pfacc %y3, %y3 \n\t"
|
||||
"pfadd %y3, %y0 \n\t"
|
||||
"pfrsqrt %y0, %y3 \n\t"
|
||||
"punpckldq %y0, %y0 \n\t"
|
||||
"pfmul %y3, %y0 \n\t"
|
||||
"pfmul %y3, %y2 \n\t"
|
||||
"pfmul %y3, %y1 \n\t"
|
||||
: "=y" (radius), "=y" (c), "=y" (d)
|
||||
: "y" (a), "0" (b), "1" (c), "2" (d)
|
||||
);
|
||||
memcpy(&vec[0],&c,sizeof(c));
|
||||
memcpy(&vec[2],&d,sizeof(d));
|
||||
__asm __volatile__( "femms" );
|
||||
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
||||
void FASTCALL _3DNow_VectorNormalizeFast (Vector& vec)
|
||||
{
|
||||
_3DNow_VectorNormalize( vec );
|
||||
}
|
||||
|
||||
|
||||
// JAY: This complains with the latest processor pack
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4730)
|
||||
#endif
|
||||
|
||||
float _3DNow_InvRSquared(const float* v)
|
||||
{
|
||||
Assert( s_bMathlibInitialized );
|
||||
float r2 = 1.f;
|
||||
#ifdef _WIN32
|
||||
_asm { // AMD 3DNow only routine
|
||||
mov eax, v
|
||||
femms
|
||||
movq mm0, QWORD PTR [eax]
|
||||
movd mm1, DWORD PTR [eax+8]
|
||||
movd mm2, [r2]
|
||||
PFMUL (mm0, mm0)
|
||||
PFMUL (mm1, mm1)
|
||||
PFACC (mm0, mm0)
|
||||
PFADD (mm1, mm0)
|
||||
PFMAX (mm1, mm2)
|
||||
PFRCP (mm0, mm1)
|
||||
movd [r2], mm0
|
||||
femms
|
||||
}
|
||||
#elif defined _LINUX || defined __APPLE__
|
||||
long long a,c;
|
||||
int b;
|
||||
memcpy(&a,&v[0],sizeof(a));
|
||||
memcpy(&b,&v[2],sizeof(b));
|
||||
memcpy(&c,&v[0],sizeof(c));
|
||||
|
||||
__asm __volatile__( "femms" );
|
||||
__asm __volatile__
|
||||
(
|
||||
"PFMUL %y2, %y2 \n\t"
|
||||
"PFMUL %y3, %y3 \n\t"
|
||||
"PFACC %y2, %y2 \n\t"
|
||||
"PFADD %y2, %y3 \n\t"
|
||||
"PFMAX %y3, %y4 \n\t"
|
||||
"PFRCP %y3, %y2 \n\t"
|
||||
"movq %y2, %y0 \n\t"
|
||||
: "=y" (r2)
|
||||
: "0" (r2), "y" (a), "y" (b), "y" (c)
|
||||
);
|
||||
__asm __volatile__( "femms" );
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
||||
return r2;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#ifndef _3DNOW_H
|
||||
#define _3DNOW_H
|
||||
|
||||
float _3DNow_Sqrt(float x);
|
||||
float _3DNow_RSqrt(float x);
|
||||
float FASTCALL _3DNow_VectorNormalize (Vector& vec);
|
||||
void FASTCALL _3DNow_VectorNormalizeFast (Vector& vec);
|
||||
float _3DNow_InvRSquared(const float* v);
|
||||
|
||||
#endif // _3DNOW_H
|
@ -210,10 +210,6 @@
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\3dnow.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\anorms.cpp"
|
||||
>
|
||||
@ -388,10 +384,6 @@
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\3dnow.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\noisedata.h"
|
||||
>
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include "mathlib/mathlib.h"
|
||||
#include "mathlib/vector.h"
|
||||
#if !defined( _X360 )
|
||||
#include "mathlib/amd3dx.h"
|
||||
#include "3dnow.h"
|
||||
#include "sse.h"
|
||||
#endif
|
||||
|
||||
@ -3198,7 +3196,6 @@ bool CalcLineToLineIntersectionSegment(
|
||||
#pragma optimize( "", on )
|
||||
#endif
|
||||
|
||||
static bool s_b3DNowEnabled = false;
|
||||
static bool s_bMMXEnabled = false;
|
||||
static bool s_bSSEEnabled = false;
|
||||
static bool s_bSSE2Enabled = false;
|
||||
@ -3235,25 +3232,6 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
|
||||
s_bMMXEnabled = false;
|
||||
}
|
||||
|
||||
// SSE Generally performs better than 3DNow when present, so this is placed
|
||||
// first to allow SSE to override these settings.
|
||||
if ( bAllow3DNow && pi.m_b3DNow )
|
||||
{
|
||||
s_b3DNowEnabled = true;
|
||||
|
||||
// Select the 3DNow specific routines if available;
|
||||
pfVectorNormalize = _3DNow_VectorNormalize;
|
||||
pfVectorNormalizeFast = _3DNow_VectorNormalizeFast;
|
||||
pfInvRSquared = _3DNow_InvRSquared;
|
||||
pfSqrt = _3DNow_Sqrt;
|
||||
pfRSqrt = _3DNow_RSqrt;
|
||||
pfRSqrtFast = _3DNow_RSqrt;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_b3DNowEnabled = false;
|
||||
}
|
||||
|
||||
if ( bAllowSSE && pi.m_bSSE )
|
||||
{
|
||||
s_bSSEEnabled = true;
|
||||
@ -3295,12 +3273,6 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
|
||||
BuildGammaTable( gamma, texGamma, brightness, overbright );
|
||||
}
|
||||
|
||||
bool MathLib_3DNowEnabled( void )
|
||||
{
|
||||
Assert( s_bMathlibInitialized );
|
||||
return s_b3DNowEnabled;
|
||||
}
|
||||
|
||||
bool MathLib_MMXEnabled( void )
|
||||
{
|
||||
Assert( s_bMathlibInitialized );
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1708,7 +1708,6 @@ float CalcDistanceSqrToLineSegment2D( Vector2D const &P, Vector2D const &vLineA,
|
||||
|
||||
// Init the mathlib
|
||||
void MathLib_Init( float gamma = 2.2f, float texGamma = 2.2f, float brightness = 0.0f, int overbright = 2.0f, bool bAllow3DNow = true, bool bAllowSSE = true, bool bAllowSSE2 = true, bool bAllowMMX = true );
|
||||
bool MathLib_3DNowEnabled( void );
|
||||
bool MathLib_MMXEnabled( void );
|
||||
bool MathLib_SSEEnabled( void );
|
||||
bool MathLib_SSE2Enabled( void );
|
||||
|
Loading…
Reference in New Issue
Block a user