misaligment fixes

This commit is contained in:
nillerusr
2022-05-15 21:09:59 +03:00
parent 1218fa659c
commit 3a73624b7e
39 changed files with 7592 additions and 6056 deletions
+10 -4
View File
@@ -21,6 +21,8 @@
#include "convar.h"
#include "tier0/tslist.h"
#include "vphysics_interface.h"
#include "mathlib/compressed_vector.h"
#ifdef CLIENT_DLL
#include "posedebugger.h"
#endif
@@ -378,14 +380,18 @@ void CalcBoneQuaternion( int frame, float s,
{
if ( panim->flags & STUDIO_ANIM_RAWROT )
{
q = *(panim->pQuat48());
Quaternion48 tmp;
memcpy( &tmp, panim->pQuat48(), sizeof(Quaternion48) );
q = tmp;
Assert( q.IsValid() );
return;
}
}
if ( panim->flags & STUDIO_ANIM_RAWROT2 )
{
q = *(panim->pQuat64());
Quaternion64 tmp;
memcpy( &tmp, panim->pQuat64(), sizeof(Quaternion64) );
q = tmp;
Assert( q.IsValid() );
return;
}
+1 -1
View File
@@ -265,7 +265,7 @@ void SendProxy_UInt16ToInt32( const SendProp *pProp, const void *pStruct, const
void SendProxy_UInt32ToInt32( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID)
{
*((unsigned long*)&pOut->m_Int) = *((unsigned long*)pData);
memcpy( &pOut->m_Int, pData, sizeof(unsigned long) );
}
#ifdef SUPPORTS_INT64
void SendProxy_UInt64ToInt64( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID)
+2 -2
View File
@@ -149,7 +149,7 @@ class Quaternion64
{
public:
// Construction/destruction:
Quaternion64(void);
Quaternion64(void) {};
Quaternion64(vec_t X, vec_t Y, vec_t Z);
// assignment
@@ -197,7 +197,7 @@ class Quaternion48
{
public:
// Construction/destruction:
Quaternion48(void);
Quaternion48(void) {};
Quaternion48(vec_t X, vec_t Y, vec_t Z);
// assignment
+2 -1
View File
@@ -34,7 +34,7 @@ enum LightType_OptimizationFlags_t
struct LightDesc_t
{
LightType_t m_Type; //< MATERIAL_LIGHT_xxx
Vector m_Color; //< color+intensity
Vector m_Color; //< color+intensity
Vector m_Position; //< light source center position
Vector m_Direction; //< for SPOT, direction it is pointing
float m_Range; //< distance range for light.0=infinite
@@ -60,6 +60,7 @@ public:
LightDesc_t(void)
{
m_Type = MATERIAL_LIGHT_DISABLE;
}
// constructors for various useful subtypes
+7 -9
View File
@@ -23,6 +23,10 @@
#include "tier0/dbg.h"
#include "mathlib/math_pfns.h"
#ifdef __arm__
#include "sse2neon.h"
#endif
// forward declarations
class Vector;
class Vector2D;
@@ -141,10 +145,8 @@ 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
@@ -616,9 +618,7 @@ inline void Vector4DAligned::Set( vec_t X, vec_t Y, vec_t Z, vec_t W )
inline void Vector4DAligned::InitZero( void )
{
#if defined (__arm__)
x = y = z = w = 0;
#elif !defined( _X360 )
#if !defined( _X360 )
this->AsM128() = _mm_set1_ps( 0.0f );
#else
this->AsM128() = __vspltisw( 0 );
@@ -629,7 +629,7 @@ inline void Vector4DAligned::InitZero( void )
inline void Vector4DMultiplyAligned( Vector4DAligned const& a, Vector4DAligned const& b, Vector4DAligned& c )
{
Assert( a.IsValid() && b.IsValid() );
#if !defined( _X360 ) || defined (__arm__)
#if !defined( _X360 )
c.x = a.x * b.x;
c.y = a.y * b.y;
c.z = a.z * b.z;
@@ -643,7 +643,7 @@ inline void Vector4DWeightMAD( vec_t w, Vector4DAligned const& vInA, Vector4DAli
{
Assert( vInA.IsValid() && vInB.IsValid() && IsFinite(w) );
#if !defined( _X360 ) || defined (__arm__)
#if !defined( _X360 )
vOutA.x += vInA.x * w;
vOutA.y += vInA.y * w;
vOutA.z += vInA.z * w;
@@ -664,7 +664,6 @@ inline void Vector4DWeightMAD( vec_t w, Vector4DAligned const& vInA, Vector4DAli
#endif
}
#ifndef __arm__
inline void Vector4DWeightMADSSE( vec_t w, Vector4DAligned const& vInA, Vector4DAligned& vOutA, Vector4DAligned const& vInB, Vector4DAligned& vOutB )
{
Assert( vInA.IsValid() && vInB.IsValid() && IsFinite(w) );
@@ -686,7 +685,6 @@ inline void Vector4DWeightMADSSE( vec_t w, Vector4DAligned const& vInA, Vector4D
vOutB.AsM128() = __vmaddfp( vInB.AsM128(), temp, vOutB.AsM128() );
#endif
}
#endif
#endif // VECTOR4D_H
+6
View File
@@ -423,6 +423,12 @@ void MatrixInverseTranspose( const VMatrix& src, VMatrix& dst );
//-----------------------------------------------------------------------------
inline VMatrix::VMatrix()
{
Init(
0.f, 0.f, 0.f, 0.f,
0.f, 0.f, 0.f, 0.f,
0.f, 0.f, 0.f, 0.f,
0.f, 0.f, 0.f, 0.f
);
}
inline VMatrix::VMatrix(
+3 -1
View File
@@ -639,6 +639,7 @@ struct mstudioanim_t
byte bone;
byte flags; // weighing options
// valid for animating data only
inline byte *pData( void ) const { return (((byte *)this) + sizeof( struct mstudioanim_t )); };
inline mstudioanim_valueptr_t *pRotV( void ) const { return (mstudioanim_valueptr_t *)(pData()); };
@@ -650,8 +651,9 @@ struct mstudioanim_t
inline Vector48 *pPos( void ) const { return (Vector48 *)(pData() + ((flags & STUDIO_ANIM_RAWROT) != 0) * sizeof( *pQuat48() ) + ((flags & STUDIO_ANIM_RAWROT2) != 0) * sizeof( *pQuat64() ) ); };
short nextoffset;
inline mstudioanim_t *pNext( void ) const { if (nextoffset != 0) return (mstudioanim_t *)(((byte *)this) + nextoffset); else return NULL; };
};
} ALIGN16;
struct mstudiomovement_t
{
+2 -2
View File
@@ -1195,7 +1195,7 @@ typedef enum _D3DVERTEXBLENDFLAGS
D3DVBF_3WEIGHTS = 3, // 4 matrix blending
D3DVBF_TWEENING = 255, // blending using D3DRS_TWEENFACTOR
D3DVBF_0WEIGHTS = 256, // one matrix is used with weight 1.0
D3DVBF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
D3DVBF_FORCE_DWORD = 0xffffffff, // force 32-bit size enum
} D3DVERTEXBLENDFLAGS;
typedef struct _D3DINDEXBUFFER_DESC
@@ -1533,7 +1533,7 @@ typedef enum _D3DTRANSFORMSTATETYPE
D3DTS_VIEW = 2,
D3DTS_PROJECTION = 3,
D3DTS_TEXTURE0 = 16,
D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
D3DTS_FORCE_DWORD = 0xffffffff, /* force 32-bit size enum */
} D3DTRANSFORMSTATETYPE;
// **** FIXED FUNCTION STUFF - None of this stuff needs support in GL.
+54 -42
View File
@@ -38,18 +38,8 @@
#include "interface.h"
#include "togles/rendermechanism.h"
#ifdef LINUX
#include <sys/time.h>
#endif
void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, void *fallback=NULL);
/*
#define GL_USE_EXECUTE_HELPER_FOR_ALL_API_CALLS 1
#define GL_TRACK_API_TIME 1
#define GL_DUMP_ALL_API_CALLS 1
*/
#if GL_USE_EXECUTE_HELPER_FOR_ALL_API_CALLS
class CGLExecuteHelperBase
{
@@ -57,7 +47,7 @@ public:
inline void StartCall(const char *pName);
inline void StopCall(const char *pName);
#if GL_TRACK_API_TIME
uint64 m_nStartTime;
TmU64 m_nStartTime;
#endif
};
@@ -313,32 +303,30 @@ public:
int m_nOpenGLVersionMinor; // if GL_VERSION is 2.1.0, this will be set to 1.
int m_nOpenGLVersionPatch; // if GL_VERSION is 2.1.0, this will be set to 0.
bool m_bHave_OpenGL;
char *m_pGLDriverStrings[cGLTotalDriverStrings];
GLDriverProvider_t m_nDriverProvider;
GLDriverProvider_t m_nDriverProvider;
#ifdef LOAD_HARDFP
#define _APIENTRY __attribute__((pcs("aapcs"))) APIENTRY
#else
#define _APIENTRY APIENTRY
#endif
#ifdef OSX
#define GL_EXT(x,glmajor,glminor) bool m_bHave_##x;
#define GL_FUNC(ext,req,ret,fn,arg,call) CDynamicFunctionOpenGL< req, ret (*) arg, ret > fn;
#define GL_FUNC_VOID(ext,req,fn,arg,call) CDynamicFunctionOpenGL< req, void (*) arg, void > fn;
#else
#ifdef LOAD_HARDFP
#define _APIENTRY __attribute__((pcs("aapcs"))) APIENTRY
#define GL_EXT(x,glmajor,glminor) bool m_bHave_##x;
#define GL_FUNC(ext,req,ret,fn,arg,call) CDynamicFunctionOpenGL< req, ret (_APIENTRY *) arg, ret > fn;
#define GL_FUNC_VOID(ext,req,fn,arg,call) CDynamicFunctionOpenGL< req, void (_APIENTRY *) arg, void > fn;
#else
#define GL_EXT(x,glmajor,glminor) bool m_bHave_##x;
#define GL_FUNC(ext,req,ret,fn,arg,call) CDynamicFunctionOpenGL< req, ret (APIENTRY *) arg, ret > fn;
#define GL_FUNC_VOID(ext,req,fn,arg,call) CDynamicFunctionOpenGL< req, void (APIENTRY *) arg, void > fn;
#endif
#endif
#include "togles/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT
#include "togles/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT
bool HasSwapTearExtension() const
{
@@ -366,30 +354,54 @@ typedef void * (*GL_GetProcAddressCallbackFunc_t)(const char *, bool &, const bo
DLL_IMPORT void ClearOpenGLEntryPoints();
#endif
inline uint64 get_nsecs()
{
struct timespec time={0,0};
clock_gettime(CLOCK_MONOTONIC, &time);
return time.tv_nsec;
}
#if GL_USE_EXECUTE_HELPER_FOR_ALL_API_CALLS
inline void CGLExecuteHelperBase::StartCall(const char *pName)
{
(void)pName;
m_nStartTime = get_nsecs();
#if GL_TELEMETRY_ZONES
tmEnter( TELEMETRY_LEVEL3, TMZF_NONE, pName );
#endif
#if GL_TRACK_API_TIME
m_nStartTime = tmFastTime();
#endif
#if GL_DUMP_ALL_API_CALLS
static bool s_bDumpCalls;
if ( s_bDumpCalls )
{
char buf[128];
buf[0] = 'G';
buf[1] = 'L';
buf[2] = ':';
size_t l = strlen( pName );
memcpy( buf + 3, pName, l );
buf[3 + l] = '\n';
buf[4 + l] = '\0';
Plat_DebugString( buf );
}
#endif
}
inline void CGLExecuteHelperBase::StopCall(const char *pName)
{
if( gGL )
{
uint64 time = get_nsecs() - m_nStartTime;
printf("Function %s finished in %llu\n", pName, time);
if( strcmp(pName, "glBufferSubData") == 0 && time > 1000000 )
DebuggerBreak();
}
{
#if GL_TRACK_API_TIME
uint64 nTotalCycles = tmFastTime() - m_nStartTime;
#endif
#if GL_TELEMETRY_ZONES
tmLeave( TELEMETRY_LEVEL3 );
#endif
#if GL_TRACK_API_TIME
//double flMilliseconds = g_Telemetry.flRDTSCToMilliSeconds * nTotalCycles;
if (gGL)
{
gGL->m_nTotalGLCycles += nTotalCycles;
gGL->m_nTotalGLCalls++;
}
#endif
}
#endif