Skip to content

Commit ed1b22b

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

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

source/modules/vprof.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ 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+
699701
#ifdef VPROF_VTUNE_GROUP
700702
bool m_bVTuneGroupEnabled;
701703
int m_nVTuneGroupID;
@@ -734,6 +736,37 @@ class PLATFORM_CLASS CCVProfile
734736
unsigned m_TargetThreadId;
735737
};
736738

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

750783
if (!g_VProfCurrentProfile.InTargetThread())
751784
{
752-
Msg("Setting new targeted Thread\n");
785+
Msg("Setting new targeted Thread (%u, %u)\n", ThreadGetCurrentId(), g_VProfCurrentProfile.GetTargetThreadId());
753786
g_VProfCurrentProfile.SetTargetThreadId(ThreadGetCurrentId());
787+
Msg("new targeted Thread (%s, %u, %u % s)\n",
788+
g_VProfCurrentProfile.InTargetThread() ? "true" : "false",
789+
g_VProfCurrentProfile.GetTargetThreadId(),
790+
ThreadGetCurrentId(),
791+
(ThreadGetCurrentId() == g_VProfCurrentProfile.GetTargetThreadId()) ? "true" : "false"
792+
);
754793
}
755794

756795
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)