Skip to content

Commit 9ee21ec

Browse files
committed
amd64: fix multithread, fix vgui, fix physmodels
1 parent 01413fd commit 9ee21ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5665
-2454
lines changed

common/GameUI/scriptobject.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "filesystem.h"
1616
#include "tier1/convar.h"
1717
#include "cdll_int.h"
18+
#include "vcrmode.h"
1819

1920
// memdbgon must be the last include file in a .cpp file!!!
2021
#include "tier0/memdbgon.h"
@@ -1150,4 +1151,4 @@ void CInfoDescription::WriteFileHeader( FileHandle_t fp )
11501151
g_pFullFileSystem->FPrintf( fp, "//\r\n//\r\n// Cvar\t-\tSetting\r\n\r\n" );
11511152
}
11521153

1153-
//-----------------------------------------------------------------------------
1154+
//-----------------------------------------------------------------------------

datacache/mdlcache.cpp

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,39 +1973,18 @@ studiohdr_t *CMDLCache::UnserializeMDL( MDLHandle_t handle, void *pData, int nDa
19731973

19741974
// critical! store a back link to our data
19751975
// this is fetched when re-establishing dependent cached data (vtx/vvd)
1976-
#ifndef PLATFORM_64BITS
1977-
pStudioHdrIn->SetVirtualModel( MDLHandleToVirtual( handle ) );
1978-
#endif
1976+
pStudioHdrIn->SetVirtualModel( MDLHandleToVirtual( handle ) );
19791977

19801978
MdlCacheMsg( "MDLCache: Alloc studiohdr %s\n", GetModelName( handle ) );
19811979

19821980
// allocate cache space
19831981
MemAlloc_PushAllocDbgInfo( "Models:StudioHdr", 0);
1984-
#ifdef PLATFORM_64BITS
1985-
studiohdr_t *pHdr = (studiohdr_t *)AllocData( MDLCACHE_STUDIOHDR, pStudioHdrIn->length + sizeof(studiohdr_shim64_index) );
1986-
#else
19871982
studiohdr_t *pHdr = (studiohdr_t *)AllocData( MDLCACHE_STUDIOHDR, pStudioHdrIn->length );
1988-
#endif
19891983
MemAlloc_PopAllocDbgInfo();
19901984
if ( !pHdr )
19911985
return NULL;
19921986

1993-
#ifdef PLATFORM_64BITS
1994-
// MoeMod : fix shim64 index
1995-
studiohdr_shim64_index *pHdrIndex = (studiohdr_shim64_index *)(((byte *)pHdr)+ pStudioHdrIn->length);
1996-
pHdrIndex->virtualModel = nullptr;
1997-
pHdrIndex->animblockModel = nullptr;
1998-
pHdrIndex->pVertexBase = nullptr;
1999-
pHdrIndex->pIndexBase = nullptr;
2000-
pStudioHdrIn->index_ptr_virtualModel = (byte *)&pHdrIndex->virtualModel - (byte *)pHdr;
2001-
pStudioHdrIn->index_ptr_animblockModel = (byte *)&pHdrIndex->animblockModel - (byte *)pHdr;
2002-
pStudioHdrIn->index_ptr_pVertexBase = (byte *)&pHdrIndex->pVertexBase - (byte *)pHdr;
2003-
pStudioHdrIn->index_ptr_pIndexBase = (byte *)&pHdrIndex->pIndexBase - (byte *)pHdr;
2004-
pStudioHdrIn->SetVirtualModel( MDLHandleToVirtual( handle ) );
2005-
CacheData( &m_MDLDict[handle]->m_MDLCache, pHdr, pStudioHdrIn->length + sizeof(studiohdr_shim64_index), GetModelName( handle ), MDLCACHE_STUDIOHDR, MakeCacheID( handle, MDLCACHE_STUDIOHDR) );
2006-
#else
20071987
CacheData( &m_MDLDict[handle]->m_MDLCache, pHdr, pStudioHdrIn->length, GetModelName( handle ), MDLCACHE_STUDIOHDR, MakeCacheID( handle, MDLCACHE_STUDIOHDR) );
2008-
#endif
20091988

20101989
if ( mod_lock_mdls_on_load.GetBool() )
20111990
{
@@ -2103,27 +2082,7 @@ bool CMDLCache::ReadMDLFile( MDLHandle_t handle, const char *pMDLFileName, CUtlB
21032082

21042083
// critical! store a back link to our data
21052084
// this is fetched when re-establishing dependent cached data (vtx/vvd)
2106-
#if PLATFORM_64BITS
2107-
int length = buf.Size();
2108-
{
2109-
studiohdr_shim64_index shim;
2110-
buf.Put( &shim, sizeof(shim) );
2111-
}
2112-
studiohdr_shim64_index *pHdrIndex = (studiohdr_shim64_index *)(((byte *)buf.PeekGet())+ length);
2113-
pStudioHdr = (studiohdr_t*)buf.PeekGet();
2114-
2115-
pHdrIndex->virtualModel = nullptr;
2116-
pHdrIndex->animblockModel = nullptr;
2117-
pHdrIndex->pVertexBase = nullptr;
2118-
pHdrIndex->pIndexBase = nullptr;
2119-
pStudioHdr->index_ptr_virtualModel = (byte *)&pHdrIndex->virtualModel - (byte *)pStudioHdr;
2120-
pStudioHdr->index_ptr_animblockModel = (byte *)&pHdrIndex->animblockModel - (byte *)pStudioHdr;
2121-
pStudioHdr->index_ptr_pVertexBase = (byte *)&pHdrIndex->pVertexBase - (byte *)pStudioHdr;
2122-
pStudioHdr->index_ptr_pIndexBase = (byte *)&pHdrIndex->pIndexBase - (byte *)pStudioHdr;
2123-
pStudioHdr->SetVirtualModel( MDLHandleToVirtual( handle ) );
2124-
#else
2125-
pStudioHdr->SetVirtualModel( MDLHandleToVirtual( handle ) );
2126-
#endif
2085+
pStudioHdr->SetVirtualModel( MDLHandleToVirtual( handle ) );
21272086

21282087
// Make sure all dependent files are valid
21292088
if ( !VerifyHeaders( pStudioHdr ) )

engine/cmodel_bsp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ bool CollisionBSPData_Load( const char *pName, CCollisionBSPData *pBSPData )
288288
CollisionBSPData_LoadPhysics( pBSPData );
289289

290290
COM_TimestampedLog( " CollisionBSPData_LoadDispInfo" );
291-
CollisionBSPData_LoadDispInfo( pBSPData );
291+
CollisionBSPData_LoadDispInfo( pBSPData );
292292

293293
return true;
294294
}

engine/console.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ Handles cursor positioning, line wrapping, etc
479479
*/
480480
static bool g_fColorPrintf = false;
481481
static bool g_bInColorPrint = false;
482-
extern CThreadLocalInt<> g_bInSpew;
482+
extern CTHREADLOCALINT g_bInSpew;
483483

484484
void Con_Printf( const char *fmt, ... );
485485

engine/download.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,14 +924,14 @@ void CDownloadManager::StartNewDownload()
924924
m_lastPercent = 0;
925925

926926
// Start the thread
927-
uintp threadID;
927+
uintp threadID;
928928
VCRHook_CreateThread(NULL, 0,
929929
#ifdef POSIX
930930
(void *)
931931
#endif
932932
DownloadThread, m_activeRequest, 0, &threadID );
933933

934-
ThreadDetach( ( ThreadHandle_t )threadID );
934+
ReleaseThreadHandle( ( ThreadHandle_t )threadID );
935935
}
936936
else
937937
{
@@ -1072,14 +1072,14 @@ class CDownloadSystem : public IDownloadSystem
10721072
public:
10731073
virtual uintp CreateDownloadThread( RequestContext_t *pContext )
10741074
{
1075-
uintp nThreadID;
1075+
uintp nThreadID;
10761076
VCRHook_CreateThread(NULL, 0,
10771077
#ifdef POSIX
10781078
(void*)
10791079
#endif
10801080
DownloadThread, pContext, 0, (uintp *)&nThreadID );
10811081

1082-
ThreadDetach( ( ThreadHandle_t )nThreadID );
1082+
ReleaseThreadHandle( ( ThreadHandle_t )nThreadID );
10831083
return nThreadID;
10841084
}
10851085
};

engine/hltvdemo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "host.h"
2323
#include "server.h"
2424
#include "networkstringtableclient.h"
25+
#include "vcrmode.h"
2526

2627
// memdbgon must be the last include file in a .cpp file!!!
2728
#include "tier0/memdbgon.h"

engine/r_decal.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ void R_DrawDecalsAllImmediate_GatherDecals( IMatRenderContext *pRenderContext, i
20032003

20042004
intp iHead = g_aDecalSortTrees[iSortTree].m_aDecalSortBuckets[iGroup][iTreeType].Element( iBucket ).m_iHead;
20052005

2006-
intp iElement = iHead;
2006+
intp iElement = iHead;
20072007
while ( iElement != g_aDecalSortPool.InvalidIndex() )
20082008
{
20092009
decal_t *pDecal = g_aDecalSortPool.Element( iElement );
@@ -2154,11 +2154,11 @@ void R_DrawDecalsAllImmediate( IMatRenderContext *pRenderContext, int iGroup, in
21542154
{
21552155
if ( g_aDecalSortTrees[iSortTree].m_aDecalSortBuckets[iGroup][iTreeType].Element( iBucket ).m_nCheckCount != nCheckCount )
21562156
continue;
2157-
2157+
21582158
intp iHead = g_aDecalSortTrees[iSortTree].m_aDecalSortBuckets[iGroup][iTreeType].Element( iBucket ).m_iHead;
2159-
2159+
21602160
int nCount;
2161-
intp iElement = iHead;
2161+
intp iElement = iHead;
21622162
while ( iElement != g_aDecalSortPool.InvalidIndex() )
21632163
{
21642164
decal_t *pDecal = g_aDecalSortPool.Element( iElement );
@@ -2330,7 +2330,7 @@ void R_DrawDecalsAll_GatherDecals( IMatRenderContext *pRenderContext, int iGroup
23302330
if ( bucket.m_nCheckCount != nCheckCount )
23312331
continue;
23322332

2333-
intp iHead = bucket.m_iHead;
2333+
intp iHead = bucket.m_iHead;
23342334
if ( !g_aDecalSortPool.IsValidIndex( iHead ) )
23352335
continue;
23362336

@@ -2647,7 +2647,7 @@ void R_DrawDecalsAll( IMatRenderContext *pRenderContext, int iGroup, int iTreeTy
26472647
if ( bucket.m_nCheckCount != nCheckCount )
26482648
continue;
26492649

2650-
int iHead = bucket.m_iHead;
2650+
intp iHead = bucket.m_iHead;
26512651
if ( !g_aDecalSortPool.IsValidIndex( iHead ) )
26522652
continue;
26532653

@@ -2666,7 +2666,7 @@ void R_DrawDecalsAll( IMatRenderContext *pRenderContext, int iGroup, int iTreeTy
26662666
bool bBatchInit = true;
26672667

26682668
int nCount;
2669-
int iElement = iHead;
2669+
intp iElement = iHead;
26702670
while ( iElement != g_aDecalSortPool.InvalidIndex() )
26712671
{
26722672
decal_t *pDecal = g_aDecalSortPool.Element( iElement );

engine/spatialpartition.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class CVoxelTree
282282
CVoxelHash* m_pVoxelHash;
283283
CLeafList m_aLeafList; // Pool - Linked list(multilist) of leaves per entity.
284284
int m_TreeId;
285-
CThreadLocalPtr<CPartitionVisits> m_pVisits;
285+
CTHREADLOCALPTR(CPartitionVisits) m_pVisits;
286286
CSpatialPartition * m_pOwner;
287287
CUtlVector<unsigned short> m_AvailableVisitBits;
288288
unsigned short m_nNextVisitBit;
@@ -1775,7 +1775,7 @@ void CVoxelTree::Shutdown( void )
17751775
//-----------------------------------------------------------------------------
17761776
void CVoxelTree::InsertIntoTree( SpatialPartitionHandle_t hPartition, const Vector& mins, const Vector& maxs )
17771777
{
1778-
bool bWasReading = ( m_pVisits != NULL );
1778+
bool bWasReading = ( m_pVisits != static_cast<void*>(nullptr) );
17791779
if ( bWasReading )
17801780
{
17811781
// If we're recursing in this thread, need to release our read lock to allow ourselves to write
@@ -1832,7 +1832,7 @@ void CVoxelTree::RemoveFromTree( SpatialPartitionHandle_t hPartition )
18321832
int nLevel = info.m_nLevel[GetTreeId()];
18331833
if ( nLevel >= 0 )
18341834
{
1835-
bool bWasReading = ( m_pVisits != NULL );
1835+
bool bWasReading = ( m_pVisits != static_cast<void*>(nullptr) );
18361836
if ( bWasReading )
18371837
{
18381838
// If we're recursing in this thread, need to release our read lock to allow ourselves to write

engine/sys_dll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ void Sys_ShutdownAuthentication( void )
797797
//-----------------------------------------------------------------------------
798798
// Debug library spew output
799799
//-----------------------------------------------------------------------------
800-
CThreadLocalInt<> g_bInSpew;
800+
CTHREADLOCALINT g_bInSpew;
801801

802802
#include "tier1/fmtstr.h"
803803

engine/tmessage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ void TextMessageParse( byte *pMemFile, int fileSize )
367367

368368
client_textmessage_t textMessages[ MAX_MESSAGES ];
369369

370-
int i, nameHeapSize, textHeapSize, messageSize, nameOffset;
370+
int i, nameHeapSize, textHeapSize, messageSize;
371+
intp nameOffset;
371372

372373
lastNamePos = 0;
373374
lineNumber = 0;
@@ -633,4 +634,4 @@ client_textmessage_t *TextMessageGet( const char *pName )
633634
}
634635

635636
return NULL;
636-
}
637+
}

0 commit comments

Comments
 (0)