mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-11 11:19:09 +00:00
First steps
This commit is contained in:
@@ -454,7 +454,7 @@ void inline SinCos( float radians, float *sine, float *cosine )
|
||||
fstp DWORD PTR [edx]
|
||||
fstp DWORD PTR [eax]
|
||||
}
|
||||
#elif defined( PLATFORM_WINDOWS_PC64 )
|
||||
#elif defined( PLATFORM_WINDOWS_PC64 ) || defined(__arm__)
|
||||
*sine = sin( radians );
|
||||
*cosine = cos( radians );
|
||||
#elif defined( POSIX )
|
||||
@@ -1217,6 +1217,8 @@ FORCEINLINE int RoundFloatToInt(float f)
|
||||
};
|
||||
flResult = __fctiw( f );
|
||||
return pResult[1];
|
||||
#elif defined(__arm__)
|
||||
return (int)(f + 0.5f);
|
||||
#else
|
||||
#error Unknown architecture
|
||||
#endif
|
||||
@@ -1246,8 +1248,10 @@ FORCEINLINE unsigned long RoundFloatToUnsignedLong(float f)
|
||||
flResult = __fctiw( f );
|
||||
Assert( pIntResult[1] >= 0 );
|
||||
return pResult[1];
|
||||
#elif defined(__arm__)
|
||||
return (unsigned long)(f + 0.5f);
|
||||
#else // !X360
|
||||
|
||||
|
||||
#if defined( PLATFORM_WINDOWS_PC64 )
|
||||
uint nRet = ( uint ) f;
|
||||
if ( nRet & 1 )
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#if defined( _X360 )
|
||||
#include <xboxmath.h>
|
||||
#elif defined(__arm__)
|
||||
#include <SSE2NEON.h>
|
||||
#else
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
@@ -15,7 +17,7 @@
|
||||
#include <mathlib/vector.h>
|
||||
#include <mathlib/mathlib.h>
|
||||
|
||||
#if defined(GNUC)
|
||||
#if defined(GNUC) && defined(__arm__) // HACK: implement NEON later
|
||||
#define USE_STDC_FOR_SIMD 0
|
||||
#else
|
||||
#define USE_STDC_FOR_SIMD 0
|
||||
@@ -879,10 +881,13 @@ FORCEINLINE fltx4 FindHighestSIMD3( const fltx4 & a )
|
||||
// like this.
|
||||
FORCEINLINE void ConvertStoreAsIntsSIMD(intx4 * RESTRICT pDest, const fltx4 &vSrc)
|
||||
{
|
||||
(*pDest)[0] = SubFloat(vSrc, 0);
|
||||
(*pDest)[1] = SubFloat(vSrc, 1);
|
||||
(*pDest)[2] = SubFloat(vSrc, 2);
|
||||
(*pDest)[3] = SubFloat(vSrc, 3);
|
||||
__m64 bottom = _mm_cvttps_pi32( vSrc );
|
||||
__m64 top = _mm_cvttps_pi32( _mm_movehl_ps(vSrc,vSrc) );
|
||||
|
||||
*reinterpret_cast<__m64 *>(&(*pDest)[0]) = bottom;
|
||||
*reinterpret_cast<__m64 *>(&(*pDest)[2]) = top;
|
||||
|
||||
_mm_empty();
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
@@ -2407,13 +2412,16 @@ FORCEINLINE i32x4 IntShiftLeftWordSIMD(const i32x4 &vSrcA, const i32x4 &vSrcB)
|
||||
// like this.
|
||||
FORCEINLINE void ConvertStoreAsIntsSIMD(intx4 * RESTRICT pDest, const fltx4 &vSrc)
|
||||
{
|
||||
#if defined( COMPILER_MSVC64 )
|
||||
|
||||
#ifdef __arm__
|
||||
(*pDest)[0] = (int)vSrc[0];
|
||||
(*pDest)[1] = (int)vSrc[1];
|
||||
(*pDest)[2] = (int)vSrc[2];
|
||||
(*pDest)[3] = (int)vSrc[3];
|
||||
#elif defined( COMPILER_MSVC64 )
|
||||
(*pDest)[0] = SubFloat( vSrc, 0 );
|
||||
(*pDest)[1] = SubFloat( vSrc, 1 );
|
||||
(*pDest)[2] = SubFloat( vSrc, 2 );
|
||||
(*pDest)[3] = SubFloat( vSrc, 3 );
|
||||
|
||||
#else
|
||||
__m64 bottom = _mm_cvttps_pi32( vSrc );
|
||||
__m64 top = _mm_cvttps_pi32( _mm_movehl_ps(vSrc,vSrc) );
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
// For rand(). We really need a library!
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef _X360
|
||||
#if !defined(_X360) && !defined(__arm__)
|
||||
// For MMX intrinsics
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
@@ -210,7 +210,7 @@ private:
|
||||
FORCEINLINE void NetworkVarConstruct( Vector &v ) { v.Zero(); }
|
||||
|
||||
|
||||
#define USE_M64S ( ( !defined( _X360 ) ) )
|
||||
#define USE_M64S ( ( !defined( _X360 ) && !defined(__arm__) ) )
|
||||
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
void Init(short ix = 0, short iy = 0, short iz = 0, short iw = 0 );
|
||||
|
||||
|
||||
#ifdef USE_M64S
|
||||
#if USE_M64S
|
||||
__m64 &AsM64() { return *(__m64*)&x; }
|
||||
const __m64 &AsM64() const { return *(const __m64*)&x; }
|
||||
#endif
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
// Initialization
|
||||
void Init(int ix = 0, int iy = 0, int iz = 0, int iw = 0 );
|
||||
|
||||
#ifdef USE_M64S
|
||||
#if USE_M64S
|
||||
__m64 &AsM64() { return *(__m64*)&x; }
|
||||
const __m64 &AsM64() const { return *(const __m64*)&x; }
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <math.h>
|
||||
#include <stdlib.h> // For rand(). We really need a library!
|
||||
#include <float.h>
|
||||
#if !defined( _X360 )
|
||||
#if !defined( _X360 ) && !defined(__arm__)
|
||||
#include <xmmintrin.h> // For SSE
|
||||
#endif
|
||||
#include "basetypes.h" // For vec_t, put this somewhere else?
|
||||
@@ -141,8 +141,10 @@ public:
|
||||
inline void Set( vec_t X, vec_t Y, vec_t Z, vec_t W );
|
||||
inline void InitZero( void );
|
||||
|
||||
#ifndef __arm__
|
||||
inline __m128 &AsM128() { return *(__m128*)&x; }
|
||||
inline const __m128 &AsM128() const { return *(const __m128*)&x; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// No copy constructors allowed if we're in optimal mode
|
||||
@@ -614,7 +616,9 @@ inline void Vector4DAligned::Set( vec_t X, vec_t Y, vec_t Z, vec_t W )
|
||||
|
||||
inline void Vector4DAligned::InitZero( void )
|
||||
{
|
||||
#if !defined( _X360 )
|
||||
#if defined(__arm__)
|
||||
x = y = z = w = 0.0f;
|
||||
#elif !defined( _X360 )
|
||||
this->AsM128() = _mm_set1_ps( 0.0f );
|
||||
#else
|
||||
this->AsM128() = __vspltisw( 0 );
|
||||
@@ -663,8 +667,10 @@ inline void Vector4DWeightMAD( vec_t w, Vector4DAligned const& vInA, Vector4DAli
|
||||
inline void Vector4DWeightMADSSE( vec_t w, Vector4DAligned const& vInA, Vector4DAligned& vOutA, Vector4DAligned const& vInB, Vector4DAligned& vOutB )
|
||||
{
|
||||
Assert( vInA.IsValid() && vInB.IsValid() && IsFinite(w) );
|
||||
|
||||
#if !defined( _X360 )
|
||||
|
||||
#if defined(__arm__)
|
||||
Vector4DWeightMAD( w, vInA, vOutA, vInB, vOutB );
|
||||
#elif !defined( _X360 )
|
||||
// Replicate scalar float out to 4 components
|
||||
__m128 packed = _mm_set1_ps( w );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user