Skip to content

Commit 9d9374b

Browse files
committed
vprof: show ids
Tf is going on...
1 parent 9e62c6f commit 9d9374b

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

source/modules/vprof.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,10 @@ void CVProfModule::InitDetour(bool bPreServer)
696696
class PLATFORM_CLASS CCVProfile
697697
{
698698
public:
699+
void EnterScope( const tchar *pszName, int detailLevel, const tchar *pBudgetGroupName, bool bAssertAccounted, int budgetFlags = BUDGETFLAG_OTHER );
700+
701+
bool InTargetThread() const { return ( m_TargetThreadId == (uint)ThreadGetCurrentId() ); } // <----- This function is fked. ThreadGetCurrentId doesn't return an uint! so comparing will break
702+
699703
#ifdef VPROF_VTUNE_GROUP
700704
bool m_bVTuneGroupEnabled;
701705
int m_nVTuneGroupID;
@@ -734,6 +738,37 @@ class PLATFORM_CLASS CCVProfile
734738
unsigned m_TargetThreadId;
735739
};
736740

741+
inline void CCVProfile::EnterScope( const tchar *pszName, int detailLevel, const tchar *pBudgetGroupName, bool bAssertAccounted, int budgetFlags )
742+
{
743+
if ( ( m_enabled != 0 || !m_fAtRoot ) && InTargetThread() ) // if became disabled, need to unwind back to root before stopping
744+
{
745+
// Only account for vprof stuff on the primary thread.
746+
//if( !Plat_IsPrimaryThread() )
747+
// return;
748+
749+
if ( pszName != m_pCurNode->GetName() )
750+
{
751+
m_pCurNode = m_pCurNode->GetSubNode( pszName, detailLevel, pBudgetGroupName, budgetFlags );
752+
}
753+
m_pBudgetGroups[m_pCurNode->GetBudgetGroupID()].m_BudgetFlags |= budgetFlags;
754+
755+
#if defined( _DEBUG ) && !defined( _X360 )
756+
// 360 doesn't want this to allow tier0 debug/release .def files to match
757+
if ( bAssertAccounted )
758+
{
759+
// FIXME
760+
AssertOnce( m_pCurNode->GetBudgetGroupID() != 0 );
761+
}
762+
#endif
763+
m_pCurNode->EnterScope();
764+
m_fAtRoot = false;
765+
}
766+
#if defined(_X360) && defined(VPROF_PIX)
767+
if ( m_pCurNode->GetBudgetGroupID() != VPROF_BUDGET_GROUP_ID_UNACCOUNTED )
768+
PIXBeginNamedEvent( 0, pszName );
769+
#endif
770+
}
771+
737772
void CVProfModule::Init(CreateInterfaceFn* appfn, CreateInterfaceFn* gamefn)
738773
{
739774
CCVProfile* prof = (CCVProfile*)&g_VProfCurrentProfile;
@@ -749,8 +784,14 @@ void CVProfModule::Init(CreateInterfaceFn* appfn, CreateInterfaceFn* gamefn)
749784

750785
if (!g_VProfCurrentProfile.InTargetThread())
751786
{
752-
Msg("Setting new targeted Thread\n");
787+
Msg("Setting new targeted Thread (%u, %u)\n", ThreadGetCurrentId(), g_VProfCurrentProfile.GetTargetThreadId());
753788
g_VProfCurrentProfile.SetTargetThreadId(ThreadGetCurrentId());
789+
Msg("new targeted Thread (%s, %u, %u % s)\n",
790+
prof->InTargetThread() ? "true" : "false",
791+
g_VProfCurrentProfile.GetTargetThreadId(),
792+
ThreadGetCurrentId(),
793+
((uint)ThreadGetCurrentId() == g_VProfCurrentProfile.GetTargetThreadId()) ? "true" : "false"
794+
);
754795
}
755796

756797
Msg("Entering Scope (%s %s %s)\n", (prof->m_enabled != 0) ? "true" : "false", prof->m_fAtRoot ? "true" : "false", g_VProfCurrentProfile.InTargetThread() ? "true" : "false");

0 commit comments

Comments
 (0)