Skip to content

Commit

Permalink
Add profiler markers
Browse files Browse the repository at this point in the history
  • Loading branch information
v2v3v4 committed Oct 1, 2024
1 parent 0a744ad commit 706c955
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Layers/xrRender/R_Backend_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ IC ID3DDepthStencilView* CBackend::get_ZB ()

ICF void CBackend::set_States (ID3DState* _state)
{
PROF_EVENT("CBackend::set_States")
// DX10 Manages states using it's own algorithm. Don't mess with it.
#ifndef USE_DX11
if (state!=_state)
Expand Down Expand Up @@ -116,6 +117,7 @@ IC void CBackend::set_Matrices (SMatrixList* _M)

IC void CBackend::set_Element (ShaderElement* S, u32 pass)
{
PROF_EVENT("CBackend::set_Element")
SPass& P = *(S->passes[pass]);
set_States (P.state);
set_PS (P.ps);
Expand Down
6 changes: 5 additions & 1 deletion src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ IC float GetDistFromCamera(const Fvector& from_position)

IC bool IsValuableToRender(dxRender_Visual* pVisual, bool isStatic, bool sm,
Fmatrix& transform_matrix, bool ignore_optimize = false) {
PROF_EVENT("IsValuableToRender")
if (ignore_optimize)
return true;

Expand Down Expand Up @@ -884,11 +885,11 @@ IC bool IsValuableToRender(dxRender_Visual* pVisual, bool isStatic, bool sm,
////////////////////////////////////////////////////////////////////////////////////////////////////
void CRender::add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore)
{
PROF_EVENT("add_leafs_Dynamic")
if (0==pVisual) return;

if (!IsValuableToRender(pVisual, false, phase == 1, *val_pTransform, ignore))
return;

// Visual is 100% visible - simply add it
xr_vector<dxRender_Visual*>::iterator I,E; // it may be useful for 'hierrarhy' visual

Expand Down Expand Up @@ -955,6 +956,7 @@ void CRender::add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore)

void CRender::add_leafs_Static(dxRender_Visual *pVisual)
{
PROF_EVENT("add_leafs_Static")
if (!HOM.visible(pVisual->vis)) return;

if (!pVisual->_ignore_optimization &&
Expand Down Expand Up @@ -1046,6 +1048,7 @@ void CRender::add_leafs_Static(dxRender_Visual *pVisual)
////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL CRender::add_Dynamic(dxRender_Visual *pVisual, u32 planes)
{
PROF_EVENT("add_Dynamic")
if (!pVisual->_ignore_optimization &&
!IsValuableToRender(pVisual, false, phase == 1, *val_pTransform))
return false;
Expand Down Expand Up @@ -1146,6 +1149,7 @@ BOOL CRender::add_Dynamic(dxRender_Visual *pVisual, u32 planes)

void CRender::add_Static(dxRender_Visual *pVisual, u32 planes)
{
PROF_EVENT("add_Static")
if (!pVisual->_ignore_optimization &&
!IsValuableToRender(pVisual, true, phase == 1, *val_pTransform))
return;
Expand Down
2 changes: 2 additions & 0 deletions src/Layers/xrRender/r_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ IC bool p_sort (ref_constant C1, ref_constant C2)

ref_constant R_constant_table::get (LPCSTR S)
{
PROF_EVENT("R_constant_table::get LPCSTR")
// assumption - sorted by name
c_table::iterator I = std::lower_bound(table.begin(),table.end(),S,p_search);
if (I==table.end() || (0!=xr_strcmp(*(*I)->name,S))) return 0;
else return *I;
}
ref_constant R_constant_table::get (shared_str& S)
{
PROF_EVENT("R_constant_table::get shared_str")
// linear search, but only ptr-compare
c_table::iterator I = table.begin ();
c_table::iterator E = table.end ();
Expand Down
3 changes: 3 additions & 0 deletions src/Layers/xrRenderDX10/dx10R_Backend_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ ICF void CBackend::set_CullMode(u32 _mode)

IC void CBackend::ApplyVertexLayout()
{
PROF_EVENT("CBackend::ApplyVertexLayout")
VERIFY(vs);
VERIFY(decl);
VERIFY(m_pInputSignature);
Expand Down Expand Up @@ -502,6 +503,7 @@ IC bool CBackend::CBuffersNeedUpdate( ref_cbuffer buf1[MaxCBuffers], ref_cbuffer

IC void CBackend::set_Constants (R_constant_table* C_)
{
PROF_EVENT("CBackend::set_Constants")
// caching
if (ctable==C_) return;
ctable = C_;
Expand Down Expand Up @@ -728,6 +730,7 @@ ICF void CBackend::ApplyRTandZB()

IC void CBackend::get_ConstantDirect(shared_str& n, u32 DataSize, void** pVData, void** pGData, void** pPData)
{
PROF_EVENT("CBackend::get_ConstantDirect")
ref_constant C_ = get_c(n);

if (C_)
Expand Down
2 changes: 2 additions & 0 deletions src/Layers/xrRenderDX10/dx10r_constants_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

dx10ConstantBuffer& R_constants::GetCBuffer(R_constant* C, BufferType BType)
{
PROF_EVENT("R_constants::GetCBuffer")
if (BType==BT_PixelBuffer)
{
// Decode index
Expand Down Expand Up @@ -69,6 +70,7 @@ dx10ConstantBuffer& R_constants::GetCBuffer(R_constant* C, BufferType BType)

void R_constants::flush_cache()
{
PROF_EVENT("R_constants::flush_cache")
for (int i=0; i < CBackend::MaxCBuffers; ++i)
{
if (RCache.m_aVertexConstants[i])
Expand Down
1 change: 1 addition & 0 deletions src/xrCDB/ISpatial_q_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class walker

void ISpatial_DB::q_box (xr_vector<ISpatial*>& R, u32 _o, u32 _mask, const Fvector& _center, const Fvector& _size)
{
PROF_EVENT("ISpatial_DB::q_frustum")
cs.Enter ();
q_result = &R;
q_result->resize(0);
Expand Down
1 change: 1 addition & 0 deletions src/xrCDB/ISpatial_q_frustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class walker

void ISpatial_DB::q_frustum (xr_vector<ISpatial*>& R, u32 _o, u32 _mask, const CFrustum& _frustum)
{
PROF_EVENT("ISpatial_DB::q_frustum")
if (!m_root)
{
return;
Expand Down
1 change: 1 addition & 0 deletions src/xrCDB/ISpatial_q_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class _MM_ALIGN16 walker

void ISpatial_DB::q_ray (xr_vector<ISpatial*>& R, u32 _o, u32 _mask_and, const Fvector& _start, const Fvector& _dir, float _range)
{
PROF_EVENT("ISpatial_DB::q_ray")
cs.Enter ();
q_result = &R;
q_result->resize(0);
Expand Down
1 change: 1 addition & 0 deletions src/xrCDB/xrCDB_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class box_collider

void COLLIDER::box_query(const MODEL *m_def, const Fvector& b_center, const Fvector& b_dim)
{
PROF_EVENT("COLLIDER::box_query")
m_def->syncronize ();

// Get nodes
Expand Down
1 change: 1 addition & 0 deletions src/xrCDB/xrCDB_frustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class CFrustumCollider {

void COLLIDER::frustum_query(const MODEL* m_def, const CFrustum& F)
{
PROF_EVENT("COLLIDER::frustum_query")
m_def->syncronize();

// Get nodes
Expand Down
1 change: 1 addition & 0 deletions src/xrCDB/xrCDB_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class _MM_ALIGN16 ray_collider

void COLLIDER::ray_query(const MODEL* m_def, const Fvector& r_start, const Fvector& r_dir, float r_range)
{
PROF_EVENT("COLLIDER::ray_query")
m_def->syncronize();

// Get nodes
Expand Down
2 changes: 2 additions & 0 deletions src/xrEngine/IGame_Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void IGame_Level::SetViewEntity( CObject* O )

void IGame_Level::SoundEvent_Register ( ref_sound_data_ptr S, float range )
{
PROF_EVENT("IGame_Level::SoundEvent_Register")
if (!g_bLoaded) return;
if (!S) return;
if (S->g_object && S->g_object->getDestroy()) {S->g_object=0; return;}
Expand Down Expand Up @@ -319,6 +320,7 @@ void IGame_Level::SoundEvent_Dispatch ( )
// Lain: added
void IGame_Level::SoundEvent_OnDestDestroy (Feel::Sound* obj)
{
PROF_EVENT("IGame_Level::SoundEvent_OnDestDestroy")
struct rem_pred
{
rem_pred(Feel::Sound* obj) : m_obj(obj) {}
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/xr_collide_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ void CCF_Skeleton::BuildTopLevel()

BOOL CCF_Skeleton::_RayQuery( const collide::ray_defs& Q, collide::rq_results& R)
{
PROF_EVENT("CCF_Skeleton::_RayQuery")
if (dwFrameTL!=Device.dwFrame) BuildTopLevel();


Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/CustomDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void CCustomDetector::Load(LPCSTR section)

void CCustomDetector::shedule_Update(u32 dt)
{
PROF_EVENT("CCustomDetector::shedule_Update");
PROF_EVENT_DYNAMIC(cNameSect_str())
inherited::shedule_Update(dt);

if( !IsWorking() ) return;
Expand Down Expand Up @@ -346,6 +346,7 @@ extern u32 hud_adj_mode;

void CCustomDetector::UpdateCL()
{
PROF_EVENT_DYNAMIC(cNameSect_str())
inherited::UpdateCL();

if(H_Parent()!=Level().CurrentEntity() ) return;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/DestroyablePhysicsObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void CDestroyablePhysicsObject::InitServerObject(CSE_Abstract* D)
}
void CDestroyablePhysicsObject::shedule_Update(u32 dt)
{
PROF_EVENT("CDestroyablePhysicsObject::shedule_Update");
PROF_EVENT_DYNAMIC(cNameSect_str())
inherited::shedule_Update(dt);
CPHDestroyable::SheduleUpdate(dt);
}
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/Grenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ void CGrenade::OnAnimationEnd(u32 state)

void CGrenade::UpdateCL()
{
PROF_EVENT_DYNAMIC(cNameSect_str())
inherited::UpdateCL ();
CExplosive::UpdateCL ();

Expand Down
1 change: 0 additions & 1 deletion src/xrGame/Missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ void CMissile::UpdateCL()
}
void CMissile::shedule_Update(u32 dt)
{
PROF_EVENT("CMissile::shedule_Update");
inherited::shedule_Update(dt);
if(!H_Parent() && getVisible() && m_pPhysicsShell)
{
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/PhysicsShellHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ void CPhysicsShellHolder::OnChangeVisual()

void CPhysicsShellHolder::UpdateCL ()
{
PROF_EVENT("CPhysicsShellHolder::UpdateCL")
inherited::UpdateCL ();
//обновить присоединенные партиклы
UpdateParticles ();
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/Torch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ void CTorch::OnH_B_Independent(bool just_before_destroy)

void CTorch::UpdateCL()
{
PROF_EVENT_DYNAMIC(cNameSect_str())
inherited::UpdateCL ();

if (!m_switched_on) return;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ void CWeapon::OnEvent(NET_Packet& P, u16 type)

void CWeapon::shedule_Update (u32 dT)
{
PROF_EVENT("CWeapon::shedule_Update");
PROF_EVENT_DYNAMIC(cNameSect_str())
// Queue shrink
// u32 dwTimeCL = Level().timeServer()-NET_Latency;
// while ((NET.size()>2) && (NET[1].dwTimeStamp<dwTimeCL)) NET.pop_front();
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/WeaponAmmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void CWeaponAmmo::renderable_Render()

void CWeaponAmmo::UpdateCL()
{
PROF_EVENT_DYNAMIC(cNameSect_str())
VERIFY2 (_valid(renderable.xform),*cName());
inherited::UpdateCL ();
VERIFY2 (_valid(renderable.xform),*cName());
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/WeaponMagazined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ void CWeaponMagazined::OnStateSwitch (u32 S)

void CWeaponMagazined::UpdateCL ()
{
PROF_EVENT_DYNAMIC(cNameSect_str())
inherited::UpdateCL ();
float dt = Device.fTimeDelta;

Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/ai/monsters/basemonster/base_monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ void CBaseMonster::update_enemy_accessible_and_at_home_info ()

void CBaseMonster::UpdateCL()
{
PROF_EVENT_DYNAMIC(cNameSect_str())
#ifdef DEBUG
if ( Level().CurrentEntity() == this )
{
Expand Down Expand Up @@ -369,7 +370,7 @@ void CBaseMonster::UpdateCL()

void CBaseMonster::shedule_Update(u32 dt)
{
PROF_EVENT("CBaseMonster::shedule_Update");
PROF_EVENT_DYNAMIC(cNameSect_str())
#ifdef DEBUG
if ( is_paused () )
{
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/entity_alive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ void CEntityAlive::reload (LPCSTR section)

void CEntityAlive::shedule_Update(u32 dt)
{
PROF_EVENT("CEntityAlive::shedule_Update")
inherited::shedule_Update (dt);

//condition update with the game time pass
Expand Down
7 changes: 7 additions & 0 deletions src/xrGame/script_binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void CScriptBinder::Load (LPCSTR section)

void CScriptBinder::reload (LPCSTR section)
{
PROF_EVENT("CScriptBinder::reload")
#ifndef DBG_DISABLE_SCRIPTS
VERIFY (!m_object);
if (!pSettings->line_exist(section,"script_binding"))
Expand Down Expand Up @@ -98,6 +99,7 @@ void CScriptBinder::reload (LPCSTR section)

BOOL CScriptBinder::net_Spawn (CSE_Abstract* DC)
{
PROF_EVENT("CScriptBinder::net_Spawn")
CSE_Abstract *abstract = (CSE_Abstract*)DC;
CSE_ALifeObject *object = smart_cast<CSE_ALifeObject*>(abstract);
if (object && m_object) {
Expand All @@ -114,6 +116,7 @@ BOOL CScriptBinder::net_Spawn (CSE_Abstract* DC)

void CScriptBinder::net_Destroy ()
{
PROF_EVENT("CScriptBinder::net_Destroy")
if (m_object) {
#ifdef _DEBUG
Msg ("* Core object %s is UNbinded from the script object",smart_cast<CGameObject*>(this) ? *smart_cast<CGameObject*>(this)->cName() : "");
Expand Down Expand Up @@ -143,6 +146,7 @@ void CScriptBinder::set_object (CScriptBinderObject *object)

void CScriptBinder::shedule_Update (u32 time_delta)
{
PROF_EVENT("CScriptBinder::shedule_Update")
if (m_object) {
try {
m_object->shedule_Update (time_delta);
Expand All @@ -155,6 +159,7 @@ void CScriptBinder::shedule_Update (u32 time_delta)

void CScriptBinder::save (NET_Packet &output_packet)
{
PROF_EVENT("CScriptBinder::save")
if (m_object) {
try {
m_object->save (&output_packet);
Expand All @@ -167,6 +172,7 @@ void CScriptBinder::save (NET_Packet &output_packet)

void CScriptBinder::load (IReader &input_packet)
{
PROF_EVENT("CScriptBinder::load")
if (m_object) {
try {
m_object->load (&input_packet);
Expand All @@ -192,6 +198,7 @@ BOOL CScriptBinder::net_SaveRelevant()

void CScriptBinder::net_Relcase (CObject *object)
{
PROF_EVENT("CScriptBinder::net_Relcase")
CGameObject *game_object = smart_cast<CGameObject*>(object);
if (m_object && game_object) {
try {
Expand Down
3 changes: 3 additions & 0 deletions src/xrPhysics/IActivationShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "phcollidevalidator.h"
void ActivateShapeExplosive( IPhysicsShellHolder* self_obj, const Fvector &size, Fvector &out_size, Fvector &in_out_pos)
{
PROF_EVENT("ActivateShapeExplosive")
//////////////
CPHActivationShape activation_shape;//Fvector start_box;m_PhysicMovementControl.Box().getsize(start_box);
activation_shape.Create(in_out_pos,size,self_obj);
Expand All @@ -22,6 +23,7 @@ void ActivateShapeExplosive( IPhysicsShellHolder* self_obj, const Fvector &size,

void ActivateShapePhysShellHolder(IPhysicsShellHolder *obj, const Fmatrix &in_xform, const Fvector &in_size, Fvector &in_pos, Fvector &out_pos )
{
PROF_EVENT("ActivateShapePhysShellHolder")
CPHActivationShape activation_shape;
activation_shape.Create (in_pos,in_size,obj);
activation_shape.set_rotation (in_xform);
Expand Down Expand Up @@ -53,6 +55,7 @@ void ActivateShapePhysShellHolder(IPhysicsShellHolder *obj, const Fmatrix &in_xf

bool ActivateShapeCharacterPhysicsSupport( Fvector &out_pos, const Fvector &vbox,const Fvector &activation_pos,const Fmatrix &mXFORM, bool not_collide_characters, bool set_rotation, IPhysicsShellHolder *m_EntityAlife )
{
PROF_EVENT("ActivateShapeCharacterPhysicsSupport")
CPHActivationShape activation_shape;
activation_shape.Create(activation_pos,vbox,m_EntityAlife);
if( not_collide_characters )
Expand Down

0 comments on commit 706c955

Please sign in to comment.