From 706c955541b86448869ecae7d8523154cde51e16 Mon Sep 17 00:00:00 2001 From: v2v3v4 Date: Tue, 1 Oct 2024 23:54:01 +0300 Subject: [PATCH] Add profiler markers --- src/Layers/xrRender/R_Backend_Runtime.h | 2 ++ src/Layers/xrRender/r__dsgraph_build.cpp | 6 +++++- src/Layers/xrRender/r_constants.cpp | 2 ++ src/Layers/xrRenderDX10/dx10R_Backend_Runtime.h | 3 +++ src/Layers/xrRenderDX10/dx10r_constants_cache.cpp | 2 ++ src/xrCDB/ISpatial_q_box.cpp | 1 + src/xrCDB/ISpatial_q_frustum.cpp | 1 + src/xrCDB/ISpatial_q_ray.cpp | 1 + src/xrCDB/xrCDB_box.cpp | 1 + src/xrCDB/xrCDB_frustum.cpp | 1 + src/xrCDB/xrCDB_ray.cpp | 1 + src/xrEngine/IGame_Level.cpp | 2 ++ src/xrEngine/xr_collide_form.cpp | 1 + src/xrGame/CustomDetector.cpp | 3 ++- src/xrGame/DestroyablePhysicsObject.cpp | 2 +- src/xrGame/Grenade.cpp | 1 + src/xrGame/Missile.cpp | 1 - src/xrGame/PhysicsShellHolder.cpp | 1 + src/xrGame/Torch.cpp | 1 + src/xrGame/Weapon.cpp | 2 +- src/xrGame/WeaponAmmo.cpp | 1 + src/xrGame/WeaponMagazined.cpp | 1 + src/xrGame/ai/monsters/basemonster/base_monster.cpp | 3 ++- src/xrGame/entity_alive.cpp | 1 + src/xrGame/script_binder.cpp | 7 +++++++ src/xrPhysics/IActivationShape.cpp | 3 +++ 26 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/Layers/xrRender/R_Backend_Runtime.h b/src/Layers/xrRender/R_Backend_Runtime.h index 945664018e..4f64be33f5 100644 --- a/src/Layers/xrRender/R_Backend_Runtime.h +++ b/src/Layers/xrRender/R_Backend_Runtime.h @@ -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) @@ -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); diff --git a/src/Layers/xrRender/r__dsgraph_build.cpp b/src/Layers/xrRender/r__dsgraph_build.cpp index 6f43447644..a7fffc8b20 100644 --- a/src/Layers/xrRender/r__dsgraph_build.cpp +++ b/src/Layers/xrRender/r__dsgraph_build.cpp @@ -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; @@ -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::iterator I,E; // it may be useful for 'hierrarhy' visual @@ -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 && @@ -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; @@ -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; diff --git a/src/Layers/xrRender/r_constants.cpp b/src/Layers/xrRender/r_constants.cpp index a16635697c..9d594ddcb9 100644 --- a/src/Layers/xrRender/r_constants.cpp +++ b/src/Layers/xrRender/r_constants.cpp @@ -51,6 +51,7 @@ 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; @@ -58,6 +59,7 @@ ref_constant R_constant_table::get (LPCSTR S) } 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 (); diff --git a/src/Layers/xrRenderDX10/dx10R_Backend_Runtime.h b/src/Layers/xrRenderDX10/dx10R_Backend_Runtime.h index 17ac8fe2e4..2dafdc0568 100644 --- a/src/Layers/xrRenderDX10/dx10R_Backend_Runtime.h +++ b/src/Layers/xrRenderDX10/dx10R_Backend_Runtime.h @@ -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); @@ -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_; @@ -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_) diff --git a/src/Layers/xrRenderDX10/dx10r_constants_cache.cpp b/src/Layers/xrRenderDX10/dx10r_constants_cache.cpp index d4b5b20797..968502ff2f 100644 --- a/src/Layers/xrRenderDX10/dx10r_constants_cache.cpp +++ b/src/Layers/xrRenderDX10/dx10r_constants_cache.cpp @@ -5,6 +5,7 @@ dx10ConstantBuffer& R_constants::GetCBuffer(R_constant* C, BufferType BType) { + PROF_EVENT("R_constants::GetCBuffer") if (BType==BT_PixelBuffer) { // Decode index @@ -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]) diff --git a/src/xrCDB/ISpatial_q_box.cpp b/src/xrCDB/ISpatial_q_box.cpp index 798bf899ff..29b90182a1 100644 --- a/src/xrCDB/ISpatial_q_box.cpp +++ b/src/xrCDB/ISpatial_q_box.cpp @@ -59,6 +59,7 @@ class walker void ISpatial_DB::q_box (xr_vector& 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); diff --git a/src/xrCDB/ISpatial_q_frustum.cpp b/src/xrCDB/ISpatial_q_frustum.cpp index c11761dc34..b1655e837b 100644 --- a/src/xrCDB/ISpatial_q_frustum.cpp +++ b/src/xrCDB/ISpatial_q_frustum.cpp @@ -53,6 +53,7 @@ class walker void ISpatial_DB::q_frustum (xr_vector& R, u32 _o, u32 _mask, const CFrustum& _frustum) { + PROF_EVENT("ISpatial_DB::q_frustum") if (!m_root) { return; diff --git a/src/xrCDB/ISpatial_q_ray.cpp b/src/xrCDB/ISpatial_q_ray.cpp index 7084eb3798..c8a91ec8c9 100644 --- a/src/xrCDB/ISpatial_q_ray.cpp +++ b/src/xrCDB/ISpatial_q_ray.cpp @@ -275,6 +275,7 @@ class _MM_ALIGN16 walker void ISpatial_DB::q_ray (xr_vector& 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); diff --git a/src/xrCDB/xrCDB_box.cpp b/src/xrCDB/xrCDB_box.cpp index ead39f2ae7..b06690df19 100644 --- a/src/xrCDB/xrCDB_box.cpp +++ b/src/xrCDB/xrCDB_box.cpp @@ -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 diff --git a/src/xrCDB/xrCDB_frustum.cpp b/src/xrCDB/xrCDB_frustum.cpp index 9e1c0bbd12..e5bba06b15 100644 --- a/src/xrCDB/xrCDB_frustum.cpp +++ b/src/xrCDB/xrCDB_frustum.cpp @@ -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 diff --git a/src/xrCDB/xrCDB_ray.cpp b/src/xrCDB/xrCDB_ray.cpp index 800f92c260..56d3e1c408 100644 --- a/src/xrCDB/xrCDB_ray.cpp +++ b/src/xrCDB/xrCDB_ray.cpp @@ -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 diff --git a/src/xrEngine/IGame_Level.cpp b/src/xrEngine/IGame_Level.cpp index 1cfc726a83..413e1471ea 100644 --- a/src/xrEngine/IGame_Level.cpp +++ b/src/xrEngine/IGame_Level.cpp @@ -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;} @@ -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) {} diff --git a/src/xrEngine/xr_collide_form.cpp b/src/xrEngine/xr_collide_form.cpp index 9b956ffe12..7bb3912f54 100644 --- a/src/xrEngine/xr_collide_form.cpp +++ b/src/xrEngine/xr_collide_form.cpp @@ -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(); diff --git a/src/xrGame/CustomDetector.cpp b/src/xrGame/CustomDetector.cpp index 1911a7c058..9805426c27 100644 --- a/src/xrGame/CustomDetector.cpp +++ b/src/xrGame/CustomDetector.cpp @@ -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; @@ -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; diff --git a/src/xrGame/DestroyablePhysicsObject.cpp b/src/xrGame/DestroyablePhysicsObject.cpp index f93e6b0b13..f125091d02 100644 --- a/src/xrGame/DestroyablePhysicsObject.cpp +++ b/src/xrGame/DestroyablePhysicsObject.cpp @@ -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); } diff --git a/src/xrGame/Grenade.cpp b/src/xrGame/Grenade.cpp index 7bfdf72baa..7c6e675b1c 100644 --- a/src/xrGame/Grenade.cpp +++ b/src/xrGame/Grenade.cpp @@ -311,6 +311,7 @@ void CGrenade::OnAnimationEnd(u32 state) void CGrenade::UpdateCL() { + PROF_EVENT_DYNAMIC(cNameSect_str()) inherited::UpdateCL (); CExplosive::UpdateCL (); diff --git a/src/xrGame/Missile.cpp b/src/xrGame/Missile.cpp index a432612d3d..6364d0e595 100644 --- a/src/xrGame/Missile.cpp +++ b/src/xrGame/Missile.cpp @@ -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) { diff --git a/src/xrGame/PhysicsShellHolder.cpp b/src/xrGame/PhysicsShellHolder.cpp index c042904b8f..2c93c76195 100644 --- a/src/xrGame/PhysicsShellHolder.cpp +++ b/src/xrGame/PhysicsShellHolder.cpp @@ -343,6 +343,7 @@ void CPhysicsShellHolder::OnChangeVisual() void CPhysicsShellHolder::UpdateCL () { + PROF_EVENT("CPhysicsShellHolder::UpdateCL") inherited::UpdateCL (); //обновить присоединенные партиклы UpdateParticles (); diff --git a/src/xrGame/Torch.cpp b/src/xrGame/Torch.cpp index 7e2fe63a1c..9a4e1ca464 100644 --- a/src/xrGame/Torch.cpp +++ b/src/xrGame/Torch.cpp @@ -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; diff --git a/src/xrGame/Weapon.cpp b/src/xrGame/Weapon.cpp index 2b8ccbafb7..d4d2f1761e 100644 --- a/src/xrGame/Weapon.cpp +++ b/src/xrGame/Weapon.cpp @@ -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].dwTimeStampline_exist(section,"script_binding")) @@ -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(abstract); if (object && m_object) { @@ -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(this) ? *smart_cast(this)->cName() : ""); @@ -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); @@ -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); @@ -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); @@ -192,6 +198,7 @@ BOOL CScriptBinder::net_SaveRelevant() void CScriptBinder::net_Relcase (CObject *object) { + PROF_EVENT("CScriptBinder::net_Relcase") CGameObject *game_object = smart_cast(object); if (m_object && game_object) { try { diff --git a/src/xrPhysics/IActivationShape.cpp b/src/xrPhysics/IActivationShape.cpp index ff4afd2c9b..564e98731a 100644 --- a/src/xrPhysics/IActivationShape.cpp +++ b/src/xrPhysics/IActivationShape.cpp @@ -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); @@ -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); @@ -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 )