Skip to content

Commit

Permalink
pending: experimental changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercoms committed Mar 21, 2023
1 parent 94fdfd4 commit 0f2c82f
Show file tree
Hide file tree
Showing 63 changed files with 400 additions and 187 deletions.
2 changes: 1 addition & 1 deletion src/engine/cmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ void FASTCALL CM_TraceToLeaf( TraceInfo_t * RESTRICT pTraceInfo, int ndxLeaf, fl
pCounters = pTraceInfo->GetDispCounters();
count = pTraceInfo->GetCount();

if (IsX360())
if (IsX360() || 1)
{
// set up some relatively constant variables we'll use in the loop below
fltx4 traceStart = LoadUnaligned3SIMD(pTraceInfo->m_start.Base());
Expand Down
2 changes: 1 addition & 1 deletion src/engine/engine.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $Configuration

$Compiler [$WIN32]
{
$EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)"
$EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)"
}

$Linker
Expand Down
2 changes: 1 addition & 1 deletion src/engine/enginetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ void CEngineTool::SetGamePaused( bool paused )

float CEngineTool::GetTimescale()
{
return host_timescale.GetFloat();
return host_timescale.GetFloat() ? host_timescale.GetFloat() : 1.0f;
}

void CEngineTool::SetTimescale( float scale )
Expand Down
35 changes: 33 additions & 2 deletions src/engine/gl_rsurf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "materialsystem/imaterialvar.h"
#include "coordsize.h"
#include "mempool.h"
#include "mathlib/ssemath.h"
#ifndef SWDS
#include "Overlay.h"
#endif
Expand Down Expand Up @@ -4839,10 +4840,12 @@ static bool EnumerateLeafInBox_R(mnode_t *node, EnumLeafBoxInfo_t& info )
}
}

#ifdef _X360

#if defined(_X360) || USE_DXMATH
#ifdef _DEBUG
static fltx4 AlignThatVector(const Vector &vc)
{
#ifdef _X360
fltx4 out = __loadunalignedvector(vc.Base());

/*
Expand All @@ -4853,7 +4856,12 @@ static fltx4 AlignThatVector(const Vector &vc)

// squelch the w component
return __vrlimi( out, __vzero(), 1, 0 );
#elif USE_DXMATH
fltx4 out = LoadUnaligned3SIMD(vc.Base());
return DirectX::XMVectorSetW(out, 0);
#endif
}
#endif

//-----------------------------------------------------------------------------
// Finds all leaves of the BSP tree within a particular volume
Expand All @@ -4864,9 +4872,11 @@ static bool EnumerateLeafInBox_R(mnode_t * RESTRICT node, const EnumLeafBoxInfo_
if (node->contents == CONTENTS_SOLID)
return true; // solid

#ifdef _X360
// speculatively get the children into the cache
__dcbt(0,node->children[0]);
__dcbt(0,node->children[1]);
#endif

// constructing these here prevents LHS if we spill.
// it's not quite a quick enough operation to do extemporaneously.
Expand Down Expand Up @@ -4937,6 +4947,7 @@ static bool EnumerateLeafInBox_R(mnode_t * RESTRICT node, const EnumLeafBoxInfo_
fltx4 vecBoxMax = LoadAlignedSIMD(pInfo->m_vecBoxMax);
fltx4 cornermin, cornermax;
// by now planeNormal is ready...
#ifdef _X360
fltx4 control = XMVectorGreaterOrEqual( planeNormal, __vzero() );
// now control[i] = planeNormal[i] > 0 ? 0xFF : 0x00
cornermin = XMVectorSelect( vecBoxMax, vecBoxMin, control); // cornermin[i] = control[i] ? vecBoxMin[i] : vecBoxMax[i]
Expand All @@ -4945,6 +4956,7 @@ static bool EnumerateLeafInBox_R(mnode_t * RESTRICT node, const EnumLeafBoxInfo_
// compute dot products
fltx4 dotCornerMax = __vmsum3fp(planeNormal, cornermax); // vsumfp ignores w component
fltx4 dotCornerMin = __vmsum3fp(planeNormal, cornermin);

fltx4 vPlaneDist = ReplicateX4(plane->dist);
UINT conditionRegister;
XMVectorGreaterR(&conditionRegister,vPlaneDist,dotCornerMax);
Expand All @@ -4954,6 +4966,25 @@ static bool EnumerateLeafInBox_R(mnode_t * RESTRICT node, const EnumLeafBoxInfo_
XMVectorGreaterOrEqualR(&conditionRegister,dotCornerMin,vPlaneDist);
if ( XMComparisonAllTrue(conditionRegister) )
return EnumerateLeafInBox_R( node->children[0], pInfo );
#elif USE_DXMATH
fltx4 control = DirectX::XMVectorGreaterOrEqual( planeNormal, LoadZeroSIMD() );
// now control[i] = planeNormal[i] > 0 ? 0xFF : 0x00
cornermin = DirectX::XMVectorSelect( vecBoxMax, vecBoxMin, control); // cornermin[i] = control[i] ? vecBoxMin[i] : vecBoxMax[i]
cornermax = DirectX::XMVectorSelect( vecBoxMin, vecBoxMax, control);
// compute dot products
fltx4 dotCornerMax = DirectX::XMVector3Dot(planeNormal, cornermax); // vsumfp ignores w component
fltx4 dotCornerMin = DirectX::XMVector3Dot(planeNormal, cornermin);

fltx4 vPlaneDist = ReplicateX4(plane->dist);
uint conditionRegister;
DirectX::XMVectorGreaterR(&conditionRegister,vPlaneDist,dotCornerMax);
if (DirectX::XMComparisonAllTrue(conditionRegister)) // plane->normal . cornermax <= plane->dist
return EnumerateLeafInBox_R( node->children[1], pInfo );

DirectX::XMVectorGreaterOrEqualR(&conditionRegister,dotCornerMin,vPlaneDist);
if ( DirectX::XMComparisonAllTrue(conditionRegister) )
return EnumerateLeafInBox_R( node->children[0], pInfo );
#endif

return EnumerateLeafInBox_R( node->children[0], pInfo ) &&
EnumerateLeafInBox_R( node->children[1], pInfo );
Expand Down Expand Up @@ -5326,7 +5357,7 @@ bool CEngineBSPTree::EnumerateLeavesInBox( const Vector& mins, const Vector& max
info.m_nContext = context;
info.m_vecBoxMax = maxs;
info.m_vecBoxMin = mins;
#ifdef _X360
#if defined(_X360) || USE_DXMATH
if (opt_EnumerateLeavesFastAlgorithm.GetBool())
return EnumerateLeafInBox_R( host_state.worldbrush->nodes, &info );
else
Expand Down
5 changes: 4 additions & 1 deletion src/engine/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ static ConVar host_profile( "host_profile","0" );

ConVar host_limitlocal( "host_limitlocal", "0", 0, "Apply cl_cmdrate and cl_updaterate to loopback connection" );
ConVar host_framerate( "host_framerate","0", 0, "Set to lock per-frame time elapse." );
ConVar host_timescale( "host_timescale","1.0", FCVAR_REPLICATED, "Prescale the clock by this amount." );
ConVar host_timescale( "host_timescale","0.0", FCVAR_REPLICATED, "Prescale the clock by this amount." );
ConVar host_speeds( "host_speeds","0", 0, "Show general system running times." ); // set for running times

ConVar host_flush_threshold( "host_flush_threshold", "20", 0, "Memory threshold below which the host should flush caches between server instances" );
Expand Down Expand Up @@ -1758,7 +1758,10 @@ void Host_ReadPreStartupConfiguration()
{
"sv_unlockedchapters", // needed to display the startup graphic while loading
"snd_legacy_surround", // needed to init the sound system
#if defined( _X360 ) || defined( STAGING_ONLY )
"gameui_xbox", // needed to initialize the correct UI
#endif
"cl_hud_minmode", // needed to initialize the correct UI
"save_in_memory" // needed to preread data from the correct location in UI
};

Expand Down
4 changes: 2 additions & 2 deletions src/engine/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ extern int host_currentframetick;

// PERFORMANCE INFO
#define MIN_FPS 0.1 // Host minimum fps value for maxfps.
#define MAX_FPS 1000.0 // Upper limit for maxfps.
#define MAX_FPS 10000.0 // Upper limit for maxfps.

#define MAX_FRAMETIME 0.1
#define MIN_FRAMETIME 0.001
#define MIN_FRAMETIME 0.0001

#define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / host_state.interval_per_tick ) )
#define TICKS_TO_TIME( dt ) ( host_state.interval_per_tick * (float)(dt) )
Expand Down
20 changes: 10 additions & 10 deletions src/engine/l_studio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2785,11 +2785,11 @@ struct rbatch_t
// ----------------------------------------
*/

inline int FindModel( const CUtlVector<rmodel_t> &list, const model_t *pModel )
inline int FindModel( const rmodel_t* pList, int listCount, const model_t* pModel )
{
for ( int j = list.Count(); --j >= 0 ; )
for ( int j = listCount; --j >= 0 ; )
{
if ( list[j].pModel == pModel )
if ( pList[j].pModel == pModel )
return j;
}
return -1;
Expand All @@ -2806,13 +2806,13 @@ int CModelRender::DrawStaticPropArrayFast( StaticPropRenderInfo_t *pProps, int c
#ifndef SWDS
MDLCACHE_CRITICAL_SECTION_( g_pMDLCache );
CMatRenderContextPtr pRenderContext( materials );
const int MAX_OBJECTS = 1024;
const int MAX_OBJECTS = 2048;
CUtlSortVector<robject_t, CRobjectLess> objectList(0, MAX_OBJECTS);
CUtlVector<rmodel_t> modelList(0,256);
CUtlVector<short> lightObjects(0,256);
CUtlVector<short> shadowObjects(0,64);
CUtlVector<rdecalmodel_t> decalObjects(0,64);
CUtlVector<LightingState_t> lightStates(0,256);
CUtlVectorFixedGrowable<rmodel_t, 256> modelList;
CUtlVectorFixedGrowable<short, 256> lightObjects;
CUtlVectorFixedGrowable<short, 64> shadowObjects;
CUtlVectorFixedGrowable<rdecalmodel_t, 64> decalObjects;
CUtlVectorFixedGrowable<LightingState_t, 256> lightStates;
bool bForceCubemap = r_showenvcubemap.GetBool();
int drawnCount = 0;
int forcedLodSetting = r_lod.GetInt();
Expand All @@ -2826,7 +2826,7 @@ int CModelRender::DrawStaticPropArrayFast( StaticPropRenderInfo_t *pProps, int c
{
drawnCount++;
// UNDONE: This is a perf hit in some scenes! Use a hash?
int modelIndex = FindModel( modelList, pProps[i].pModel );
int modelIndex = FindModel( modelList.Base(), modelList.Count(), pProps[i].pModel );
if ( modelIndex < 0 )
{
modelIndex = modelList.AddToTail();
Expand Down
8 changes: 1 addition & 7 deletions src/engine/modelloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@

ConVar mat_loadtextures( "mat_loadtextures", "1", FCVAR_CHEAT );

// OS X and Linux are blowing up right now due to this. Benefits vs possible regressions on DX less clear.
#if defined( DX_TO_GL_ABSTRACTION ) || defined( STAGING_ONLY )
#define CONVAR_DEFAULT_MOD_OFFLINE_HDR_SWITCH "1"
#else
#define CONVAR_DEFAULT_MOD_OFFLINE_HDR_SWITCH "0"
#endif
static ConVar mod_offline_hdr_switch( "mod_offline_hdr_switch", CONVAR_DEFAULT_MOD_OFFLINE_HDR_SWITCH, FCVAR_INTERNAL_USE,
static ConVar mod_offline_hdr_switch( "mod_offline_hdr_switch", "1", FCVAR_INTERNAL_USE,
"Re-order the HDR/LDR mode switch to do most of the material system "
"reloading with the device offline. This reduces unnecessary device "
"resource uploads and may drastically reduce load time and memory pressure "
Expand Down
10 changes: 9 additions & 1 deletion src/engine/net_ws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,15 @@ void NET_SetTime( double flRealtime )
}

// adjust network time so fakelag works with host_timescale
net_time += frametime * host_timescale.GetFloat();
const float timescale = host_timescale.GetFloat();
if (timescale > 0)
{
net_time += frametime * timescale;
}
else
{
net_time += frametime;
}
}

/*
Expand Down
6 changes: 4 additions & 2 deletions src/engine/vgui_baseui_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ IGameConsole *staticGameConsole = NULL;
bool s_bWindowsInputEnabled = true;

ConVar r_drawvgui( "r_drawvgui", "1", FCVAR_CHEAT, "Enable the rendering of vgui panels" );
#if defined( _X360 ) || defined( STAGING_ONLY )
ConVar gameui_xbox( "gameui_xbox", "0", 0 );
#endif

void Con_CreateConsolePanel( vgui::Panel *parent );
void CL_CreateEntityReportPanel( vgui::Panel *parent );
Expand Down Expand Up @@ -2142,11 +2144,11 @@ void VGui_FindNamedPanels( CUtlVector< vgui::VPANEL >& panelList, char const *pa
VGui_RecursiveFindPanels( panelList, embedded, panelname );
}

CON_COMMAND( vgui_togglepanel, "show/hide vgui panel by name." )
CON_COMMAND_F( vgui_togglepanel, "show/hide vgui panel by name.", FCVAR_CHEAT )
{
if ( args.ArgC() < 2 )
{
ConMsg( "Usage: vgui_showpanel panelname\n" );
ConMsg( "Usage: vgui_togglepanel panelname\n" );
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/game/client/c_vguiscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
// X360TBD: Turn this on if feature actually used
return NULL;
}
// Feature not used, causes crashes if entity exists anyway...
return NULL;

C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();

Expand Down
6 changes: 3 additions & 3 deletions src/game/client/game_controls/MapOverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ void CMapOverview::SetMode(int mode)
{
ShowPanel( false );

g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapOff" );
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "MapOff", true, true );
}
else if ( mode == MAP_MODE_INSET )
{
Expand All @@ -1041,7 +1041,7 @@ void CMapOverview::SetMode(int mode)

if ( mode != m_nMode && RunHudAnimations() )
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToSmall" );
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "MapZoomToSmall", true, true );
}
}
else if ( mode == MAP_MODE_FULL )
Expand All @@ -1061,7 +1061,7 @@ void CMapOverview::SetMode(int mode)

if ( mode != m_nMode && RunHudAnimations() )
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToLarge" );
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "MapZoomToLarge", true, true );
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/game/client/game_controls/baseviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void hud_autoreloadscript_callback( IConVar *var, const char *pOldValue, float f

static ConVar cl_leveloverviewmarker( "cl_leveloverviewmarker", "0", FCVAR_CHEAT );

CON_COMMAND( showpanel, "Shows a viewport panel <name>" )
CON_COMMAND_F( showpanel, "Shows a viewport panel <name>", FCVAR_CHEAT )
{
if ( !gViewPortInterface )
return;
Expand All @@ -90,7 +90,7 @@ CON_COMMAND( showpanel, "Shows a viewport panel <name>" )
gViewPortInterface->ShowPanel( args[ 1 ], true );
}

CON_COMMAND( hidepanel, "Hides a viewport panel <name>" )
CON_COMMAND_F( hidepanel, "Hides a viewport panel <name>", FCVAR_CHEAT )
{
if ( !gViewPortInterface )
return;
Expand Down
6 changes: 3 additions & 3 deletions src/game/client/hud_base_account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void CHudBaseAccount::LevelInit( void )
m_pszLastAnimationName = NULL;
m_pszQueuedAnimationName = NULL;

GetAnimationController()->StartAnimationSequence("AccountMoneyInvisible");
GetAnimationController()->StartAnimationSequence(this, "AccountMoneyInvisible", true, true);
}

void CHudBaseAccount::ApplySchemeSettings(vgui::IScheme *pScheme)
Expand Down Expand Up @@ -91,14 +91,14 @@ void CHudBaseAccount::Paint()
{
m_pszLastAnimationName = "AccountMoneyAdded";
}
GetAnimationController()->StartAnimationSequence( m_pszLastAnimationName );
GetAnimationController()->StartAnimationSequence( this, m_pszLastAnimationName, true, true );
m_flLastAnimationEnd = gpGlobals->curtime + GetAnimationController()->GetAnimationSequenceLength( m_pszLastAnimationName );

m_iPreviousAccount = account;
}
else if ( m_pszQueuedAnimationName )
{
GetAnimationController()->StartAnimationSequence( m_pszQueuedAnimationName );
GetAnimationController()->StartAnimationSequence( this, m_pszQueuedAnimationName, true, true );
m_pszQueuedAnimationName = NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/client/hud_controlpointicons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ void CControlPointIcon::PerformLayout( void )
if ( m_pCapNumPlayers )
{
m_pCapNumPlayers->SetVisible( (iPlayers>1) );
SetDialogVariable( "numcappers", iPlayers );
SetDialogVariable( "numcappers", iPlayers, false );

m_pCapNumPlayers->SetFgColor( Color(0,0,0,255) );
}
Expand Down
12 changes: 6 additions & 6 deletions src/game/client/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ void CHudMenu::SelectMenuItem( int menu_item )

m_nSelectedItem = menu_item;
// Pulse the selection
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuPulse");
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuPulse", true, true);

// remove the menu quickly
m_bMenuTakesInput = false;
m_flShutoffTime = gpGlobals->realtime + m_flOpenCloseTime;
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuClose");
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuClose", true, true);
}
}

Expand Down Expand Up @@ -365,7 +365,7 @@ void CHudMenu::HideMenu( void )
{
m_bMenuTakesInput = false;
m_flShutoffTime = gpGlobals->realtime + m_flOpenCloseTime;
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuClose");
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuClose", true, true);
}

//-----------------------------------------------------------------------------
Expand All @@ -384,7 +384,7 @@ void CHudMenu::ShowMenu( const char * menuName, int validSlots )

Q_strncpy( g_szPrelocalisedMenuString, menuName, sizeof( g_szPrelocalisedMenuString ) );

g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuOpen", true, true);
m_nSelectedItem = -1;

// we have the whole string, so we can localise it now
Expand All @@ -409,7 +409,7 @@ void CHudMenu::ShowMenu_KeyValueItems( KeyValues *pKV )
m_fWaitingForMore = 0;
m_bitsValidSlots = 0;

g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuOpen", true, true);
m_nSelectedItem = -1;

g_szMenuString[0] = '\0';
Expand Down Expand Up @@ -489,7 +489,7 @@ void CHudMenu::MsgFunc_ShowMenu( bf_read &msg)

if ( !NeedMore )
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuOpen", true, true);
m_nSelectedItem = -1;

// we have the whole string, so we can localise it now
Expand Down
Loading

0 comments on commit 0f2c82f

Please sign in to comment.