mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-07 17:29:36 +00:00
arm64 : fix intptr_t size
This commit is contained in:
+9
-9
@@ -119,21 +119,21 @@
|
||||
#define _T( arg ) arg
|
||||
#endif
|
||||
#define INVALID_HANDLE_VALUE (void*)-1
|
||||
#define CloseHandle( arg ) close( (int) arg )
|
||||
#define CloseHandle( arg ) close( (intptr_t) arg )
|
||||
#define ZeroMemory( ptr, size ) memset( ptr, 0, size )
|
||||
#define FILE_CURRENT SEEK_CUR
|
||||
#define FILE_BEGIN SEEK_SET
|
||||
#define FILE_END SEEK_END
|
||||
#define CreateDirectory( dir, ign ) mkdir( dir, S_IRWXU | S_IRWXG | S_IRWXO )
|
||||
#define SetFilePointer( handle, pos, ign, dir ) lseek( (int) handle, pos, dir )
|
||||
#define SetFilePointer( handle, pos, ign, dir ) lseek( (intptr_t) handle, pos, dir )
|
||||
bool ReadFile( void *handle, void *outbuf, unsigned int toread, unsigned int *nread, void *ignored )
|
||||
{
|
||||
*nread = read( (int) handle, outbuf, toread );
|
||||
*nread = read( (intptr_t) handle, outbuf, toread );
|
||||
return *nread == toread;
|
||||
}
|
||||
bool WriteFile( void *handle, void *buf, unsigned int towrite, unsigned int *written, void *ignored )
|
||||
{
|
||||
*written = write( (int) handle, buf, towrite );
|
||||
*written = write( (intptr_t) handle, buf, towrite );
|
||||
return *written == towrite;
|
||||
}
|
||||
|
||||
@@ -2778,8 +2778,8 @@ LUFILE *lufopen(void *z,unsigned int len,DWORD flags,ZRESULT *err)
|
||||
#ifdef _WIN32
|
||||
res = DuplicateHandle(GetCurrentProcess(),hf,GetCurrentProcess(),&h,0,FALSE,DUPLICATE_SAME_ACCESS) == TRUE;
|
||||
#else
|
||||
h = (void*) dup( (int)hf );
|
||||
res = (int) dup >= 0;
|
||||
h = (void*) dup( (intptr_t)hf );
|
||||
res = (intptr_t) dup >= 0;
|
||||
#endif
|
||||
if (!res)
|
||||
{
|
||||
@@ -2806,7 +2806,7 @@ LUFILE *lufopen(void *z,unsigned int len,DWORD flags,ZRESULT *err)
|
||||
canseek = (type==FILE_TYPE_DISK);
|
||||
#else
|
||||
struct stat buf;
|
||||
fstat( (int)h, &buf );
|
||||
fstat( (intptr_t)h, &buf );
|
||||
canseek = buf.st_mode & S_IFREG;
|
||||
#endif
|
||||
}
|
||||
@@ -4235,7 +4235,7 @@ ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags)
|
||||
settime=true;
|
||||
#else
|
||||
struct stat sbuf;
|
||||
fstat( (int)h, &sbuf );
|
||||
fstat( (intptr_t)h, &sbuf );
|
||||
settime = ( sbuf.st_mode & S_IFREG );
|
||||
#endif
|
||||
|
||||
@@ -4256,7 +4256,7 @@ ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags)
|
||||
tv[0].tv_usec = 0;
|
||||
tv[1].tv_sec = ze.mtime;
|
||||
tv[1].tv_usec = 0;
|
||||
futimes( (int)h, tv );
|
||||
futimes( (intptr_t)h, tv );
|
||||
#endif
|
||||
}
|
||||
if (flags!=ZIP_HANDLE)
|
||||
|
||||
+1
-1
@@ -663,7 +663,7 @@ public:
|
||||
CDispCornerNeighbors m_CornerNeighbors[4]; // Indexed by CORNER_ defines.
|
||||
|
||||
enum unnamed { ALLOWEDVERTS_SIZE = PAD_NUMBER( MAX_DISPVERTS, 32 ) / 32 };
|
||||
unsigned long m_AllowedVerts[ALLOWEDVERTS_SIZE]; // This is built based on the layout and sizes of our neighbors
|
||||
unsigned int m_AllowedVerts[ALLOWEDVERTS_SIZE]; // This is built based on the layout and sizes of our neighbors
|
||||
// and tells us which vertices are allowed to be active.
|
||||
};
|
||||
|
||||
|
||||
+12
-12
@@ -35,16 +35,16 @@ public:
|
||||
void ElementMoved( BSPTreeDataHandle_t handle, Vector const& mins, Vector const& maxs );
|
||||
|
||||
// Enumerate elements in a particular leaf
|
||||
bool EnumerateElementsInLeaf( int leaf, IBSPTreeDataEnumerator* pEnum, int context );
|
||||
bool EnumerateElementsInLeaf( int leaf, IBSPTreeDataEnumerator* pEnum, intp context );
|
||||
|
||||
// For convenience, enumerates the leaves along a ray, box, etc.
|
||||
bool EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, int context );
|
||||
bool EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, int context );
|
||||
bool EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, int context );
|
||||
bool EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, int context );
|
||||
bool EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, intp context );
|
||||
bool EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, intp context );
|
||||
bool EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, intp context );
|
||||
bool EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, intp context );
|
||||
|
||||
// methods of IBSPLeafEnumerator
|
||||
bool EnumerateLeaf( int leaf, int context );
|
||||
bool EnumerateLeaf( int leaf, intp context );
|
||||
|
||||
// Is the element in any leaves at all?
|
||||
bool IsElementInTree( BSPTreeDataHandle_t handle ) const;
|
||||
@@ -223,7 +223,7 @@ void CBSPTreeData::AddHandleToLeaf( int leaf, BSPTreeDataHandle_t handle )
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inserts an element into the tree
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBSPTreeData::EnumerateLeaf( int leaf, int context )
|
||||
bool CBSPTreeData::EnumerateLeaf( int leaf, intp context )
|
||||
{
|
||||
BSPTreeDataHandle_t handle = (BSPTreeDataHandle_t)context;
|
||||
AddHandleToLeaf( leaf, handle );
|
||||
@@ -302,7 +302,7 @@ int CBSPTreeData::CountElementsInLeaf( int leaf )
|
||||
//-----------------------------------------------------------------------------
|
||||
// Enumerate elements in a particular leaf
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBSPTreeData::EnumerateElementsInLeaf( int leaf, IBSPTreeDataEnumerator* pEnum, int context )
|
||||
bool CBSPTreeData::EnumerateElementsInLeaf( int leaf, IBSPTreeDataEnumerator* pEnum, intp context )
|
||||
{
|
||||
#ifdef DBGFLAG_ASSERT
|
||||
// The enumeration method better damn well not change this list...
|
||||
@@ -330,22 +330,22 @@ bool CBSPTreeData::EnumerateElementsInLeaf( int leaf, IBSPTreeDataEnumerator* pE
|
||||
//-----------------------------------------------------------------------------
|
||||
// For convenience, enumerates the leaves along a ray, box, etc.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBSPTreeData::EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, int context )
|
||||
bool CBSPTreeData::EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, intp context )
|
||||
{
|
||||
return m_pBSPTree->EnumerateLeavesAtPoint( pt, pEnum, context );
|
||||
}
|
||||
|
||||
bool CBSPTreeData::EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, int context )
|
||||
bool CBSPTreeData::EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, intp context )
|
||||
{
|
||||
return m_pBSPTree->EnumerateLeavesInBox( mins, maxs, pEnum, context );
|
||||
}
|
||||
|
||||
bool CBSPTreeData::EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, int context )
|
||||
bool CBSPTreeData::EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, intp context )
|
||||
{
|
||||
return m_pBSPTree->EnumerateLeavesInSphere( center, radius, pEnum, context );
|
||||
}
|
||||
|
||||
bool CBSPTreeData::EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, int context )
|
||||
bool CBSPTreeData::EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, intp context )
|
||||
{
|
||||
return m_pBSPTree->EnumerateLeavesAlongRay( ray, pEnum, context );
|
||||
}
|
||||
|
||||
+11
-11
@@ -58,7 +58,7 @@ public:
|
||||
// that passes the test; return true to continue enumerating,
|
||||
// false to stop
|
||||
|
||||
virtual bool EnumerateLeaf( int leaf, int context ) = 0;
|
||||
virtual bool EnumerateLeaf( int leaf, intp context ) = 0;
|
||||
};
|
||||
|
||||
abstract_class ISpatialQuery
|
||||
@@ -68,10 +68,10 @@ public:
|
||||
virtual int LeafCount() const = 0;
|
||||
|
||||
// Enumerates the leaves along a ray, box, etc.
|
||||
virtual bool EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
virtual bool EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
virtual bool EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
virtual bool EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ abstract_class IBSPTreeDataEnumerator
|
||||
{
|
||||
public:
|
||||
// call back with a userId and a context
|
||||
virtual bool FASTCALL EnumerateElement( int userId, int context ) = 0;
|
||||
virtual bool FASTCALL EnumerateElement( int userId, intp context ) = 0;
|
||||
};
|
||||
|
||||
abstract_class IBSPTreeData
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
virtual void ElementMoved( BSPTreeDataHandle_t handle, Vector const& mins, Vector const& maxs ) = 0;
|
||||
|
||||
// Enumerate elements in a particular leaf
|
||||
virtual bool EnumerateElementsInLeaf( int leaf, IBSPTreeDataEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateElementsInLeaf( int leaf, IBSPTreeDataEnumerator* pEnum, intp context ) = 0;
|
||||
|
||||
// Is the element in any leaves at all?
|
||||
virtual bool IsElementInTree( BSPTreeDataHandle_t handle ) const = 0;
|
||||
@@ -117,10 +117,10 @@ public:
|
||||
// NOTE: These methods call through to the functions in the attached
|
||||
// ISpatialQuery
|
||||
// For convenience, enumerates the leaves along a ray, box, etc.
|
||||
virtual bool EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, int context ) = 0;
|
||||
virtual bool EnumerateLeavesAtPoint( Vector const& pt, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
virtual bool EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
virtual bool EnumerateLeavesInSphere( Vector const& center, float radius, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
virtual bool EnumerateLeavesAlongRay( Ray_t const& ray, ISpatialLeafEnumerator* pEnum, intp context ) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -35,7 +35,7 @@ class IDataCache;
|
||||
//---------------------------------------------------------
|
||||
// Unique (per section) identifier for a cache item defined by client
|
||||
//---------------------------------------------------------
|
||||
typedef uint32 DataCacheClientID_t;
|
||||
typedef uintp DataCacheClientID_t;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
@@ -491,7 +491,7 @@ public:
|
||||
m_pCache->EnsureCapacity(STORAGE_TYPE::EstimatedSize(createParams));
|
||||
STORAGE_TYPE *pStore = STORAGE_TYPE::CreateResource( createParams );
|
||||
DataCacheHandle_t handle;
|
||||
m_pCache->AddEx( (DataCacheClientID_t)pStore, pStore, pStore->Size(), flags, &handle);
|
||||
m_pCache->AddEx( (DataCacheClientID_t)(uintp)pStore, pStore, pStore->Size(), flags, &handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,17 @@ namespace OptimizedModel
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef unsigned short MDLHandle_t;
|
||||
|
||||
// MoeMod : integer promotion keeps sign on arm, but discards sign on x86
|
||||
inline MDLHandle_t VoidPtrToMDLHandle( void *ptr )
|
||||
{
|
||||
return ( MDLHandle_t ) ( ( uintp ) ptr & 0xffff );
|
||||
}
|
||||
|
||||
inline void* MDLHandleToVirtual( MDLHandle_t hndl )
|
||||
{
|
||||
return (void*)(uintp)hndl;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
MDLHANDLE_INVALID = (MDLHandle_t)~0
|
||||
|
||||
+2
-1
@@ -64,6 +64,7 @@ typedef enum _fieldtypes
|
||||
FIELD_MATERIALINDEX, // a material index (using the material precache string table)
|
||||
|
||||
FIELD_VECTOR2D, // 2 floats
|
||||
FIELD_INTEGER64, // 64bit integer
|
||||
|
||||
FIELD_TYPECOUNT, // MUST BE LAST
|
||||
} fieldtype_t;
|
||||
@@ -128,7 +129,7 @@ DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) )
|
||||
#define ARRAYSIZE2D(p) (sizeof(p)/sizeof(p[0][0]))
|
||||
#define SIZE_OF_ARRAY(p) _ARRAYSIZE(p)
|
||||
|
||||
#define _offsetof(s,m) ((int)&(((s *)0)->m))
|
||||
#define _offsetof(s,m) ((int)(intp)&(((s *)0)->m))
|
||||
|
||||
#define _FIELD(name,fieldtype,count,flags,mapname,tolerance) { fieldtype, #name, { _offsetof(classNameTypedef, name), 0 }, count, flags, mapname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, tolerance }
|
||||
#define DEFINE_FIELD_NULL { FIELD_VOID,0, {0,0},0,0,0,0,0,0}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "tier1/interface.h"
|
||||
#include "bitmap/imageformat.h"
|
||||
|
||||
typedef unsigned int ColorCorrectionHandle_t;
|
||||
typedef uintp ColorCorrectionHandle_t;
|
||||
struct ShaderColorCorrectionInfo_t;
|
||||
|
||||
#define COLORCORRECTION_INTERFACE_VERSION "COLORCORRECTION_VERSION_1"
|
||||
|
||||
@@ -1156,7 +1156,7 @@ inline void CVertexBuilder::FastAdvanceNVertices( int n )
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CVertexBuilder::FastVertex( const ModelVertexDX7_t &vertex )
|
||||
{
|
||||
#ifdef __arm__
|
||||
#if defined(__arm__) || defined(__arm64__)
|
||||
FastVertexSSE( vertex );
|
||||
#else
|
||||
Assert( m_CompressionType == VERTEX_COMPRESSION_NONE ); // FIXME: support compressed verts if needed
|
||||
@@ -1244,11 +1244,11 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX7_t &vertex )
|
||||
const char *pRead = (char *)&vertex;
|
||||
char *pCurrPos = (char *)m_pCurrPosition;
|
||||
__m128 m1 = _mm_load_ps( (float *)pRead );
|
||||
__m128 m2 = _mm_load_ps( (float *)((int)pRead + 16) );
|
||||
__m128 m3 = _mm_load_ps( (float *)((int)pRead + 32) );
|
||||
__m128 m2 = _mm_load_ps( (float *)((intp)pRead + 16) );
|
||||
__m128 m3 = _mm_load_ps( (float *)((intp)pRead + 32) );
|
||||
_mm_stream_ps( (float *)pCurrPos, m1 );
|
||||
_mm_stream_ps( (float *)((int)pCurrPos + 16), m2 );
|
||||
_mm_stream_ps( (float *)((int)pCurrPos + 32), m3 );
|
||||
_mm_stream_ps( (float *)((intp)pCurrPos + 16), m2 );
|
||||
_mm_stream_ps( (float *)((intp)pCurrPos + 32), m3 );
|
||||
#else
|
||||
Error( "Implement CMeshBuilder::FastVertexSSE(dx7)" );
|
||||
#endif
|
||||
@@ -1326,7 +1326,7 @@ inline void CVertexBuilder::Fast4VerticesSSE(
|
||||
|
||||
inline void CVertexBuilder::FastVertex( const ModelVertexDX8_t &vertex )
|
||||
{
|
||||
#ifdef __arm__
|
||||
#if defined(__arm__) || defined(__arm64__)
|
||||
FastVertexSSE( vertex );
|
||||
#else
|
||||
Assert( m_CompressionType == VERTEX_COMPRESSION_NONE ); // FIXME: support compressed verts if needed
|
||||
@@ -1436,13 +1436,13 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX8_t &vertex )
|
||||
:: "r" (pRead), "r" (pCurrPos) : "memory"); */
|
||||
|
||||
__m128 m1 = _mm_load_ps( (float *)pRead );
|
||||
__m128 m2 = _mm_load_ps( (float *)((int)pRead + 16) );
|
||||
__m128 m3 = _mm_load_ps( (float *)((int)pRead + 32) );
|
||||
__m128 m4 = _mm_load_ps( (float *)((int)pRead + 48) );
|
||||
__m128 m2 = _mm_load_ps( (float *)((intp)pRead + 16) );
|
||||
__m128 m3 = _mm_load_ps( (float *)((intp)pRead + 32) );
|
||||
__m128 m4 = _mm_load_ps( (float *)((intp)pRead + 48) );
|
||||
_mm_stream_ps( (float *)pCurrPos, m1 );
|
||||
_mm_stream_ps( (float *)((int)pCurrPos + 16), m2 );
|
||||
_mm_stream_ps( (float *)((int)pCurrPos + 32), m3 );
|
||||
_mm_stream_ps( (float *)((int)pCurrPos + 48), m4 );
|
||||
_mm_stream_ps( (float *)((intp)pCurrPos + 16), m2 );
|
||||
_mm_stream_ps( (float *)((intp)pCurrPos + 32), m3 );
|
||||
_mm_stream_ps( (float *)((intp)pCurrPos + 48), m4 );
|
||||
#else
|
||||
Error( "Implement CMeshBuilder::FastVertexSSE((dx8)" );
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
|
||||
#pragma warning( disable : 4284 ) // warning C4284: return type for 'CNetworkVarT<int>::operator ->' is 'int *' (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation)
|
||||
|
||||
#define MyOffsetOf( type, var ) ( (int)&((type*)0)->var )
|
||||
#define MyOffsetOf( type, var ) ( (intp)&((type*)0)->var )
|
||||
|
||||
#ifdef _DEBUG
|
||||
extern bool g_bUseNetworkVars;
|
||||
|
||||
@@ -52,7 +52,7 @@ enum ShaderRenderTarget_t
|
||||
//-----------------------------------------------------------------------------
|
||||
// This must match the definition in playback.cpp!
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef int ShaderAPITextureHandle_t;
|
||||
typedef intp ShaderAPITextureHandle_t;
|
||||
#define INVALID_SHADERAPI_TEXTURE_HANDLE 0
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "tier0/basetypes.h"
|
||||
|
||||
|
||||
typedef int ShaderAPITextureHandle_t;
|
||||
typedef intp ShaderAPITextureHandle_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
|
||||
+69
-3
@@ -1194,10 +1194,16 @@ struct mstudiotexture_t
|
||||
int flags;
|
||||
int used;
|
||||
int unused1;
|
||||
#if PLATFORM_64BITS
|
||||
mutable IMaterial *material;
|
||||
mutable void *clientmaterial;
|
||||
int unused[8];
|
||||
#else
|
||||
mutable IMaterial *material; // fixme: this needs to go away . .isn't used by the engine, but is used by studiomdl
|
||||
mutable void *clientmaterial; // gary, replace with client material pointer if used
|
||||
|
||||
int unused[10];
|
||||
#endif
|
||||
};
|
||||
|
||||
// eyeball
|
||||
@@ -1290,6 +1296,11 @@ struct mstudio_modelvertexdata_t
|
||||
const void *pTangentData;
|
||||
};
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
// 64b - match 32-bit packing
|
||||
#pragma pack( push, 4 )
|
||||
#endif
|
||||
|
||||
struct mstudio_meshvertexdata_t
|
||||
{
|
||||
DECLARE_BYTESWAP_DATADESC();
|
||||
@@ -1339,9 +1350,15 @@ struct mstudiomesh_t
|
||||
|
||||
Vector center;
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
mstudio_meshvertexdata_t vertexdata;
|
||||
|
||||
int unused[7]; // remove as appropriate
|
||||
#else
|
||||
mstudio_meshvertexdata_t vertexdata;
|
||||
|
||||
int unused[8]; // remove as appropriate
|
||||
#endif
|
||||
|
||||
mstudiomesh_t(){}
|
||||
private:
|
||||
@@ -1383,11 +1400,22 @@ struct mstudiomodel_t
|
||||
int eyeballindex;
|
||||
inline mstudioeyeball_t *pEyeball( int i ) { return (mstudioeyeball_t *)(((byte *)this) + eyeballindex) + i; };
|
||||
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
mstudio_modelvertexdata_t vertexdata; // sizeof(mstudio_modelvertexdata_t) == 16
|
||||
|
||||
int unused[6]; // remove as appropriate
|
||||
#else
|
||||
mstudio_modelvertexdata_t vertexdata;
|
||||
|
||||
int unused[8]; // remove as appropriate
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
#pragma pack( pop )
|
||||
#endif
|
||||
|
||||
inline bool mstudio_modelvertexdata_t::HasTangentData( void ) const
|
||||
{
|
||||
return (pTangentData != NULL);
|
||||
@@ -1396,14 +1424,14 @@ inline bool mstudio_modelvertexdata_t::HasTangentData( void ) const
|
||||
inline int mstudio_modelvertexdata_t::GetGlobalVertexIndex( int i ) const
|
||||
{
|
||||
mstudiomodel_t *modelptr = (mstudiomodel_t *)((byte *)this - offsetof(mstudiomodel_t, vertexdata));
|
||||
Assert( ( modelptr->vertexindex % sizeof( mstudiovertex_t ) ) == 0 );
|
||||
//Assert( ( modelptr->vertexindex % sizeof( mstudiovertex_t ) ) == 0 );
|
||||
return ( i + ( modelptr->vertexindex / sizeof( mstudiovertex_t ) ) );
|
||||
}
|
||||
|
||||
inline int mstudio_modelvertexdata_t::GetGlobalTangentIndex( int i ) const
|
||||
{
|
||||
mstudiomodel_t *modelptr = (mstudiomodel_t *)((byte *)this - offsetof(mstudiomodel_t, vertexdata));
|
||||
Assert( ( modelptr->tangentsindex % sizeof( Vector4D ) ) == 0 );
|
||||
//Assert( ( modelptr->tangentsindex % sizeof( Vector4D ) ) == 0 );
|
||||
return ( i + ( modelptr->tangentsindex / sizeof( Vector4D ) ) );
|
||||
}
|
||||
|
||||
@@ -2263,7 +2291,11 @@ struct studiohdr_t
|
||||
const studiohdr_t *FindModel( void **cache, char const *modelname ) const;
|
||||
|
||||
// implementation specific back pointer to virtual data
|
||||
#ifdef PLATFORM_64BITS
|
||||
int index_ptr_virtualModel;
|
||||
#else
|
||||
mutable void *virtualModel;
|
||||
#endif
|
||||
virtualmodel_t *GetVirtualModel( void ) const;
|
||||
|
||||
// for demand loaded animation blocks
|
||||
@@ -2272,7 +2304,11 @@ struct studiohdr_t
|
||||
int numanimblocks;
|
||||
int animblockindex;
|
||||
inline mstudioanimblock_t *pAnimBlock( int i ) const { Assert( i > 0 && i < numanimblocks); return (mstudioanimblock_t *)(((byte *)this) + animblockindex) + i; };
|
||||
#ifdef PLATFORM_64BITS
|
||||
int index_ptr_animblockModel;
|
||||
#else
|
||||
mutable void *animblockModel;
|
||||
#endif
|
||||
byte * GetAnimBlock( int i ) const;
|
||||
|
||||
int bonetablebynameindex;
|
||||
@@ -2280,8 +2316,13 @@ struct studiohdr_t
|
||||
|
||||
// used by tools only that don't cache, but persist mdl's peer data
|
||||
// engine uses virtualModel to back link to cache pointers
|
||||
#ifdef PLATFORM_64BITS
|
||||
int index_ptr_pVertexBase;
|
||||
int index_ptr_pIndexBase;
|
||||
#else
|
||||
void *pVertexBase;
|
||||
void *pIndexBase;
|
||||
#endif
|
||||
|
||||
// if STUDIOHDR_FLAGS_CONSTANT_DIRECTIONAL_LIGHT_DOT is set,
|
||||
// this value is used to calculate directional components of lighting
|
||||
@@ -2327,7 +2368,23 @@ struct studiohdr_t
|
||||
inline mstudiolinearbone_t *pLinearBones() const { return studiohdr2index ? pStudioHdr2()->pLinearBones() : NULL; }
|
||||
|
||||
inline int BoneFlexDriverCount() const { return studiohdr2index ? pStudioHdr2()->m_nBoneFlexDriverCount : 0; }
|
||||
inline const mstudioboneflexdriver_t* BoneFlexDriver( int i ) const { Assert( i >= 0 && i < BoneFlexDriverCount() ); return studiohdr2index ? pStudioHdr2()->pBoneFlexDriver( i ) : NULL; }
|
||||
inline const mstudioboneflexdriver_t* BoneFlexDriver( int i ) const { Assert( i >= 0 && i < BoneFlexDriverCount() ); return studiohdr2index > 0 ? pStudioHdr2()->pBoneFlexDriver( i ) : NULL; }
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
void* VirtualModel() const { return *(void **)(((byte *)this) + index_ptr_virtualModel); }
|
||||
void SetVirtualModel( void* ptr ) const { *(void **)(((byte *)this) + index_ptr_virtualModel) = ptr; }
|
||||
void* VertexBase() const { return *(void **)(((byte *)this) + index_ptr_pVertexBase); }
|
||||
void SetVertexBase( void* ptr ) { *(void **)(((byte *)this) + index_ptr_pVertexBase) = ptr; }
|
||||
void* IndexBase() const { return *(void **)(((byte *)this) + index_ptr_pIndexBase); }
|
||||
void SetIndexBase( void* ptr ) { *(void **)(((byte *)this) + index_ptr_pIndexBase) = ptr; }
|
||||
#else
|
||||
void* VirtualModel() const { return virtualModel; }
|
||||
void SetVirtualModel( void* ptr ) const { virtualModel = ptr; }
|
||||
void* VertexBase() const { return pVertexBase; }
|
||||
void SetVertexBase( void* ptr ) { pVertexBase = ptr; }
|
||||
void* IndexBase() const { return pIndexBase; }
|
||||
void SetIndexBase( void* ptr ) { pIndexBase = ptr; } }
|
||||
#endif
|
||||
|
||||
// NOTE: No room to add stuff? Up the .mdl file format version
|
||||
// [and move all fields in studiohdr2_t into studiohdr_t and kill studiohdr2_t],
|
||||
@@ -2340,6 +2397,15 @@ private:
|
||||
friend struct virtualmodel_t;
|
||||
};
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
struct studiohdr_shim64_index
|
||||
{
|
||||
mutable void *virtualModel;
|
||||
mutable void *animblockModel;
|
||||
void *pVertexBase;
|
||||
void *pIndexBase;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+23
-8
@@ -9,7 +9,7 @@
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
#if defined(__x86_64__) || defined(_WIN64)
|
||||
#if defined(__x86_64__) || defined(_WIN64) || defined(__arm64__)
|
||||
#define PLATFORM_64BITS 1
|
||||
#endif
|
||||
|
||||
@@ -70,7 +70,11 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#ifdef OSX
|
||||
#include <malloc/malloc.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <new>
|
||||
|
||||
// need this for memset
|
||||
@@ -171,6 +175,9 @@ typedef signed char int8;
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
|
||||
typedef int64 lint64;
|
||||
typedef uint64 ulint64;
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
typedef __int64 intp; // intp is an integer that can accomodate a pointer
|
||||
typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *)
|
||||
@@ -201,13 +208,17 @@ typedef signed char int8;
|
||||
typedef unsigned int uint32;
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
typedef long int lint64;
|
||||
typedef unsigned long int ulint64;
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
typedef long long intp;
|
||||
typedef unsigned long long uintp;
|
||||
#else
|
||||
typedef int intp;
|
||||
typedef unsigned int uintp;
|
||||
#endif
|
||||
#endif
|
||||
typedef void *HWND;
|
||||
|
||||
// Avoid redefinition warnings if a previous header defines this.
|
||||
@@ -429,7 +440,11 @@ typedef void * HINSTANCE;
|
||||
// On OSX, SIGTRAP doesn't really stop the thread cold when debugging.
|
||||
// So if being debugged, use INT3 which is precise.
|
||||
#ifdef OSX
|
||||
#define DebuggerBreak() if ( Plat_IsInDebugSession() ) { __asm ( "int $3" ); } else { raise(SIGTRAP); }
|
||||
#if defined(__arm__) || defined(__arm64__)
|
||||
#define DebuggerBreak() do { if ( Plat_IsInDebugSession() ) { __builtin_debugtrap(); } else { raise(SIGTRAP); } } while(0)
|
||||
#else
|
||||
#define DebuggerBreak() do { if ( Plat_IsInDebugSession() ) { __asm ( "int $3" ); } else { raise(SIGTRAP); } } while(0)
|
||||
#endif
|
||||
#else
|
||||
#define DebuggerBreak() raise(SIGTRAP)
|
||||
#endif
|
||||
@@ -752,7 +767,7 @@ typedef void * HINSTANCE;
|
||||
#define _wtoi(arg) wcstol(arg, NULL, 10)
|
||||
#define _wtoi64(arg) wcstoll(arg, NULL, 10)
|
||||
|
||||
typedef uint32 HMODULE;
|
||||
typedef uintp HMODULE;
|
||||
typedef void *HANDLE;
|
||||
#endif
|
||||
|
||||
@@ -830,7 +845,7 @@ static FORCEINLINE double fsel(double fComparand, double fValGE, double fLT)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#elif defined (__arm__)
|
||||
#elif defined (__arm__) || defined (__arm64__)
|
||||
inline void SetupFPUControlWord() {}
|
||||
#else
|
||||
inline void SetupFPUControlWord()
|
||||
@@ -1094,12 +1109,12 @@ FORCEINLINE void StoreLittleDWord( unsigned long *base, unsigned int dwordIndex,
|
||||
__storewordbytereverse( dword, dwordIndex<<2, base );
|
||||
}
|
||||
#else
|
||||
FORCEINLINE unsigned long LoadLittleDWord( const unsigned long *base, unsigned int dwordIndex )
|
||||
FORCEINLINE uint32 LoadLittleDWord( const uint32 *base, unsigned int dwordIndex )
|
||||
{
|
||||
return LittleDWord( base[dwordIndex] );
|
||||
}
|
||||
|
||||
FORCEINLINE void StoreLittleDWord( unsigned long *base, unsigned int dwordIndex, unsigned long dword )
|
||||
FORCEINLINE void StoreLittleDWord( uint32 *base, unsigned int dwordIndex, uint32 dword )
|
||||
{
|
||||
base[dwordIndex] = LittleDWord(dword);
|
||||
}
|
||||
@@ -1167,7 +1182,7 @@ PLATFORM_INTERFACE struct tm * Plat_localtime( const time_t *timep, struct tm *
|
||||
|
||||
inline uint64 Plat_Rdtsc()
|
||||
{
|
||||
#if defined( __arm__ ) && defined (POSIX)
|
||||
#if (defined( __arm__ ) || defined( __arm64__ )) && defined (POSIX)
|
||||
struct timespec t;
|
||||
clock_gettime( CLOCK_REALTIME, &t);
|
||||
return t.tv_sec * 1000000000ULL + t.tv_nsec;
|
||||
|
||||
+152
-66
@@ -12,6 +12,9 @@
|
||||
#include "tier0/type_traits.h"
|
||||
|
||||
#include <limits.h>
|
||||
#if defined( __arm__ ) || defined( __arm64__ )
|
||||
#include <atomic>
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier0/dbg.h"
|
||||
@@ -100,7 +103,11 @@ const unsigned TT_INFINITE = 0xffffffff;
|
||||
|
||||
#endif // NO_THREAD_LOCAL
|
||||
|
||||
typedef unsigned long ThreadId_t;
|
||||
#ifdef PLATFORM_64BITS
|
||||
typedef uint64 ThreadId_t;
|
||||
#else
|
||||
typedef uint32 ThreadId_t;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
@@ -109,7 +116,7 @@ typedef unsigned long ThreadId_t;
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
FORWARD_DECLARE_HANDLE( ThreadHandle_t );
|
||||
typedef unsigned (*ThreadFunc_t)( void *pParam );
|
||||
typedef uintp (*ThreadFunc_t)( void *pParam );
|
||||
|
||||
PLATFORM_OVERLOAD ThreadHandle_t CreateSimpleThread( ThreadFunc_t, void *pParam, ThreadId_t *pID, unsigned stackSize = 0 );
|
||||
PLATFORM_INTERFACE ThreadHandle_t CreateSimpleThread( ThreadFunc_t, void *pParam, unsigned stackSize = 0 );
|
||||
@@ -119,7 +126,7 @@ PLATFORM_INTERFACE bool ReleaseThreadHandle( ThreadHandle_t );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PLATFORM_INTERFACE void ThreadSleep(unsigned duration = 0);
|
||||
PLATFORM_INTERFACE uint ThreadGetCurrentId();
|
||||
PLATFORM_INTERFACE ThreadId_t ThreadGetCurrentId();
|
||||
PLATFORM_INTERFACE ThreadHandle_t ThreadGetCurrentHandle();
|
||||
PLATFORM_INTERFACE int ThreadGetPriority( ThreadHandle_t hThread = NULL );
|
||||
PLATFORM_INTERFACE bool ThreadSetPriority( ThreadHandle_t hThread, int priority );
|
||||
@@ -142,10 +149,10 @@ inline void ThreadPause()
|
||||
#if defined( PLATFORM_WINDOWS_PC )
|
||||
// Intrinsic for __asm pause; from <intrin.h>
|
||||
_mm_pause();
|
||||
#elif POSIX && defined( __i386__ )
|
||||
#elif POSIX && ( defined( __i386__ ) || defined( __x86_64__ ) )
|
||||
__asm __volatile( "pause" );
|
||||
#elif defined( _X360 )
|
||||
#elif defined(__arm__)
|
||||
#elif defined(__arm__) || defined(__arm64__)
|
||||
sched_yield();
|
||||
#else
|
||||
#error "implement me"
|
||||
@@ -238,28 +245,28 @@ extern "C"
|
||||
#pragma intrinsic( _InterlockedExchangeAdd )
|
||||
#pragma intrinsic( _InterlockedIncrement )
|
||||
|
||||
inline long ThreadInterlockedIncrement( long volatile *p ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedIncrement( p ); }
|
||||
inline long ThreadInterlockedDecrement( long volatile *p ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedDecrement( p ); }
|
||||
inline long ThreadInterlockedExchange( long volatile *p, long value ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedExchange( p, value ); }
|
||||
inline long ThreadInterlockedExchangeAdd( long volatile *p, long value ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedExchangeAdd( p, value ); }
|
||||
inline long ThreadInterlockedCompareExchange( long volatile *p, long value, long comperand ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedCompareExchange( p, value, comperand ); }
|
||||
inline bool ThreadInterlockedAssignIf( long volatile *p, long value, long comperand ) { Assert( (size_t)p % 4 == 0 ); return ( _InterlockedCompareExchange( p, value, comperand ) == comperand ); }
|
||||
inline int32 ThreadInterlockedIncrement( int32 volatile *p ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedIncrement( p ); }
|
||||
inline int32 ThreadInterlockedDecrement( int32 volatile *p ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedDecrement( p ); }
|
||||
inline int32 ThreadInterlockedExchange( int32 volatile *p, int32 value ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedExchange( p, value ); }
|
||||
inline int32 ThreadInterlockedExchangeAdd( int32 volatile *p, int32 value ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedExchangeAdd( p, value ); }
|
||||
inline int32 ThreadInterlockedCompareExchange( int32 volatile *p, int32 value, int32 comperand ) { Assert( (size_t)p % 4 == 0 ); return _InterlockedCompareExchange( p, value, comperand ); }
|
||||
inline bool ThreadInterlockedAssignIf( int32 volatile *p, int32 value, int32 comperand ) { Assert( (size_t)p % 4 == 0 ); return ( _InterlockedCompareExchange( p, value, comperand ) == comperand ); }
|
||||
#else
|
||||
PLATFORM_INTERFACE long ThreadInterlockedIncrement( long volatile * );
|
||||
PLATFORM_INTERFACE long ThreadInterlockedDecrement( long volatile * );
|
||||
PLATFORM_INTERFACE long ThreadInterlockedExchange( long volatile *, long value );
|
||||
PLATFORM_INTERFACE long ThreadInterlockedExchangeAdd( long volatile *, long value );
|
||||
PLATFORM_INTERFACE long ThreadInterlockedCompareExchange( long volatile *, long value, long comperand );
|
||||
PLATFORM_INTERFACE bool ThreadInterlockedAssignIf( long volatile *, long value, long comperand );
|
||||
PLATFORM_INTERFACE int32 ThreadInterlockedIncrement( int32 volatile * );
|
||||
PLATFORM_INTERFACE int32 ThreadInterlockedDecrement( int32 volatile * );
|
||||
PLATFORM_INTERFACE int32 ThreadInterlockedExchange( int32 volatile *, int32 value );
|
||||
PLATFORM_INTERFACE int32 ThreadInterlockedExchangeAdd( int32 volatile *, int32 value );
|
||||
PLATFORM_INTERFACE int32 ThreadInterlockedCompareExchange( int32 volatile *, int32 value, int32 comperand );
|
||||
PLATFORM_INTERFACE bool ThreadInterlockedAssignIf( int32 volatile *, int32 value, int32 comperand );
|
||||
#endif
|
||||
|
||||
inline unsigned ThreadInterlockedExchangeSubtract( long volatile *p, long value ) { return ThreadInterlockedExchangeAdd( (long volatile *)p, -value ); }
|
||||
inline unsigned ThreadInterlockedExchangeSubtract( int32 volatile *p, int32 value ) { return ThreadInterlockedExchangeAdd( (int32 volatile *)p, -value ); }
|
||||
|
||||
#if defined( USE_INTRINSIC_INTERLOCKED ) && !defined( _WIN64 )
|
||||
#define TIPTR()
|
||||
inline void *ThreadInterlockedExchangePointer( void * volatile *p, void *value ) { return (void *)_InterlockedExchange( reinterpret_cast<long volatile *>(p), reinterpret_cast<long>(value) ); }
|
||||
inline void *ThreadInterlockedCompareExchangePointer( void * volatile *p, void *value, void *comperand ) { return (void *)_InterlockedCompareExchange( reinterpret_cast<long volatile *>(p), reinterpret_cast<long>(value), reinterpret_cast<long>(comperand) ); }
|
||||
inline bool ThreadInterlockedAssignPointerIf( void * volatile *p, void *value, void *comperand ) { return ( _InterlockedCompareExchange( reinterpret_cast<long volatile *>(p), reinterpret_cast<long>(value), reinterpret_cast<long>(comperand) ) == reinterpret_cast<long>(comperand) ); }
|
||||
inline void *ThreadInterlockedExchangePointer( void * volatile *p, void *value ) { return (void *)_InterlockedExchange( reinterpret_cast<intp volatile *>(p), reinterpret_cast<intp>(value) ); }
|
||||
inline void *ThreadInterlockedCompareExchangePointer( void * volatile *p, void *value, void *comperand ) { return (void *)_InterlockedCompareExchange( reinterpret_cast<intp volatile *>(p), reinterpret_cast<intp>(value), reinterpret_cast<intp>(comperand) ); }
|
||||
inline bool ThreadInterlockedAssignPointerIf( void * volatile *p, void *value, void *comperand ) { return ( _InterlockedCompareExchange( reinterpret_cast<intp volatile *>(p), reinterpret_cast<intp>(value), reinterpret_cast<intp>(comperand) ) == reinterpret_cast<intp>(comperand) ); }
|
||||
#else
|
||||
PLATFORM_INTERFACE void *ThreadInterlockedExchangePointer( void * volatile *, void *value ) NOINLINE;
|
||||
PLATFORM_INTERFACE void *ThreadInterlockedCompareExchangePointer( void * volatile *, void *value, void *comperand ) NOINLINE;
|
||||
@@ -276,7 +283,7 @@ typedef __m128i int128;
|
||||
inline int128 int128_zero() { return _mm_setzero_si128(); }
|
||||
#else
|
||||
typedef __int128_t int128;
|
||||
#define int128_zero() 0
|
||||
#define int128_zero() int128()
|
||||
#endif
|
||||
|
||||
PLATFORM_INTERFACE bool ThreadInterlockedAssignIf128( volatile int128 *pDest, const int128 &value, const int128 &comperand ) NOINLINE;
|
||||
@@ -290,21 +297,28 @@ PLATFORM_INTERFACE int64 ThreadInterlockedExchange64( int64 volatile *, int64 va
|
||||
PLATFORM_INTERFACE int64 ThreadInterlockedExchangeAdd64( int64 volatile *, int64 value ) NOINLINE;
|
||||
PLATFORM_INTERFACE bool ThreadInterlockedAssignIf64(volatile int64 *pDest, int64 value, int64 comperand ) NOINLINE;
|
||||
|
||||
inline unsigned ThreadInterlockedExchangeSubtract( unsigned volatile *p, unsigned value ) { return ThreadInterlockedExchangeAdd( (long volatile *)p, value ); }
|
||||
inline unsigned ThreadInterlockedIncrement( unsigned volatile *p ) { return ThreadInterlockedIncrement( (long volatile *)p ); }
|
||||
inline unsigned ThreadInterlockedDecrement( unsigned volatile *p ) { return ThreadInterlockedDecrement( (long volatile *)p ); }
|
||||
inline unsigned ThreadInterlockedExchange( unsigned volatile *p, unsigned value ) { return ThreadInterlockedExchange( (long volatile *)p, value ); }
|
||||
inline unsigned ThreadInterlockedExchangeAdd( unsigned volatile *p, unsigned value ) { return ThreadInterlockedExchangeAdd( (long volatile *)p, value ); }
|
||||
inline unsigned ThreadInterlockedCompareExchange( unsigned volatile *p, unsigned value, unsigned comperand ) { return ThreadInterlockedCompareExchange( (long volatile *)p, value, comperand ); }
|
||||
inline bool ThreadInterlockedAssignIf( unsigned volatile *p, unsigned value, unsigned comperand ) { return ThreadInterlockedAssignIf( (long volatile *)p, value, comperand ); }
|
||||
inline uint32 ThreadInterlockedExchangeSubtract( uint32 volatile *p, uint32 value ) { return ThreadInterlockedExchangeAdd( (int32 volatile *)p, value ); }
|
||||
inline uint32 ThreadInterlockedIncrement( uint32 volatile *p ) { return ThreadInterlockedIncrement( (int32 volatile *)p ); }
|
||||
inline uint32 ThreadInterlockedDecrement( uint32 volatile *p ) { return ThreadInterlockedDecrement( (int32 volatile *)p ); }
|
||||
inline uint32 ThreadInterlockedExchange( uint32 volatile *p, uint32 value ) { return ThreadInterlockedExchange( (int32 volatile *)p, value ); }
|
||||
inline uint32 ThreadInterlockedExchangeAdd( uint32 volatile *p, uint32 value ) { return ThreadInterlockedExchangeAdd( (int32 volatile *)p, value ); }
|
||||
inline uint32 ThreadInterlockedCompareExchange( uint32 volatile *p, uint32 value, uint32 comperand ) { return ThreadInterlockedCompareExchange( (int32 volatile *)p, value, comperand ); }
|
||||
inline bool ThreadInterlockedAssignIf( uint32 volatile *p, uint32 value, uint32 comperand ) { return ThreadInterlockedAssignIf( (int32 volatile *)p, value, comperand ); }
|
||||
|
||||
inline int ThreadInterlockedExchangeSubtract( int volatile *p, int value ) { return ThreadInterlockedExchangeAdd( (long volatile *)p, value ); }
|
||||
inline int ThreadInterlockedIncrement( int volatile *p ) { return ThreadInterlockedIncrement( (long volatile *)p ); }
|
||||
inline int ThreadInterlockedDecrement( int volatile *p ) { return ThreadInterlockedDecrement( (long volatile *)p ); }
|
||||
inline int ThreadInterlockedExchange( int volatile *p, int value ) { return ThreadInterlockedExchange( (long volatile *)p, value ); }
|
||||
inline int ThreadInterlockedExchangeAdd( int volatile *p, int value ) { return ThreadInterlockedExchangeAdd( (long volatile *)p, value ); }
|
||||
inline int ThreadInterlockedCompareExchange( int volatile *p, int value, int comperand ) { return ThreadInterlockedCompareExchange( (long volatile *)p, value, comperand ); }
|
||||
inline bool ThreadInterlockedAssignIf( int volatile *p, int value, int comperand ) { return ThreadInterlockedAssignIf( (long volatile *)p, value, comperand ); }
|
||||
inline uint64 ThreadInterlockedIncrement64( uint64 volatile *p ) { return ThreadInterlockedIncrement64( (int64 volatile *)p ); }
|
||||
inline uint64 ThreadInterlockedDecrement64( uint64 volatile *p ) { return ThreadInterlockedDecrement64( (int64 volatile *)p ); }
|
||||
inline uint64 ThreadInterlockedCompareExchange64( uint64 volatile *p, uint64 value, uint64 comperand ) { return ThreadInterlockedCompareExchange64( (int64 volatile *)p, value, comperand ); }
|
||||
inline uint64 ThreadInterlockedExchange64( uint64 volatile *p, uint64 value ) { return ThreadInterlockedExchange64( (int64 volatile *)p, value ); }
|
||||
inline uint64 ThreadInterlockedExchangeAdd64( uint64 volatile *p, uint64 value ) { return ThreadInterlockedExchangeAdd64( (int64 volatile *)p, value ); }
|
||||
inline bool ThreadInterlockedAssignIf64( uint64 volatile *p, uint64 value, uint64 comperand ) { return ThreadInterlockedAssignIf64( (int64 volatile *)p, value, comperand ); }
|
||||
|
||||
//inline int ThreadInterlockedExchangeSubtract( int volatile *p, int value ) { return ThreadInterlockedExchangeAdd( (int32 volatile *)p, value ); }
|
||||
//inline int ThreadInterlockedIncrement( int volatile *p ) { return ThreadInterlockedIncrement( (int32 volatile *)p ); }
|
||||
//inline int ThreadInterlockedDecrement( int volatile *p ) { return ThreadInterlockedDecrement( (int32 volatile *)p ); }
|
||||
//inline int ThreadInterlockedExchange( int volatile *p, int value ) { return ThreadInterlockedExchange( (int32 volatile *)p, value ); }
|
||||
//inline int ThreadInterlockedExchangeAdd( int volatile *p, int value ) { return ThreadInterlockedExchangeAdd( (int32 volatile *)p, value ); }
|
||||
//inline int ThreadInterlockedCompareExchange( int volatile *p, int value, int comperand ) { return ThreadInterlockedCompareExchange( (int32 volatile *)p, value, comperand ); }
|
||||
//inline bool ThreadInterlockedAssignIf( int volatile *p, int value, int comperand ) { return ThreadInterlockedAssignIf( (int32 volatile *)p, value, comperand ); }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Access to VTune thread profiling
|
||||
@@ -380,17 +394,44 @@ private:
|
||||
public:
|
||||
CThreadLocal()
|
||||
{
|
||||
COMPILE_TIME_ASSERT( sizeof(T) == sizeof(void *) );
|
||||
#ifdef PLATFORM_64BITS
|
||||
COMPILE_TIME_ASSERT( sizeof(T) <= sizeof(void *) );
|
||||
#else
|
||||
COMPILE_TIME_ASSERT( sizeof(T) == sizeof(void *) );
|
||||
#endif
|
||||
}
|
||||
|
||||
T Get() const
|
||||
{
|
||||
#ifdef PLATFORM_64BITS
|
||||
void *pData = CThreadLocalBase::Get();
|
||||
return *reinterpret_cast<T*>( &pData );
|
||||
#else
|
||||
#ifdef COMPILER_MSVC
|
||||
#pragma warning ( disable : 4311 )
|
||||
#endif
|
||||
return reinterpret_cast<T>( CThreadLocalBase::Get() );
|
||||
#ifdef COMPILER_MSVC
|
||||
#pragma warning ( default : 4311 )
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Set(T val)
|
||||
{
|
||||
#ifdef PLATFORM_64BITS
|
||||
void* pData = 0;
|
||||
*reinterpret_cast<T*>( &pData ) = val;
|
||||
CThreadLocalBase::Set( pData );
|
||||
#else
|
||||
#ifdef COMPILER_MSVC
|
||||
#pragma warning ( disable : 4312 )
|
||||
#endif
|
||||
CThreadLocalBase::Set( reinterpret_cast<void *>(val) );
|
||||
#ifdef COMPILER_MSVC
|
||||
#pragma warning ( default : 4312 )
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -433,16 +474,11 @@ template <class T = intp>
|
||||
operator const T *() { return (T *)Get(); }
|
||||
operator T *() { return (T *)Get(); }
|
||||
|
||||
int operator=( int i ) { AssertMsg( i == 0, "Only NULL allowed on integer assign" ); Set( NULL ); return 0; }
|
||||
T * operator=( T *p ) { Set( p ); return p; }
|
||||
|
||||
bool operator !() const { return (!Get()); }
|
||||
bool operator!=( int i ) const { AssertMsg( i == 0, "Only NULL allowed on integer compare" ); return (Get() != NULL); }
|
||||
bool operator==( int i ) const { AssertMsg( i == 0, "Only NULL allowed on integer compare" ); return (Get() == NULL); }
|
||||
bool operator==( const void *p ) const { return (Get() == p); }
|
||||
bool operator!=( const void *p ) const { return (Get() != p); }
|
||||
bool operator==( const T *p ) const { return operator==((void*)p); }
|
||||
bool operator!=( const T *p ) const { return operator!=((void*)p); }
|
||||
|
||||
T * operator->() { return (T *)Get(); }
|
||||
T & operator *() { return *((T *)Get()); }
|
||||
@@ -480,7 +516,7 @@ template <typename T>
|
||||
class CInterlockedIntT
|
||||
{
|
||||
public:
|
||||
CInterlockedIntT() : m_value( 0 ) { COMPILE_TIME_ASSERT( sizeof(T) == sizeof(long) ); }
|
||||
CInterlockedIntT() : m_value( 0 ) { COMPILE_TIME_ASSERT( sizeof(T) == sizeof(int) ); }
|
||||
CInterlockedIntT( T value ) : m_value( value ) {}
|
||||
|
||||
T GetRaw() const { return m_value; }
|
||||
@@ -491,17 +527,34 @@ public:
|
||||
bool operator==( T rhs ) const { return ( m_value == rhs ); }
|
||||
bool operator!=( T rhs ) const { return ( m_value != rhs ); }
|
||||
|
||||
T operator++() { return (T)ThreadInterlockedIncrement( (long *)&m_value ); }
|
||||
|
||||
#if defined( __arm__ ) || defined( __arm64__ )
|
||||
CInterlockedIntT( const CInterlockedIntT &rhs ) : m_value( rhs ) {}
|
||||
CInterlockedIntT &operator=( const CInterlockedIntT &rhs ) { m_value.store(rhs.m_value.load()); return *this; }
|
||||
T operator++() { return m_value.fetch_add(1) + 1; }
|
||||
T operator++(int) { return m_value.fetch_add(1); }
|
||||
|
||||
T operator--() { return m_value.fetch_sub(1) - 1; }
|
||||
T operator--(int) { return m_value.fetch_sub(1); }
|
||||
|
||||
bool AssignIf( T conditionValue, T newValue ) { return m_value.compare_exchange_strong(conditionValue, newValue); }
|
||||
|
||||
T operator=( T newValue ) { m_value.store(newValue); return newValue; }
|
||||
|
||||
void operator+=( T add ) { m_value.fetch_add(add); }
|
||||
#else
|
||||
T operator++() { return (T)ThreadInterlockedIncrement( (int *)&m_value ); }
|
||||
T operator++(int) { return operator++() - 1; }
|
||||
|
||||
T operator--() { return (T)ThreadInterlockedDecrement( (long *)&m_value ); }
|
||||
T operator--() { return (T)ThreadInterlockedDecrement( (int *)&m_value ); }
|
||||
T operator--(int) { return operator--() + 1; }
|
||||
|
||||
bool AssignIf( T conditionValue, T newValue ) { return ThreadInterlockedAssignIf( (long *)&m_value, (long)newValue, (long)conditionValue ); }
|
||||
bool AssignIf( T conditionValue, T newValue ) { return ThreadInterlockedAssignIf( (int *)&m_value, (int)newValue, (int)conditionValue ); }
|
||||
|
||||
T operator=( T newValue ) { ThreadInterlockedExchange((long *)&m_value, newValue); return m_value; }
|
||||
T operator=( T newValue ) { ThreadInterlockedExchange((int *)&m_value, newValue); return m_value; }
|
||||
|
||||
void operator+=( T add ) { ThreadInterlockedExchangeAdd( (long *)&m_value, (long)add ); }
|
||||
void operator+=( T add ) { ThreadInterlockedExchangeAdd( (int *)&m_value, (int)add ); }
|
||||
#endif
|
||||
void operator-=( T subtract ) { operator+=( -subtract ); }
|
||||
void operator*=( T multiplier ) {
|
||||
T original, result;
|
||||
@@ -524,7 +577,11 @@ public:
|
||||
T operator-( T rhs ) const { return m_value - rhs; }
|
||||
|
||||
private:
|
||||
#if defined( __arm__ ) || defined( __arm64__ )
|
||||
std::atomic<T> m_value;
|
||||
#else
|
||||
volatile T m_value;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef CInterlockedIntT<int> CInterlockedInt;
|
||||
@@ -544,7 +601,21 @@ public:
|
||||
bool operator!() const { return ( m_value == 0 ); }
|
||||
bool operator==( T *rhs ) const { return ( m_value == rhs ); }
|
||||
bool operator!=( T *rhs ) const { return ( m_value != rhs ); }
|
||||
#if defined( __arm__ ) || defined( __arm64__ )
|
||||
CInterlockedPtr( const CInterlockedPtr &rhs ) : m_value( rhs ) {}
|
||||
CInterlockedPtr &operator=( const CInterlockedPtr &rhs ) { m_value.store(rhs.m_value.load()); return *this; }
|
||||
T *operator++() { return m_value.fetch_add(1) + 1; }
|
||||
T *operator++(int) { return m_value.fetch_add(1); }
|
||||
|
||||
T *operator--() { return m_value.fetch_sub(1) - 1; }
|
||||
T *operator--(int) { return m_value.fetch_sub(1); }
|
||||
|
||||
bool AssignIf( T *conditionValue, T *newValue ) { return m_value.compare_exchange_strong(conditionValue, newValue); }
|
||||
|
||||
T *operator=( T *newValue ) { m_value.store(newValue); return newValue; }
|
||||
|
||||
void operator+=( int add ) { m_value.fetch_add(add); }
|
||||
#else
|
||||
#if defined( PLATFORM_64BITS )
|
||||
T *operator++() { return ((T *)ThreadInterlockedExchangeAdd64( (int64 *)&m_value, sizeof(T) )) + 1; }
|
||||
T *operator++(int) { return (T *)ThreadInterlockedExchangeAdd64( (int64 *)&m_value, sizeof(T) ); }
|
||||
@@ -569,6 +640,7 @@ public:
|
||||
T *operator=( T *newValue ) { ThreadInterlockedExchangePointerToConst( (void const **) &m_value, (void const *) newValue ); return newValue; }
|
||||
|
||||
void operator+=( int add ) { ThreadInterlockedExchangeAdd( (long *)&m_value, add * sizeof(T) ); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void operator-=( int subtract ) { operator+=( -subtract ); }
|
||||
@@ -581,7 +653,11 @@ public:
|
||||
size_t operator-( const CInterlockedPtr<T> &p ) const { return m_value - p.m_value; }
|
||||
|
||||
private:
|
||||
#if defined( __arm__ ) || defined( __arm64__ )
|
||||
std::atomic<T *> m_value;
|
||||
#else
|
||||
T * volatile m_value;
|
||||
#endif
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -708,9 +784,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
FORCEINLINE bool TryLockInline( const uint32 threadId ) volatile
|
||||
FORCEINLINE bool TryLockInline( const uintp threadId ) volatile
|
||||
{
|
||||
if ( threadId != m_ownerID && !ThreadInterlockedAssignIf( (volatile long *)&m_ownerID, (long)threadId, 0 ) )
|
||||
#if PLATFORM_64BITS
|
||||
if ( threadId != m_ownerID && !ThreadInterlockedAssignIf64( &m_ownerID, threadId, 0 ) )
|
||||
#else
|
||||
if ( threadId != m_ownerID && !ThreadInterlockedAssignIf( &m_ownerID, threadId, 0 ) )
|
||||
#endif
|
||||
return false;
|
||||
|
||||
ThreadMemoryBarrier();
|
||||
@@ -718,12 +798,12 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TryLock( const uint32 threadId ) volatile
|
||||
bool TryLock( const uintp threadId ) volatile
|
||||
{
|
||||
return TryLockInline( threadId );
|
||||
}
|
||||
|
||||
PLATFORM_CLASS void Lock( const uint32 threadId, unsigned nSpinSleepTime ) volatile;
|
||||
PLATFORM_CLASS void Lock( const uintp threadId, unsigned nSpinSleepTime ) volatile;
|
||||
|
||||
public:
|
||||
bool TryLock() volatile
|
||||
@@ -743,7 +823,7 @@ public:
|
||||
#endif
|
||||
void Lock( unsigned int nSpinSleepTime = 0 ) volatile
|
||||
{
|
||||
const uint32 threadId = ThreadGetCurrentId();
|
||||
const uintp threadId = ThreadGetCurrentId();
|
||||
|
||||
if ( !TryLockInline( threadId ) )
|
||||
{
|
||||
@@ -779,7 +859,11 @@ public:
|
||||
if ( !m_depth )
|
||||
{
|
||||
ThreadMemoryBarrier();
|
||||
ThreadInterlockedExchange( &m_ownerID, 0 );
|
||||
#if PLATFORM_64BITS
|
||||
ThreadInterlockedExchange64( &m_ownerID, 0 );
|
||||
#else
|
||||
ThreadInterlockedExchange( &m_ownerID, 0 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,10 +876,10 @@ public:
|
||||
bool AssertOwnedByCurrentThread() { return true; }
|
||||
void SetTrace( bool ) {}
|
||||
|
||||
uint32 GetOwnerId() const { return m_ownerID; }
|
||||
uintp GetOwnerId() const { return m_ownerID; }
|
||||
int GetDepth() const { return m_depth; }
|
||||
private:
|
||||
volatile uint32 m_ownerID;
|
||||
volatile uintp m_ownerID;
|
||||
int m_depth;
|
||||
};
|
||||
|
||||
@@ -838,7 +922,7 @@ public:
|
||||
static bool AssertOwnedByCurrentThread() { return true; }
|
||||
static void SetTrace( bool b ) {}
|
||||
|
||||
static uint32 GetOwnerId() { return 0; }
|
||||
static uintp GetOwnerId() { return 0; }
|
||||
static int GetDepth() { return 0; }
|
||||
};
|
||||
|
||||
@@ -1182,11 +1266,7 @@ private:
|
||||
class ALIGN8 PLATFORM_CLASS CThreadSpinRWLock
|
||||
{
|
||||
public:
|
||||
CThreadSpinRWLock()
|
||||
{
|
||||
COMPILE_TIME_ASSERT( sizeof( LockInfo_t ) == sizeof( int64 ) );
|
||||
Assert( (intp)this % 8 == 0 );
|
||||
}
|
||||
CThreadSpinRWLock() { Assert( (intp)this % 8 == 0 ); memset( this, 0, sizeof( *this ) ); }
|
||||
|
||||
bool TryLockForWrite();
|
||||
bool TryLockForRead();
|
||||
@@ -1218,8 +1298,8 @@ private:
|
||||
};
|
||||
|
||||
bool AssignIf( const LockInfo_t &newValue, const LockInfo_t &comperand );
|
||||
bool TryLockForWrite( const uint32 threadId );
|
||||
void SpinLockForWrite( const uint32 threadId );
|
||||
bool TryLockForWrite( const uintp threadId );
|
||||
void SpinLockForWrite( const uintp threadId );
|
||||
|
||||
volatile LockInfo_t m_lockInfo;
|
||||
CInterlockedInt m_nWriters;
|
||||
@@ -1751,10 +1831,16 @@ inline void CThreadRWLock::UnlockRead()
|
||||
|
||||
inline bool CThreadSpinRWLock::AssignIf( const LockInfo_t &newValue, const LockInfo_t &comperand )
|
||||
{
|
||||
#if PLATFORM_64BITS
|
||||
COMPILE_TIME_ASSERT(sizeof(LockInfo_t) == 16);
|
||||
return ThreadInterlockedAssignIf128( (int128 *)&m_lockInfo, *((int128 *)&newValue), *((int128 *)&comperand) );
|
||||
#else
|
||||
COMPILE_TIME_ASSERT(sizeof(LockInfo_t) == 8);
|
||||
return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) );
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool CThreadSpinRWLock::TryLockForWrite( const uint32 threadId )
|
||||
inline bool CThreadSpinRWLock::TryLockForWrite( const uintp threadId )
|
||||
{
|
||||
// In order to grab a write lock, there can be no readers and no owners of the write lock
|
||||
if ( m_lockInfo.m_nReaders > 0 || ( m_lockInfo.m_writerId && m_lockInfo.m_writerId != threadId ) )
|
||||
@@ -1812,7 +1898,7 @@ inline bool CThreadSpinRWLock::TryLockForRead()
|
||||
|
||||
inline void CThreadSpinRWLock::LockForWrite()
|
||||
{
|
||||
const uint32 threadId = ThreadGetCurrentId();
|
||||
const uintp threadId = ThreadGetCurrentId();
|
||||
|
||||
m_nWriters++;
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ typedef struct VCR_s
|
||||
void *lpStartAddress,
|
||||
void *lpParameter,
|
||||
unsigned long dwCreationFlags,
|
||||
unsigned long *lpThreadID );
|
||||
uintp *lpThreadID );
|
||||
|
||||
unsigned long (*Hook_WaitForSingleObject)(
|
||||
void *handle,
|
||||
|
||||
@@ -28,7 +28,7 @@ class CUtlBuffer;
|
||||
//-----------------------------------------------------------------------------
|
||||
// Invalid command handle
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef int CommandHandle_t;
|
||||
typedef intp CommandHandle_t;
|
||||
enum
|
||||
{
|
||||
COMMAND_BUFFER_INVALID_COMMAND_HANDLE = 0
|
||||
@@ -100,11 +100,11 @@ private:
|
||||
};
|
||||
|
||||
// Insert a command into the command queue at the appropriate time
|
||||
void InsertCommandAtAppropriateTime( int hCommand );
|
||||
void InsertCommandAtAppropriateTime( CommandHandle_t hCommand );
|
||||
|
||||
// Insert a command into the command queue
|
||||
// Only happens if it's inserted while processing other commands
|
||||
void InsertImmediateCommand( int hCommand );
|
||||
void InsertImmediateCommand( CommandHandle_t hCommand );
|
||||
|
||||
// Insert a command into the command queue
|
||||
bool InsertCommand( const char *pArgS, int nCommandSize, int nTick );
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
int m_nCurrentTick;
|
||||
int m_nLastTickToProcess;
|
||||
int m_nWaitDelayTicks;
|
||||
int m_hNextCommand;
|
||||
CommandHandle_t m_hNextCommand;
|
||||
int m_nMaxArgSBufferLength;
|
||||
bool m_bIsProcessingCommands;
|
||||
bool m_bWaitEnabled;
|
||||
|
||||
+11
-11
@@ -115,7 +115,7 @@ public:
|
||||
void SetName( const char *setName);
|
||||
|
||||
// gets the name as a unique int
|
||||
int GetNameSymbol() const { return m_iKeyName; }
|
||||
intp GetNameSymbol() const { return m_iKeyName; }
|
||||
|
||||
// File access. Set UsesEscapeSequences true, if resource file/buffer uses Escape Sequences (eg \n, \t)
|
||||
void UsesEscapeSequences(bool state); // default false
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
// Find a keyValue, create it if it is not found.
|
||||
// Set bCreate to true to create the key if it doesn't already exist (which ensures a valid pointer will be returned)
|
||||
KeyValues *FindKey(const char *keyName, bool bCreate = false);
|
||||
KeyValues *FindKey(int keySymbol) const;
|
||||
KeyValues *FindKey(intp keySymbol) const;
|
||||
KeyValues *CreateNewKey(); // creates a new key, with an autogenerated name. name is guaranteed to be an integer, of value 1 higher than the highest other integer key name
|
||||
void AddSubKey( KeyValues *pSubkey ); // Adds a subkey. Make sure the subkey isn't a child of some other keyvalues
|
||||
void RemoveSubKey(KeyValues *subKey); // removes a subkey from the list, DOES NOT DELETE IT
|
||||
@@ -311,7 +311,7 @@ private:
|
||||
void FreeAllocatedValue();
|
||||
void AllocateValueBlock(int size);
|
||||
|
||||
int m_iKeyName; // keyname is a symbol defined in KeyValuesSystem
|
||||
intp m_iKeyName; // keyname is a symbol defined in KeyValuesSystem
|
||||
|
||||
// These are needed out of the union because the API returns string pointers
|
||||
char *m_sValue;
|
||||
@@ -338,22 +338,22 @@ private:
|
||||
private:
|
||||
// Statics to implement the optional growable string table
|
||||
// Function pointers that will determine which mode we are in
|
||||
static int (*s_pfGetSymbolForString)( const char *name, bool bCreate );
|
||||
static const char *(*s_pfGetStringForSymbol)( int symbol );
|
||||
static intp (*s_pfGetSymbolForString)( const char *name, bool bCreate );
|
||||
static const char *(*s_pfGetStringForSymbol)( intp symbol );
|
||||
static CKeyValuesGrowableStringTable *s_pGrowableStringTable;
|
||||
|
||||
public:
|
||||
// Functions that invoke the default behavior
|
||||
static int GetSymbolForStringClassic( const char *name, bool bCreate = true );
|
||||
static const char *GetStringForSymbolClassic( int symbol );
|
||||
static intp GetSymbolForStringClassic( const char *name, bool bCreate = true );
|
||||
static const char *GetStringForSymbolClassic( intp symbol );
|
||||
|
||||
// Functions that use the growable string table
|
||||
static int GetSymbolForStringGrowable( const char *name, bool bCreate = true );
|
||||
static const char *GetStringForSymbolGrowable( int symbol );
|
||||
static intp GetSymbolForStringGrowable( const char *name, bool bCreate = true );
|
||||
static const char *GetStringForSymbolGrowable( intp symbol );
|
||||
|
||||
// Functions to get external access to whichever of the above functions we're going to call.
|
||||
static int CallGetSymbolForString( const char *name, bool bCreate = true ) { return s_pfGetSymbolForString( name, bCreate ); }
|
||||
static const char *CallGetStringForSymbol( int symbol ) { return s_pfGetStringForSymbol( symbol ); }
|
||||
static intp CallGetSymbolForString( const char *name, bool bCreate = true ) { return s_pfGetSymbolForString( name, bCreate ); }
|
||||
static const char *CallGetStringForSymbol( intp symbol ) { return s_pfGetStringForSymbol( symbol ); }
|
||||
};
|
||||
|
||||
typedef KeyValues::AutoDelete KeyValuesAD;
|
||||
|
||||
+15
-15
@@ -225,7 +225,7 @@ public:
|
||||
void WriteByte(int val);
|
||||
void WriteShort(int val);
|
||||
void WriteWord(int val);
|
||||
void WriteLong(long val);
|
||||
void WriteLong(int32 val);
|
||||
void WriteLongLong(int64 val);
|
||||
void WriteFloat(float val);
|
||||
bool WriteBytes( const void *pBuf, int nBytes );
|
||||
@@ -255,7 +255,7 @@ public:
|
||||
|
||||
public:
|
||||
// The current buffer.
|
||||
unsigned long* RESTRICT m_pData;
|
||||
uint32* RESTRICT m_pData;
|
||||
int m_nDataBytes;
|
||||
int m_nDataBits;
|
||||
|
||||
@@ -342,7 +342,7 @@ BITBUF_INLINE void bf_write::WriteOneBitNoCheck(int nValue)
|
||||
else
|
||||
m_pData[m_iCurBit >> 5] &= ~(1u << (m_iCurBit & 31));
|
||||
#else
|
||||
extern unsigned long g_LittleBits[32];
|
||||
extern uint32 g_LittleBits[32];
|
||||
if(nValue)
|
||||
m_pData[m_iCurBit >> 5] |= g_LittleBits[m_iCurBit & 31];
|
||||
else
|
||||
@@ -379,7 +379,7 @@ inline void bf_write::WriteOneBitAt( int iBit, int nValue )
|
||||
else
|
||||
m_pData[iBit >> 5] &= ~(1u << (iBit & 31));
|
||||
#else
|
||||
extern unsigned long g_LittleBits[32];
|
||||
extern uint32 g_LittleBits[32];
|
||||
if(nValue)
|
||||
m_pData[iBit >> 5] |= g_LittleBits[iBit & 31];
|
||||
else
|
||||
@@ -393,7 +393,7 @@ BITBUF_INLINE void bf_write::WriteUBitLong( unsigned int curData, int numbits, b
|
||||
// Make sure it doesn't overflow.
|
||||
if ( bCheckRange && numbits < 32 )
|
||||
{
|
||||
if ( curData >= (unsigned long)(1 << numbits) )
|
||||
if ( curData >= (uint32)(1 << numbits) )
|
||||
{
|
||||
CallErrorHandler( BITBUFERROR_VALUE_OUT_OF_RANGE, GetDebugName() );
|
||||
}
|
||||
@@ -414,8 +414,8 @@ BITBUF_INLINE void bf_write::WriteUBitLong( unsigned int curData, int numbits, b
|
||||
m_iCurBit += numbits;
|
||||
|
||||
// Mask in a dword.
|
||||
Assert( (iDWord*4 + sizeof(long)) <= (unsigned int)m_nDataBytes );
|
||||
unsigned long * RESTRICT pOut = &m_pData[iDWord];
|
||||
Assert( (iDWord*4 + sizeof(int32)) <= (unsigned int)m_nDataBytes );
|
||||
uint32 * RESTRICT pOut = &m_pData[iDWord];
|
||||
|
||||
// Rotate data into dword alignment
|
||||
curData = (curData << iCurBitMasked) | (curData >> (32 - iCurBitMasked));
|
||||
@@ -427,8 +427,8 @@ BITBUF_INLINE void bf_write::WriteUBitLong( unsigned int curData, int numbits, b
|
||||
|
||||
// Only look beyond current word if necessary (avoid access violation)
|
||||
int i = mask2 & 1;
|
||||
unsigned long dword1 = LoadLittleDWord( pOut, 0 );
|
||||
unsigned long dword2 = LoadLittleDWord( pOut, i );
|
||||
uint32 dword1 = LoadLittleDWord( pOut, 0 );
|
||||
uint32 dword2 = LoadLittleDWord( pOut, i );
|
||||
|
||||
// Drop bits into place
|
||||
dword1 ^= ( mask1 & ( curData ^ dword1 ) );
|
||||
@@ -467,7 +467,7 @@ BITBUF_INLINE void bf_write::WriteBitFloat(float val)
|
||||
{
|
||||
int32 intVal;
|
||||
|
||||
Assert(sizeof(long) == sizeof(float));
|
||||
Assert(sizeof(int32) == sizeof(float));
|
||||
Assert(sizeof(float) == 4);
|
||||
|
||||
Q_memcpy( &intVal, &val, sizeof(intVal));
|
||||
@@ -603,7 +603,7 @@ public:
|
||||
BITBUF_INLINE int ReadByte() { return ReadUBitLong(8); }
|
||||
BITBUF_INLINE int ReadShort() { return (short)ReadUBitLong(16); }
|
||||
BITBUF_INLINE int ReadWord() { return ReadUBitLong(16); }
|
||||
BITBUF_INLINE long ReadLong() { return ReadUBitLong(32); }
|
||||
BITBUF_INLINE int32 ReadLong() { return ReadUBitLong(32); }
|
||||
int64 ReadLongLong();
|
||||
float ReadFloat();
|
||||
bool ReadBytes(void *pOut, int nBytes);
|
||||
@@ -728,7 +728,7 @@ inline bool bf_read::CheckForOverflow(int nBits)
|
||||
inline int bf_read::ReadOneBitNoCheck()
|
||||
{
|
||||
#if VALVE_LITTLE_ENDIAN
|
||||
unsigned int value = ((unsigned long * RESTRICT)m_pData)[m_iCurBit >> 5] >> (m_iCurBit & 31);
|
||||
unsigned int value = ((uint32 * RESTRICT)m_pData)[m_iCurBit >> 5] >> (m_iCurBit & 31);
|
||||
#else
|
||||
unsigned char value = m_pData[m_iCurBit >> 3] >> (m_iCurBit & 7);
|
||||
#endif
|
||||
@@ -787,12 +787,12 @@ BITBUF_INLINE unsigned int bf_read::ReadUBitLong( int numbits ) RESTRICT
|
||||
#if __i386__
|
||||
unsigned int bitmask = (2 << (numbits-1)) - 1;
|
||||
#else
|
||||
extern unsigned long g_ExtraMasks[33];
|
||||
extern uint32 g_ExtraMasks[33];
|
||||
unsigned int bitmask = g_ExtraMasks[numbits];
|
||||
#endif
|
||||
|
||||
unsigned int dw1 = LoadLittleDWord( (unsigned long* RESTRICT)m_pData, iWordOffset1 ) >> iStartBit;
|
||||
unsigned int dw2 = LoadLittleDWord( (unsigned long* RESTRICT)m_pData, iWordOffset2 ) << (32 - iStartBit);
|
||||
unsigned int dw1 = LoadLittleDWord( (uint32* RESTRICT)m_pData, iWordOffset1 ) >> iStartBit;
|
||||
unsigned int dw2 = LoadLittleDWord( (uint32* RESTRICT)m_pData, iWordOffset2 ) << (32 - iStartBit);
|
||||
|
||||
return (dw1 | dw2) & bitmask;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ private:
|
||||
|
||||
inline unsigned short CDataManagerBase::FromHandle( memhandle_t handle )
|
||||
{
|
||||
unsigned int fullWord = (unsigned int)handle;
|
||||
uintp fullWord = (uintp)handle;
|
||||
unsigned short serial = fullWord>>16;
|
||||
unsigned short index = fullWord & 0xFFFF;
|
||||
index--;
|
||||
|
||||
@@ -193,8 +193,8 @@ public:
|
||||
class CRefMT
|
||||
{
|
||||
public:
|
||||
static int Increment( int *p) { return ThreadInterlockedIncrement( (long *)p ); }
|
||||
static int Decrement( int *p) { return ThreadInterlockedDecrement( (long *)p ); }
|
||||
static int Increment( int *p) { return ThreadInterlockedIncrement( (int32 *)p ); }
|
||||
static int Decrement( int *p) { return ThreadInterlockedDecrement( (int32 *)p ); }
|
||||
};
|
||||
|
||||
class CRefST
|
||||
|
||||
@@ -189,6 +189,7 @@ public:
|
||||
unsigned int GetUnsignedInt( );
|
||||
float GetFloat( );
|
||||
double GetDouble( );
|
||||
void * GetPtr();
|
||||
template <size_t maxLenInChars> void GetString( char( &pString )[maxLenInChars] )
|
||||
{
|
||||
GetStringInternal( pString, maxLenInChars );
|
||||
@@ -278,6 +279,7 @@ public:
|
||||
void PutUnsignedInt( unsigned int u );
|
||||
void PutFloat( float f );
|
||||
void PutDouble( double d );
|
||||
void PutPtr( void * ); // Writes the pointer, not the pointed to
|
||||
void PutString( const char* pString );
|
||||
void Put( const void* pMem, int size );
|
||||
|
||||
@@ -757,6 +759,18 @@ inline float CUtlBuffer::GetFloat( )
|
||||
return f;
|
||||
}
|
||||
|
||||
inline void *CUtlBuffer::GetPtr( )
|
||||
{
|
||||
void *p;
|
||||
// LEGACY WARNING: in text mode, PutPtr writes 32 bit pointers in hex, while GetPtr reads 32 or 64 bit pointers in decimal
|
||||
#ifndef PLATFORM_64BITS
|
||||
p = ( void* )GetUnsignedInt();
|
||||
#else
|
||||
p = ( void* )GetInt64();
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
inline double CUtlBuffer::GetDouble( )
|
||||
{
|
||||
double d;
|
||||
@@ -986,6 +1000,19 @@ inline void CUtlBuffer::PutDouble( double d )
|
||||
PutType( d, "%f" );
|
||||
}
|
||||
|
||||
inline void CUtlBuffer::PutPtr( void *p )
|
||||
{
|
||||
// LEGACY WARNING: in text mode, PutPtr writes 32 bit pointers in hex, while GetPtr reads 32 or 64 bit pointers in decimal
|
||||
if (!IsText())
|
||||
{
|
||||
PutTypeBin( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf( "0x%p", p );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Am I a text buffer?
|
||||
|
||||
@@ -59,13 +59,21 @@ public:
|
||||
private:
|
||||
struct HandleType_t
|
||||
{
|
||||
// MoeMod : use union to fix strict alias bug
|
||||
HandleType_t( unsigned int i, unsigned int s ) : nIndex( i ), nSerial( s )
|
||||
{
|
||||
Assert( i < ( 1 << HandleBits ) );
|
||||
Assert( s < ( 1 << ( 31 - HandleBits ) ) );
|
||||
}
|
||||
unsigned int nIndex : HandleBits;
|
||||
unsigned int nSerial : 31 - HandleBits;
|
||||
HandleType_t( UtlHandle_t handle ) : handle(handle) {}
|
||||
|
||||
union {
|
||||
UtlHandle_t handle;
|
||||
struct {
|
||||
unsigned int nIndex : HandleBits;
|
||||
unsigned int nSerial : 31 - HandleBits;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
struct EntryType_t
|
||||
@@ -186,7 +194,7 @@ bool CUtlHandleTable<T, HandleBits>::IsHandleValid( UtlHandle_t handle ) const
|
||||
return false;
|
||||
|
||||
unsigned int nIndex = GetListIndex( handle );
|
||||
AssertOnce( nIndex < ( unsigned int )m_list.Count() );
|
||||
//AssertOnce( nIndex < ( unsigned int )m_list.Count() );
|
||||
if ( nIndex >= ( unsigned int )m_list.Count() )
|
||||
return false;
|
||||
|
||||
@@ -241,20 +249,26 @@ int CUtlHandleTable<T, HandleBits>::GetIndexFromHandle( UtlHandle_t h ) const
|
||||
template< class T, int HandleBits >
|
||||
unsigned int CUtlHandleTable<T, HandleBits>::GetSerialNumber( UtlHandle_t handle )
|
||||
{
|
||||
return ( ( HandleType_t* )&handle )->nSerial;
|
||||
//return ( ( HandleType_t* )&handle )->nSerial;
|
||||
//return (handle >> HandleBits) & ((1 << (32 - HandleBits)) - 1);
|
||||
return HandleType_t(handle).nSerial;
|
||||
}
|
||||
|
||||
template< class T, int HandleBits >
|
||||
unsigned int CUtlHandleTable<T, HandleBits>::GetListIndex( UtlHandle_t handle )
|
||||
{
|
||||
return ( ( HandleType_t* )&handle )->nIndex;
|
||||
//return ( ( HandleType_t* )&handle )->nIndex;
|
||||
//return handle & ((1 << HandleBits) - 1);
|
||||
return HandleType_t(handle).nIndex;
|
||||
}
|
||||
|
||||
template< class T, int HandleBits >
|
||||
UtlHandle_t CUtlHandleTable<T, HandleBits>::CreateHandle( unsigned int nSerial, unsigned int nIndex )
|
||||
{
|
||||
HandleType_t h( nIndex, nSerial );
|
||||
return *( UtlHandle_t* )&h;
|
||||
//return *( UtlHandle_t* )&h;
|
||||
//return (nIndex & ((1 << HandleBits) - 1)) | (nSerial << HandleBits);
|
||||
return h.handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +282,7 @@ const typename CUtlHandleTable<T, HandleBits>::EntryType_t *CUtlHandleTable<T, H
|
||||
return NULL;
|
||||
|
||||
unsigned int nIndex = GetListIndex( handle );
|
||||
Assert( nIndex < ( unsigned int )m_list.Count() );
|
||||
//Assert( nIndex < ( unsigned int )m_list.Count() );
|
||||
if ( nIndex >= ( unsigned int )m_list.Count() )
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -461,7 +461,7 @@ inline void CUtlHash<Data, C, K>::Log( const char *filename )
|
||||
// Number of buckets must be a power of 2.
|
||||
// Key must be 32-bits (unsigned int).
|
||||
//
|
||||
typedef int UtlHashFastHandle_t;
|
||||
typedef intp UtlHashFastHandle_t;
|
||||
|
||||
#define UTLHASH_POOL_SCALAR 2
|
||||
|
||||
@@ -617,7 +617,7 @@ template<class Data, class HashFuncs> inline UtlHashFastHandle_t CUtlHashFast<Da
|
||||
template<class Data, class HashFuncs> inline UtlHashFastHandle_t CUtlHashFast<Data,HashFuncs>::FastInsert( unsigned int uiKey, const Data &data )
|
||||
{
|
||||
// Get a new element from the pool.
|
||||
int iHashData = m_aDataPool.Alloc( true );
|
||||
intp iHashData = m_aDataPool.Alloc( true );
|
||||
HashFastData_t *pHashData = &m_aDataPool[iHashData];
|
||||
if ( !pHashData )
|
||||
return InvalidHandle();
|
||||
@@ -671,7 +671,7 @@ template<class Data, class HashFuncs> inline UtlHashFastHandle_t CUtlHashFast<Da
|
||||
// hash the "key" - get the correct hash table "bucket"
|
||||
int iBucket = HashFuncs::Hash( uiKey, m_uiBucketMask );
|
||||
|
||||
for ( int iElement = m_aBuckets[iBucket]; iElement != m_aDataPool.InvalidIndex(); iElement = m_aDataPool.Next( iElement ) )
|
||||
for ( intp iElement = m_aBuckets[iBucket]; iElement != m_aDataPool.InvalidIndex(); iElement = m_aDataPool.Next( iElement ) )
|
||||
{
|
||||
if ( m_aDataPool[iElement].m_uiKey == uiKey )
|
||||
return iElement;
|
||||
@@ -719,7 +719,7 @@ template<class Data, class HashFuncs> inline Data const &CUtlHashFast<Data,HashF
|
||||
// Number of buckets must be a power of 2.
|
||||
// Key must be 32-bits (unsigned int).
|
||||
//
|
||||
typedef int UtlHashFixedHandle_t;
|
||||
typedef intp UtlHashFixedHandle_t;
|
||||
|
||||
template <int NUM_BUCKETS>
|
||||
class CUtlHashFixedGenericHash
|
||||
@@ -753,7 +753,7 @@ public:
|
||||
void Purge( void );
|
||||
|
||||
// Invalid handle.
|
||||
static UtlHashFixedHandle_t InvalidHandle( void ) { return ( UtlHashFixedHandle_t )~0; }
|
||||
static UtlHashFixedHandle_t InvalidHandle( void ) { return ( UtlHashFixedHandle_t )-1; }
|
||||
|
||||
// Size.
|
||||
int Count( void );
|
||||
@@ -858,7 +858,7 @@ template<class Data, int NUM_BUCKETS, class HashFuncs> inline UtlHashFixedHandle
|
||||
pHashData->m_Data = data;
|
||||
|
||||
m_nElements++;
|
||||
return (UtlHashFixedHandle_t)pHashData;
|
||||
return (UtlHashFixedHandle_t)(intp)pHashData;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -895,7 +895,7 @@ template<class Data, int NUM_BUCKETS, class HashFuncs> inline UtlHashFixedHandle
|
||||
for ( UtlPtrLinkedListIndex_t iElement = bucket.Head(); iElement != bucket.InvalidIndex(); iElement = bucket.Next( iElement ) )
|
||||
{
|
||||
if ( bucket[iElement].m_uiKey == uiKey )
|
||||
return (UtlHashFixedHandle_t)iElement;
|
||||
return (UtlHashFixedHandle_t)(intp)iElement;
|
||||
}
|
||||
|
||||
return InvalidHandle();
|
||||
|
||||
@@ -389,15 +389,16 @@ private:
|
||||
|
||||
|
||||
// this is kind of ugly, but until C++ gets templatized typedefs in C++0x, it's our only choice
|
||||
// MoeMod : CUtlFixedMemory uses intp as index type
|
||||
template < class T >
|
||||
class CUtlFixedLinkedList : public CUtlLinkedList< T, int, true, int, CUtlFixedMemory< UtlLinkedListElem_t< T, int > > >
|
||||
class CUtlFixedLinkedList : public CUtlLinkedList< T, intp, true, intp, CUtlFixedMemory< UtlLinkedListElem_t< T, intp > > >
|
||||
{
|
||||
public:
|
||||
CUtlFixedLinkedList( int growSize = 0, int initSize = 0 )
|
||||
: CUtlLinkedList< T, int, true, int, CUtlFixedMemory< UtlLinkedListElem_t< T, int > > >( growSize, initSize ) {}
|
||||
: CUtlLinkedList< T, intp, true, intp, CUtlFixedMemory< UtlLinkedListElem_t< T, intp > > >( growSize, initSize ) {}
|
||||
|
||||
typedef CUtlLinkedList< T, int, true, int, CUtlFixedMemory< UtlLinkedListElem_t< T, int > > > BaseClass;
|
||||
bool IsValidIndex( int i ) const
|
||||
typedef CUtlLinkedList< T, intp, true, intp, CUtlFixedMemory< UtlLinkedListElem_t< T, intp > > > BaseClass;
|
||||
bool IsValidIndex( intp i ) const
|
||||
{
|
||||
if ( !BaseClass::Memory().IsIdxValid( i ) )
|
||||
return false;
|
||||
@@ -414,7 +415,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
int MaxElementIndex() const { Assert( 0 ); return BaseClass::InvalidIndex(); } // fixedmemory containers don't support iteration from 0..maxelements-1
|
||||
intp MaxElementIndex() const { Assert( 0 ); return BaseClass::InvalidIndex(); } // fixedmemory containers don't support iteration from 0..maxelements-1
|
||||
void ResetDbgInfo() {}
|
||||
};
|
||||
|
||||
@@ -439,7 +440,7 @@ CUtlLinkedList<T,S,ML,I,M>::CUtlLinkedList( int growSize, int initSize ) :
|
||||
m_Memory( growSize, initSize ), m_LastAlloc( m_Memory.InvalidIterator() )
|
||||
{
|
||||
// Prevent signed non-int datatypes
|
||||
COMPILE_TIME_ASSERT( sizeof(S) == 4 || ( ( (S)-1 ) > 0 ) );
|
||||
COMPILE_TIME_ASSERT( sizeof(S) == sizeof(M::InvalidIndex()) || ( ( (S)-1 ) > 0 ) );
|
||||
ConstructList();
|
||||
ResetDbgInfo();
|
||||
}
|
||||
@@ -797,7 +798,7 @@ inline I CUtlLinkedList<T,S,ML,I,M>::AddToHead( )
|
||||
template <class T, class S, bool ML, class I, class M>
|
||||
inline I CUtlLinkedList<T,S,ML,I,M>::AddToTail( )
|
||||
{
|
||||
return InsertBefore( InvalidIndex() );
|
||||
return InsertBefore( InvalidIndex() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
+8
-8
@@ -25,12 +25,12 @@
|
||||
class IFileReadBinary
|
||||
{
|
||||
public:
|
||||
virtual int open( const char *pFileName ) = 0;
|
||||
virtual int read( void *pOutput, int size, int file ) = 0;
|
||||
virtual void close( int file ) = 0;
|
||||
virtual void seek( int file, int pos ) = 0;
|
||||
virtual unsigned int tell( int file ) = 0;
|
||||
virtual unsigned int size( int file ) = 0;
|
||||
virtual intp open( const char *pFileName ) = 0;
|
||||
virtual int read( void *pOutput, int size, intp file ) = 0;
|
||||
virtual void close( intp file ) = 0;
|
||||
virtual void seek( intp file, int pos ) = 0;
|
||||
virtual unsigned int tell( intp file ) = 0;
|
||||
virtual unsigned int size( intp file ) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
const InFileRIFF & operator=( const InFileRIFF & );
|
||||
|
||||
IFileReadBinary &m_io;
|
||||
int m_file;
|
||||
intp m_file;
|
||||
unsigned int m_riffName;
|
||||
unsigned int m_riffSize;
|
||||
};
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
const OutFileRIFF & operator=( const OutFileRIFF & );
|
||||
|
||||
IFileWriteBinary &m_io;
|
||||
int m_file;
|
||||
intp m_file;
|
||||
unsigned int m_riffName;
|
||||
unsigned int m_riffSize;
|
||||
unsigned int m_nNamePos;
|
||||
|
||||
@@ -249,7 +249,7 @@ struct TOGL_CLASS IDirect3DQuery9 : public IDirect3DResource9 //was IUnknown
|
||||
GLMContext *m_ctx;
|
||||
CGLMQuery *m_query;
|
||||
|
||||
uint m_nIssueStartThreadID, m_nIssueEndThreadID;
|
||||
uintp m_nIssueStartThreadID, m_nIssueEndThreadID;
|
||||
uint m_nIssueStartDrawCallIndex, m_nIssueEndDrawCallIndex;
|
||||
uint m_nIssueStartFrameIndex, m_nIssueEndFrameIndex;
|
||||
uint m_nIssueStartQueryCreationCounter, m_nIssueEndQueryCreationCounter;
|
||||
@@ -373,7 +373,7 @@ struct RenderTargetState_t
|
||||
|
||||
static inline bool LessFunc( const RenderTargetState_t &lhs, const RenderTargetState_t &rhs )
|
||||
{
|
||||
COMPILE_TIME_ASSERT( sizeof( lhs.m_pRenderTargets[0] ) == sizeof( uint32 ) );
|
||||
COMPILE_TIME_ASSERT( sizeof( lhs.m_pRenderTargets[0] ) == sizeof( uintp ) );
|
||||
uint64 lhs0 = reinterpret_cast<const uint64 *>(lhs.m_pRenderTargets)[0];
|
||||
uint64 rhs0 = reinterpret_cast<const uint64 *>(rhs.m_pRenderTargets)[0];
|
||||
if ( lhs0 < rhs0 )
|
||||
@@ -563,7 +563,7 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown
|
||||
|
||||
void TOGLMETHODCALLTYPE AcquireThreadOwnership( );
|
||||
void TOGLMETHODCALLTYPE ReleaseThreadOwnership( );
|
||||
inline DWORD TOGLMETHODCALLTYPE GetCurrentOwnerThreadId() const { return m_ctx->m_nCurOwnerThreadId; }
|
||||
inline uintp TOGLMETHODCALLTYPE GetCurrentOwnerThreadId() const { return m_ctx->m_nCurOwnerThreadId; }
|
||||
|
||||
FORCEINLINE void TOGLMETHODCALLTYPE SetMaxUsedVertexShaderConstantsHint( uint nMaxReg );
|
||||
void TOGLMETHODCALLTYPE SetMaxUsedVertexShaderConstantsHintNonInline( uint nMaxReg );
|
||||
|
||||
@@ -1534,7 +1534,7 @@ class GLMContext
|
||||
#endif
|
||||
|
||||
FORCEINLINE void SetMaxUsedVertexShaderConstantsHint( uint nMaxConstants );
|
||||
FORCEINLINE DWORD GetCurrentOwnerThreadId() const { return m_nCurOwnerThreadId; }
|
||||
FORCEINLINE uintp GetCurrentOwnerThreadId() const { return m_nCurOwnerThreadId; }
|
||||
|
||||
protected:
|
||||
friend class GLMgr; // only GLMgr can make GLMContext objects
|
||||
@@ -1663,7 +1663,7 @@ class GLMContext
|
||||
// members------------------------------------------
|
||||
|
||||
// context
|
||||
DWORD m_nCurOwnerThreadId;
|
||||
uintp m_nCurOwnerThreadId;
|
||||
uint m_nThreadOwnershipReleaseCounter;
|
||||
|
||||
bool m_bUseSamplerObjects;
|
||||
|
||||
@@ -563,7 +563,7 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown
|
||||
|
||||
void TOGLMETHODCALLTYPE AcquireThreadOwnership( );
|
||||
void TOGLMETHODCALLTYPE ReleaseThreadOwnership( );
|
||||
inline DWORD TOGLMETHODCALLTYPE GetCurrentOwnerThreadId() const { return m_ctx->m_nCurOwnerThreadId; }
|
||||
inline uintp TOGLMETHODCALLTYPE GetCurrentOwnerThreadId() const { return m_ctx->m_nCurOwnerThreadId; }
|
||||
|
||||
FORCEINLINE void TOGLMETHODCALLTYPE SetMaxUsedVertexShaderConstantsHint( uint nMaxReg );
|
||||
void TOGLMETHODCALLTYPE SetMaxUsedVertexShaderConstantsHintNonInline( uint nMaxReg );
|
||||
|
||||
@@ -1448,7 +1448,7 @@ class GLMContext
|
||||
#endif
|
||||
|
||||
FORCEINLINE void SetMaxUsedVertexShaderConstantsHint( uint nMaxConstants );
|
||||
FORCEINLINE DWORD GetCurrentOwnerThreadId() const { return m_nCurOwnerThreadId; }
|
||||
FORCEINLINE uintp GetCurrentOwnerThreadId() const { return m_nCurOwnerThreadId; }
|
||||
|
||||
protected:
|
||||
friend class GLMgr; // only GLMgr can make GLMContext objects
|
||||
@@ -1573,7 +1573,7 @@ class GLMContext
|
||||
// members------------------------------------------
|
||||
|
||||
// context
|
||||
DWORD m_nCurOwnerThreadId;
|
||||
uintp m_nCurOwnerThreadId;
|
||||
uint m_nThreadOwnershipReleaseCounter;
|
||||
|
||||
bool m_bUseSamplerObjects;
|
||||
|
||||
+10
-2
@@ -39,6 +39,14 @@ typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long ulong;
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
typedef long long intp;
|
||||
typedef unsigned long long uintp;
|
||||
#else
|
||||
typedef int intp;
|
||||
typedef unsigned int uintp;
|
||||
#endif
|
||||
|
||||
#ifndef _WCHAR_T_DEFINED
|
||||
// DAL - wchar_t is a built in define in gcc 3.2 with a size of 4 bytes
|
||||
#if !defined( __x86_64__ ) && !defined( __WCHAR_TYPE__ )
|
||||
@@ -54,7 +62,7 @@ namespace vgui
|
||||
{
|
||||
// handle to an internal vgui panel
|
||||
// this is the only handle to a panel that is valid across dll boundaries
|
||||
typedef unsigned int VPANEL;
|
||||
typedef uintp VPANEL;
|
||||
|
||||
// handles to vgui objects
|
||||
// NULL values signify an invalid value
|
||||
@@ -63,7 +71,7 @@ typedef unsigned long HScheme;
|
||||
typedef unsigned long HTexture;
|
||||
typedef unsigned long HCursor;
|
||||
typedef unsigned long HPanel;
|
||||
const HPanel INVALID_PANEL = 0xffffffff;
|
||||
const HPanel INVALID_PANEL = (HPanel)-1;
|
||||
typedef unsigned long HFont;
|
||||
const HFont INVALID_FONT = 0; // the value of an invalid font handle
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
}
|
||||
|
||||
KeyValues *kv;
|
||||
unsigned int userData;
|
||||
uintp userData;
|
||||
KeyValues *m_pDragData;
|
||||
bool m_bImage;
|
||||
int m_nImageIndex;
|
||||
@@ -115,17 +115,17 @@ public:
|
||||
// DATA HANDLING
|
||||
// data->GetName() is used to uniquely identify an item
|
||||
// data sub items are matched against column header name to be used in the table
|
||||
virtual int AddItem(const KeyValues *data, unsigned int userData, bool bScrollToItem, bool bSortOnAdd); // Takes a copy of the data for use in the table. Returns the index the item is at.
|
||||
virtual int AddItem(const KeyValues *data, uintp userData, bool bScrollToItem, bool bSortOnAdd); // Takes a copy of the data for use in the table. Returns the index the item is at.
|
||||
void SetItemDragData( int itemID, const KeyValues *data ); // Makes a copy of the keyvalues to store in the table. Used when dragging from the table. Only used if the caller enables drag support
|
||||
virtual int GetItemCount( void ); // returns the number of VISIBLE items
|
||||
virtual int GetItem(const char *itemName); // gets the row index of an item by name (data->GetName())
|
||||
virtual KeyValues *GetItem(int itemID); // returns pointer to data the row holds
|
||||
virtual int GetItemCurrentRow(int itemID); // returns -1 if invalid index or item not visible
|
||||
virtual int GetItemIDFromRow(int currentRow); // returns -1 if invalid row
|
||||
virtual unsigned int GetItemUserData(int itemID);
|
||||
virtual uintp GetItemUserData(int itemID);
|
||||
virtual ListPanelItem *GetItemData(int itemID);
|
||||
virtual void SetUserData( int itemID, unsigned int userData );
|
||||
virtual int GetItemIDFromUserData( unsigned int userData );
|
||||
virtual void SetUserData( int itemID, uintp userData );
|
||||
virtual int GetItemIDFromUserData( uintp userData );
|
||||
virtual void ApplyItemChanges(int itemID); // applies any changes to the data, performed by modifying the return of GetItem() above
|
||||
virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items)
|
||||
virtual void RereadAllItems(); // updates the view with the new data
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include "vstdlib/vstdlib.h"
|
||||
|
||||
// handle to a KeyValues key name symbol
|
||||
typedef int HKeySymbol;
|
||||
#define INVALID_KEY_SYMBOL (-1)
|
||||
typedef intp HKeySymbol;
|
||||
#define INVALID_KEY_SYMBOL (HKeySymbol)(-1)
|
||||
|
||||
class IBaseFileSystem;
|
||||
class KeyValues;
|
||||
|
||||
@@ -1147,7 +1147,7 @@ private:
|
||||
// Raw thread launching
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
inline unsigned FunctorExecuteThread( void *pParam )
|
||||
inline uintp FunctorExecuteThread( void *pParam )
|
||||
{
|
||||
CFunctor *pFunctor = (CFunctor *)pParam;
|
||||
(*pFunctor)();
|
||||
|
||||
Reference in New Issue
Block a user