diff --git a/Editor/ProjectManager.cpp b/Editor/ProjectManager.cpp index c77e1b3cc..1d0de2a23 100644 --- a/Editor/ProjectManager.cpp +++ b/Editor/ProjectManager.cpp @@ -73,6 +73,7 @@ bool ProjectManager::newProject(hecl::SystemStringView path) { } bool ProjectManager::openProject(hecl::SystemStringView path) { + OPTICK_EVENT(); hecl::SystemString subPath; hecl::ProjectRootPath projPath = hecl::SearchForProject(path, subPath); if (!projPath) { @@ -166,6 +167,7 @@ bool ProjectManager::saveProject() { } void ProjectManager::mainUpdate() { + OPTICK_EVENT(); if (m_precooking) { if (!m_factoryMP1.IsBusy()) m_precooking = false; diff --git a/Editor/Space.hpp b/Editor/Space.hpp index 659482d51..4f6b49aae 100644 --- a/Editor/Space.hpp +++ b/Editor/Space.hpp @@ -172,6 +172,7 @@ public: } void think() override { + OPTICK_EVENT(); if (m_spaceTree) m_spaceTree->think(); } diff --git a/Editor/SplashScreen.cpp b/Editor/SplashScreen.cpp index cd4345a36..53fd21dda 100644 --- a/Editor/SplashScreen.cpp +++ b/Editor/SplashScreen.cpp @@ -50,6 +50,7 @@ void SplashScreen::think() { m_fileBrowser.m_view.reset(); return; } + OPTICK_EVENT(); ModalWindow::think(); if (m_fileBrowser.m_view) diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index c8d0b782a..2a89052f8 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -18,6 +18,7 @@ #include "hecl/Pipeline.hpp" #include "version.h" #include +#include "optick.h" using YAMLNode = athena::io::YAMLNode; @@ -54,6 +55,7 @@ void ViewManager::TestGameView::draw(boo::IGraphicsCommandQueue* gfxQ) { } void ViewManager::TestGameView::think() { + OPTICK_EVENT(); if (!m_debugText) { m_debugText.reset(new specter::MultiLineTextView(m_vm.m_viewResources, *this, m_vm.m_viewResources.m_monoFont18)); boo::SWindowRect sub = subRect(); @@ -356,6 +358,7 @@ bool ViewManager::proc() { return false; if (m_updatePf) { + OPTICK_EVENT("m_updatePf"); m_viewResources.resetPixelFactor(m_reqPf); specter::RootView* root = SetupRootView(); if (m_rootSpace) @@ -368,8 +371,14 @@ bool ViewManager::proc() { m_updatePf = false; } - m_rootView->dispatchEvents(); - m_rootView->internalThink(); + { + OPTICK_EVENT("m_rootView->DispatchEvents"); + m_rootView->dispatchEvents(); + } + { + OPTICK_EVENT("m_rootView->internalThink"); + m_rootView->internalThink(); + } if (m_rootSpace) m_rootSpace->think(); if (m_splash) @@ -391,19 +400,24 @@ bool ViewManager::proc() { if (m_testGameView) m_testGameView->think(); - if (g_Renderer) - g_Renderer->BeginScene(); - m_rootView->draw(gfxQ); - if (g_Renderer) - g_Renderer->EndScene(); - gfxQ->execute(); + { + OPTICK_EVENT("Draw"); + if (g_Renderer) + g_Renderer->BeginScene(); + m_rootView->draw(gfxQ); + if (g_Renderer) + g_Renderer->EndScene(); + gfxQ->execute(); + } if (g_ResFactory) g_ResFactory->AsyncIdle(); #ifndef URDE_MSAN m_voiceEngine->pumpAndMixVoices(); #endif - if (!m_skipWait || !hecl::com_developer->toBoolean()) + if (!m_skipWait || !hecl::com_developer->toBoolean()) { + OPTICK_EVENT("waitForRetrace"); m_mainWindow->waitForRetrace(); + } CBooModel::ClearModelUniformCounters(); CGraphics::TickRenderTimings(); ++logvisor::FrameIndex; diff --git a/Editor/main.cpp b/Editor/main.cpp index ec2f17724..980d12988 100644 --- a/Editor/main.cpp +++ b/Editor/main.cpp @@ -9,6 +9,7 @@ #include "hecl/Console.hpp" #include "fmt/chrono.h" #include "version.h" +#include "optick.h" static logvisor::Module AthenaLog("Athena"); static void AthenaExc(athena::error::Level level, const char* file, const char*, int line, fmt::string_view fmt, @@ -71,6 +72,7 @@ struct Application : boo::IApplicationCallback { initialize(app); m_viewManager->init(app); while (m_running.load()) { + OPTICK_FRAME("MainThread"); if (!m_viewManager->proc()) break; } diff --git a/Runtime/AutoMapper/CMapArea.cpp b/Runtime/AutoMapper/CMapArea.cpp index 3717e5ae9..99362316f 100644 --- a/Runtime/AutoMapper/CMapArea.cpp +++ b/Runtime/AutoMapper/CMapArea.cpp @@ -78,6 +78,7 @@ CMapArea::CMapArea(CInputStream& in, u32 size) } void CMapArea::PostConstruct() { + OPTICK_EVENT(); x38_moStart = x44_buf.get(); x3c_vertexStart = x38_moStart + (x28_mappableObjCount * 0x50); x40_surfaceStart = x3c_vertexStart + (x2c_vertexCount * 12); diff --git a/Runtime/CFactoryMgr.cpp b/Runtime/CFactoryMgr.cpp index bc285cc86..72fda9658 100644 --- a/Runtime/CFactoryMgr.cpp +++ b/Runtime/CFactoryMgr.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "optick.h" #include "Runtime/CStopwatch.hpp" #include "Runtime/IObj.hpp" @@ -35,6 +36,7 @@ bool CFactoryMgr::CanMakeMemory(const metaforce::SObjectTag& tag) const { CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr&& buf, int size, bool compressed, const CVParamTransfer& paramXfer, CObjectReference* selfRef) { + OPTICK_EVENT(); std::unique_ptr localBuf = std::move(buf); const auto memFactoryIter = m_memFactories.find(tag.type); diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index b777e1be4..2d0df10cc 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -133,7 +133,7 @@ endfunction() set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) set(RUNTIME_LIBRARIES ${HECL_APPLICATION_REPS_TARGETS_LIST} RetroDataSpec AssetNameMapNull NESEmulator - libjpeg-turbo jbus kabufuda discord-rpc logvisor) + libjpeg-turbo jbus kabufuda discord-rpc logvisor OptickCore) if(MSVC) # WTF MS???? LINK.EXE is unable to address static libraries larger than 4GB. diff --git a/Runtime/CResFactory.cpp b/Runtime/CResFactory.cpp index b976c4755..22ec21111 100644 --- a/Runtime/CResFactory.cpp +++ b/Runtime/CResFactory.cpp @@ -2,6 +2,7 @@ #include "Runtime/CSimplePool.hpp" #include "Runtime/CStopwatch.hpp" +#include "optick.h" namespace metaforce { static logvisor::Module Log("CResFactory"); @@ -33,6 +34,7 @@ CFactoryFnReturn CResFactory::BuildSync(const SObjectTag& tag, const CVParamTran } bool CResFactory::PumpResource(SLoadingData& data) { + OPTICK_EVENT(); if (data.x8_dvdReq && data.x8_dvdReq->IsComplete()) { data.x8_dvdReq.reset(); *data.xc_targetPtr = @@ -74,6 +76,7 @@ void CResFactory::BuildAsync(const SObjectTag& tag, const CVParamTransfer& xfer, } void CResFactory::AsyncIdle() { + OPTICK_EVENT(); if (m_loadList.empty()) return; auto startTime = std::chrono::steady_clock::now(); diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 078bd517e..bba5001e4 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -780,6 +780,7 @@ void CStateManager::DrawWorld() { g_Renderer->SetThermalColdScale(xf28_thermColdScale2 + xf24_thermColdScale1); for (int i = areaCount - 1; i >= 0; --i) { + OPTICK_EVENT("CStateManager::DrawWorld DrawArea"); const CGameArea& area = *areaArr[i]; SetupFogForArea(area); g_Renderer->EnablePVS(pvsArr[i], area.x4_selfIdx); @@ -1472,6 +1473,7 @@ void CStateManager::LoadScriptObjects(TAreaId aid, CInputStream& in, std::vector std::pair CStateManager::LoadScriptObject(TAreaId aid, EScriptObjectType type, u32 length, CInputStream& in) { + OPTICK_EVENT(); const TEditorId id = in.readUint32Big(); const u32 connCount = in.readUint32Big(); length -= 8; diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index f1eaf9548..620541a0e 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -553,6 +553,7 @@ void CAnimData::Render(CSkinnedModel& model, const CModelFlags& drawFlags, void CAnimData::SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags, const std::optional& morphEffect, const float* morphMagnitudes) { + OPTICK_EVENT(); if (!x220_30_poseBuilt) { x2fc_poseBuilder.BuildNoScale(x224_pose); x220_30_poseBuilt = true; @@ -560,7 +561,9 @@ void CAnimData::SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags, PoseSkinnedModel(model, x224_pose, drawFlags, morphEffect, morphMagnitudes); } -void CAnimData::DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags) { model.Draw(flags); } +void CAnimData::DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags) { + model.Draw(flags); +} void CAnimData::PreRender() { if (!x220_31_poseCached) { diff --git a/Runtime/Character/CSkinRules.cpp b/Runtime/Character/CSkinRules.cpp index ffb7f69fb..8ce0ca4c9 100644 --- a/Runtime/Character/CSkinRules.cpp +++ b/Runtime/Character/CSkinRules.cpp @@ -25,6 +25,7 @@ CSkinRules::CSkinRules(CInputStream& in) { void CSkinRules::TransformVerticesCPU(std::vector>& vnOut, const CPoseAsTransforms& pose, const CModel& model) const { + OPTICK_EVENT(); vnOut.resize(m_poolToSkinIdx.size()); for (size_t i = 0; i < m_poolToSkinIdx.size(); ++i) { const CVirtualBone& vb = m_virtualBones[m_poolToSkinIdx[i]]; diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 39fe67e0e..e5d769243 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -223,6 +223,7 @@ CBooRenderer::CAreaListItem::CAreaListItem(const std::vector thisLights; thisLights.reserve(lightCount); @@ -767,6 +768,7 @@ void CBooRenderer::DisablePVS() { xc8_pvs = std::nullopt; } void CBooRenderer::UpdateAreaUniforms(int areaIdx, EWorldShadowMode shadowMode, bool activateLights, int cubeFace, const CModelFlags* ballShadowFlags) { + OPTICK_EVENT(); SetupRendererStates(); CModelFlags flags; @@ -1067,6 +1069,7 @@ void CBooRenderer::SetViewport(int left, int bottom, int width, int height) { void CBooRenderer::SetDebugOption(EDebugOption, int) {} void CBooRenderer::BeginScene() { + OPTICK_EVENT(); CGraphics::SetViewport(0, 0, g_Viewport.x8_width, g_Viewport.xc_height); CGraphics::SetPerspective(75.f, CGraphics::g_ProjAspect, 1.f, 4096.f); CGraphics::SetModelMatrix(zeus::CTransform()); @@ -1088,6 +1091,7 @@ void CBooRenderer::BeginScene() { } void CBooRenderer::EndScene() { + OPTICK_EVENT(); CGraphics::EndScene(); if (x2dc_reflectionAge >= 2) { // Delete reflection tex x14c_ diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index bb9cd69c7..f89161d2a 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -445,6 +445,7 @@ float CGraphics::GetSecondsMod900() { } void CGraphics::TickRenderTimings() { + OPTICK_EVENT(); g_RenderTimings = (g_RenderTimings + 1) % u32(900 * 60); g_DefaultSeconds = g_RenderTimings / 60.f; } diff --git a/Runtime/Graphics/CGraphics.hpp b/Runtime/Graphics/CGraphics.hpp index 14bf97e41..2b804748e 100644 --- a/Runtime/Graphics/CGraphics.hpp +++ b/Runtime/Graphics/CGraphics.hpp @@ -3,6 +3,7 @@ #include #include #include +#include "optick.h" #include "Runtime/RetroTypes.hpp" @@ -438,7 +439,7 @@ public: }; #define SCOPED_GRAPHICS_DEBUG_GROUP(...) GraphicsDebugGroup _GfxDbg_(__VA_ARGS__); #else -#define SCOPED_GRAPHICS_DEBUG_GROUP(...) +#define SCOPED_GRAPHICS_DEBUG_GROUP(name, ...) OPTICK_EVENT_DYNAMIC(name) #endif } // namespace metaforce diff --git a/Runtime/Graphics/CLineRenderer.cpp b/Runtime/Graphics/CLineRenderer.cpp index ef2dde9a5..eafe3a7cc 100644 --- a/Runtime/Graphics/CLineRenderer.cpp +++ b/Runtime/Graphics/CLineRenderer.cpp @@ -23,6 +23,7 @@ hecl::UniformBufferPool CLineRenderer::s_uniformPoo CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken& texture, bool additive, bool zTest, bool zGEqual) : m_mode(mode), m_maxVerts(maxVerts) { + OPTICK_EVENT(); if (maxVerts < 2) { LineRendererLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("maxVerts < 2, maxVerts = {}")), maxVerts); return; @@ -54,6 +55,7 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitive CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken& texture, bool additive, bool zTest, bool zGEqual) : m_mode(mode), m_maxVerts(maxVerts) { + OPTICK_EVENT(); if (maxVerts < 2) { LineRendererLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("maxVerts < 2, maxVerts = {}")), maxVerts); return; diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index 5665de014..039dd32e9 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -51,6 +51,7 @@ void CBooModel::Shutdown() { } void CBooModel::ClearModelUniformCounters() { + OPTICK_EVENT(); for (CBooModel* model = g_FirstModel; model; model = model->m_next) model->ClearUniformCounter(); } @@ -244,6 +245,7 @@ GeometryUniformLayout::GeometryUniformLayout(const CModel* model, const Material } CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf, boo::IGraphicsDataFactory::Context* ctx) { + OPTICK_EVENT(); if (!x40_24_texturesLoaded && !g_DummyTextures) { return nullptr; } @@ -981,6 +983,7 @@ boo::ObjToken GeometryUniformLayout::GetSharedBuffer(int boo::ObjToken CBooModel::UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose, int sharedLayoutBuf, boo::IGraphicsDataFactory::Context* ctx) { + OPTICK_EVENT(); if (!g_DummyTextures && !TryLockTextures()) return {}; @@ -1154,6 +1157,7 @@ std::unique_ptr CModel::MakeNewInstance(int shaderIdx, int subInsts, } CModelShaders::ShaderPipelines SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat) { + OPTICK_EVENT(); hecl::Backend::ReflectionType reflectionType; if (mat.flags.samusReflectionIndirectTexture()) reflectionType = hecl::Backend::ReflectionType::Indirect; diff --git a/Runtime/Graphics/CSkinnedModel.cpp b/Runtime/Graphics/CSkinnedModel.cpp index 6d42878bc..343166c3d 100644 --- a/Runtime/Graphics/CSkinnedModel.cpp +++ b/Runtime/Graphics/CSkinnedModel.cpp @@ -53,6 +53,7 @@ void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& } void CSkinnedModel::Draw(const CModelFlags& drawFlags) const { + OPTICK_EVENT(); if (m_modelInst->TryLockTextures()) m_modelInst->DrawSurfaces(drawFlags); } diff --git a/Runtime/Graphics/Shaders/CFluidPlaneShader.cpp b/Runtime/Graphics/Shaders/CFluidPlaneShader.cpp index 2c2f2bc88..f11ffdc44 100644 --- a/Runtime/Graphics/Shaders/CFluidPlaneShader.cpp +++ b/Runtime/Graphics/Shaders/CFluidPlaneShader.cpp @@ -90,6 +90,7 @@ u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneDoorShaderInfo& info template <> CFluidPlaneShader::ShaderPair CFluidPlaneShader::Cache::GetOrBuildShader(const SFluidPlaneShaderInfo& info) { + OPTICK_EVENT(); u16 key = MakeCacheKey(info); auto& slot = CacheSlot(info, key); if (slot.m_regular) @@ -104,6 +105,7 @@ CFluidPlaneShader::Cache::GetOrBuildShader(const SFluidPl template <> CFluidPlaneShader::ShaderPair CFluidPlaneShader::Cache::GetOrBuildShader(const SFluidPlaneDoorShaderInfo& info) { + OPTICK_EVENT(); u16 key = MakeCacheKey(info); auto& slot = CacheSlot(info, key); if (slot.m_regular) diff --git a/Runtime/Particle/CDecalManager.cpp b/Runtime/Particle/CDecalManager.cpp index 2412c51ea..4880c4dc4 100644 --- a/Runtime/Particle/CDecalManager.cpp +++ b/Runtime/Particle/CDecalManager.cpp @@ -93,6 +93,7 @@ void CDecalManager::Update(float dt, CStateManager& mgr) { void CDecalManager::AddDecal(const TToken& decal, const zeus::CTransform& xf, bool notIce, CStateManager& mgr) { + OPTICK_EVENT(); if (m_LastDecalCreatedIndex != -1 && m_DeltaTimeSinceLastDecalCreation < 0.75f && m_LastDecalCreatedAssetId == decal.GetObjectTag()->id) { SDecal& existingDecal = m_DecalPool[m_LastDecalCreatedIndex]; diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index e1c4f9848..dbc43664c 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -593,6 +593,7 @@ void CElementGen::UpdatePSTranslationAndOrientation() { } std::unique_ptr CElementGen::ConstructChildParticleSystem(const TToken& desc) const { + OPTICK_EVENT(); auto ret = std::make_unique(desc, EModelOrientationType::Normal, x26d_27_enableOPTS ? EOptionalSystemFlags::Two : EOptionalSystemFlags::One); ret->x26d_26_modelsUseLights = x26d_26_modelsUseLights; diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index 4f2e3b9d9..7d179c288 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -176,6 +176,7 @@ constexpr std::array CGunWeapon::skShootAnim{4, 3}; void CGunWeapon::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf, CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2) { + OPTICK_EVENT(); CDamageInfo dInfo = GetDamageInfo(mgr, chargeState, chargeFactor1); zeus::CVector3f scale(chargeState == EChargeState::Normal ? 1.f : chargeFactor2); bool partialCharge = chargeState == EChargeState::Normal ? false : !zeus::close_enough(chargeFactor1, 1.f); diff --git a/Runtime/World/CFluidPlane.cpp b/Runtime/World/CFluidPlane.cpp index 5cc16905a..47a430a30 100644 --- a/Runtime/World/CFluidPlane.cpp +++ b/Runtime/World/CFluidPlane.cpp @@ -312,6 +312,7 @@ void CFluidPlane::RenderStripWithRipples(float curY, const Heights& heights, con void CFluidPlane::RenderPatch(const CFluidPlaneRender::SPatchInfo& info, const Heights& heights, const Flags& flags, bool noRipples, bool flagIs1, std::vector& vOut, std::vector& pvOut) { + OPTICK_EVENT(); if (noRipples) { m_shader->bindRegular(); diff --git a/Runtime/World/CFluidPlaneCPU.cpp b/Runtime/World/CFluidPlaneCPU.cpp index c36529250..d4fe09a1f 100644 --- a/Runtime/World/CFluidPlaneCPU.cpp +++ b/Runtime/World/CFluidPlaneCPU.cpp @@ -129,6 +129,7 @@ CFluidPlaneShader::RenderSetupInfo CFluidPlaneCPU::RenderSetup(const CStateManag const zeus::CTransform& xf, const zeus::CTransform& areaXf, const zeus::CAABox& aabb, const CScriptWater* water) { + OPTICK_EVENT(); CFluidPlaneShader::RenderSetupInfo out; const float uvT = mgr.GetFluidPlaneManager()->GetUVT(); diff --git a/extern/boo b/extern/boo index 6335cb09f..cd25ff4ab 160000 --- a/extern/boo +++ b/extern/boo @@ -1 +1 @@ -Subproject commit 6335cb09fe5046984e8baa9b5a65de837037e70c +Subproject commit cd25ff4abfeb8c32256447f97a1a829bdbaf262c