Skip to content

Commit 6c76623

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

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

source/modules/vprof.cpp

Lines changed: 45 additions & 4 deletions
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,12 +784,18 @@ void CVProfModule::Init(CreateInterfaceFn* appfn, CreateInterfaceFn* gamefn)
749784

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

756-
Msg("Entering Scope (%s %s %s)\n", (prof->m_enabled != 0) ? "true" : "false", prof->m_fAtRoot ? "true" : "false", g_VProfCurrentProfile.InTargetThread() ? "true" : "false");
757-
g_VProfCurrentProfile.EnterScope(_T("HolyLib_Test"), 0, "HolyLib", false);
797+
Msg("Entering Scope (%s %s %s)\n", (prof->m_enabled != 0) ? "true" : "false", prof->m_fAtRoot ? "true" : "false", prof->InTargetThread() ? "true" : "false");
798+
prof->EnterScope(_T("HolyLib_Test"), 0, "HolyLib", false);
758799
Msg("m_fAtRoot: %s\n", prof->m_fAtRoot ? "true" : "false");
759800
g_VProfCurrentProfile.ExitScope();
760801
Msg("Exiting Scope\n");

0 commit comments

Comments
 (0)