From 93c0d1b1e10eb5f1a2f43a94e203c1080e1190f1 Mon Sep 17 00:00:00 2001 From: JuiceyDev Date: Sun, 5 Apr 2026 22:13:22 +0200 Subject: [PATCH] feat/tracy: added tracy zones in important parts. --- targets/app/common/Game.cpp | 207 +++++++++++++++++- targets/app/linux/Iggy/gdraw/gdraw.c | 144 ++++++++++-- targets/app/linux/LinuxGame.cpp | 40 +++- targets/app/linux/Linux_Minecraft.cpp | 13 ++ targets/minecraft/client/Minecraft.cpp | 62 +++++- .../chunk/storage/McRegionChunkStorage.cpp | 43 +++- .../world/level/chunk/storage/RegionFile.cpp | 22 +- .../level/chunk/storage/RegionFileCache.cpp | 15 +- targets/platform/meson.build | 4 +- targets/platform/sdl2/Render.cpp | 48 +++- 10 files changed, 537 insertions(+), 61 deletions(-) diff --git a/targets/app/common/Game.cpp b/targets/app/common/Game.cpp index 34b83bbf3..82135eba4 100644 --- a/targets/app/common/Game.cpp +++ b/targets/app/common/Game.cpp @@ -125,6 +125,7 @@ int Game::s_iHTMLFontSizesA[eHTMLSize_COUNT] = { 20, 13, 20, 26}; Game::Game() { + ZoneScopedN("Game::Game"); if (GAME_SETTINGS_PROFILE_DATA_BYTES != sizeof(GAME_SETTINGS)) { // 4J Stu - See comment for GAME_SETTINGS_PROFILE_DATA_BYTES in // Xbox_App.h @@ -250,6 +251,7 @@ Game::Game() { } void Game::DebugPrintf(const char* szFormat, ...) { + ZoneScopedN("Game::DebugPrintf"); #if !defined(_FINAL_BUILD) char buf[1024]; va_list ap; @@ -261,6 +263,7 @@ void Game::DebugPrintf(const char* szFormat, ...) { } void Game::DebugPrintf(int user, const char* szFormat, ...) { + ZoneScopedN("Game::DebugPrintf"); #if !defined(_FINAL_BUILD) if (user == USER_NONE) return; char buf[1024]; @@ -276,12 +279,14 @@ void Game::DebugPrintf(int user, const char* szFormat, ...) { } const wchar_t* Game::GetString(int iID) { + ZoneScopedN("Game::GetString"); // return L"Değişiklikler ve Yenilikler"; // return L"ÕÕÕÕÖÖÖÖ"; return app.m_stringTable->getString(iID); } void Game::SetAction(int iPad, eXuiAction action, void* param) { + ZoneScopedN("Game::SetAction"); if ((m_eXuiAction[iPad] == eAppAction_ReloadTexturePack) && (action == eAppAction_EthernetDisconnected)) { app.DebugPrintf( @@ -310,12 +315,14 @@ bool Game::IsAppPaused() { return m_bIsAppPaused; } void Game::SetAppPaused(bool val) { m_bIsAppPaused = val; } void Game::HandleButtonPresses() { + ZoneScopedN("Game::HandleButtonPresses"); for (int i = 0; i < 4; i++) { HandleButtonPresses(i); } } void Game::HandleButtonPresses(int iPad) { + ZoneScopedN("Game::HandleButtonPresses"); // // test an update of the profile data // void *pData=ProfileManager.GetGameDefinedProfileData(iPad); // @@ -332,6 +339,7 @@ void Game::HandleButtonPresses(int iPad) { bool Game::LoadInventoryMenu(int iPad, std::shared_ptr player, bool bNavigateBack) { + ZoneScopedN("Game::LoadInventoryMenu"); bool success = true; InventoryScreenInput* initData = new InventoryScreenInput(); @@ -353,6 +361,7 @@ bool Game::LoadInventoryMenu(int iPad, bool Game::LoadCreativeMenu(int iPad, std::shared_ptr player, bool bNavigateBack) { + ZoneScopedN("Game::LoadCreativeMenu"); bool success = true; InventoryScreenInput* initData = new InventoryScreenInput(); @@ -373,6 +382,7 @@ bool Game::LoadCreativeMenu(int iPad, bool Game::LoadCrafting2x2Menu(int iPad, std::shared_ptr player) { + ZoneScopedN("Game::LoadCrafting2x2Menu"); bool success = true; CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); @@ -397,6 +407,7 @@ bool Game::LoadCrafting2x2Menu(int iPad, bool Game::LoadCrafting3x3Menu(int iPad, std::shared_ptr player, int x, int y, int z) { + ZoneScopedN("Game::LoadCrafting3x3Menu"); bool success = true; CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); @@ -421,6 +432,7 @@ bool Game::LoadCrafting3x3Menu(int iPad, bool Game::LoadFireworksMenu(int iPad, std::shared_ptr player, int x, int y, int z) { + ZoneScopedN("Game::LoadFireworksMenu"); bool success = true; FireworksScreenInput* initData = new FireworksScreenInput(); @@ -445,6 +457,7 @@ bool Game::LoadEnchantingMenu(int iPad, std::shared_ptr inventory, int x, int y, int z, Level* level, const std::wstring& name) { + ZoneScopedN("Game::LoadEnchantingMenu"); bool success = true; EnchantingScreenInput* initData = new EnchantingScreenInput(); @@ -470,6 +483,7 @@ bool Game::LoadEnchantingMenu(int iPad, bool Game::LoadFurnaceMenu( int iPad, std::shared_ptr inventory, std::shared_ptr furnace) { + ZoneScopedN("Game::LoadFurnaceMenu"); bool success = true; FurnaceScreenInput* initData = new FurnaceScreenInput(); @@ -493,6 +507,7 @@ bool Game::LoadFurnaceMenu( bool Game::LoadBrewingStandMenu( int iPad, std::shared_ptr inventory, std::shared_ptr brewingStand) { + ZoneScopedN("Game::LoadBrewingStandMenu"); bool success = true; BrewingScreenInput* initData = new BrewingScreenInput(); @@ -516,6 +531,7 @@ bool Game::LoadBrewingStandMenu( bool Game::LoadContainerMenu(int iPad, std::shared_ptr inventory, std::shared_ptr container) { + ZoneScopedN("Game::LoadContainerMenu"); bool success = true; ContainerScreenInput* initData = new ContainerScreenInput(); @@ -547,6 +563,7 @@ bool Game::LoadContainerMenu(int iPad, bool Game::LoadTrapMenu(int iPad, std::shared_ptr inventory, std::shared_ptr trap) { + ZoneScopedN("Game::LoadTrapMenu"); bool success = true; TrapScreenInput* initData = new TrapScreenInput(); @@ -569,6 +586,7 @@ bool Game::LoadTrapMenu(int iPad, std::shared_ptr inventory, bool Game::LoadSignEntryMenu(int iPad, std::shared_ptr sign) { + ZoneScopedN("Game::LoadSignEntryMenu"); bool success = true; SignEntryScreenInput* initData = new SignEntryScreenInput(); @@ -586,6 +604,7 @@ bool Game::LoadSignEntryMenu(int iPad, bool Game::LoadRepairingMenu(int iPad, std::shared_ptr inventory, Level* level, int x, int y, int z) { + ZoneScopedN("Game::LoadRepairingMenu"); bool success = true; AnvilScreenInput* initData = new AnvilScreenInput(); @@ -609,6 +628,7 @@ bool Game::LoadTradingMenu(int iPad, std::shared_ptr inventory, std::shared_ptr trader, Level* level, const std::wstring& name) { + ZoneScopedN("Game::LoadTradingMenu"); bool success = true; TradingScreenInput* initData = new TradingScreenInput(); @@ -629,6 +649,7 @@ bool Game::LoadTradingMenu(int iPad, bool Game::LoadHopperMenu(int iPad, std::shared_ptr inventory, std::shared_ptr hopper) { + ZoneScopedN("Game::LoadHopperMenu"); bool success = true; HopperScreenInput* initData = new HopperScreenInput(); @@ -648,6 +669,7 @@ bool Game::LoadHopperMenu(int iPad, bool Game::LoadHopperMenu(int iPad, std::shared_ptr inventory, std::shared_ptr hopper) { + ZoneScopedN("Game::LoadHopperMenu"); bool success = true; HopperScreenInput* initData = new HopperScreenInput(); @@ -668,6 +690,7 @@ bool Game::LoadHorseMenu(int iPad, std::shared_ptr inventory, std::shared_ptr container, std::shared_ptr horse) { + ZoneScopedN("Game::LoadHorseMenu"); bool success = true; HorseScreenInput* initData = new HorseScreenInput(); @@ -688,6 +711,7 @@ bool Game::LoadHorseMenu(int iPad, bool Game::LoadBeaconMenu(int iPad, std::shared_ptr inventory, std::shared_ptr beacon) { + ZoneScopedN("Game::LoadBeaconMenu"); bool success = true; BeaconScreenInput* initData = new BeaconScreenInput(); @@ -708,6 +732,7 @@ bool Game::LoadBeaconMenu(int iPad, // GAME SETTINGS ////////////////////////////////////////////// void Game::InitGameSettings() { + ZoneScopedN("Game::InitGameSettings"); for (int i = 0; i < XUSER_MAX_COUNT; i++) { GameSettingsA[i] = (GAME_SETTINGS*)ProfileManager.GetGameDefinedProfileData(i); @@ -738,6 +763,7 @@ void Game::InitGameSettings() { int Game::SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings, const int iPad) { + ZoneScopedN("Game::SetDefaultOptions"); SetGameSettings(iPad, eGameSetting_MusicVolume, DEFAULT_VOLUME_LEVEL); SetGameSettings(iPad, eGameSetting_SoundFXVolume, DEFAULT_VOLUME_LEVEL); SetGameSettings(iPad, eGameSetting_Gamma, 50); @@ -836,6 +862,7 @@ int Game::SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings, int Game::DefaultOptionsCallback( void* pParam, C_4JProfile::PROFILESETTINGS* pSettings, const int iPad) { + ZoneScopedN("Game::DefaultOptionsCallback"); Game* pApp = (Game*)pParam; // flag the default options to be set @@ -856,6 +883,7 @@ int Game::OldProfileVersionCallback(void* pParam, unsigned char* pucData, const unsigned short usVersion, const int iPad) { + ZoneScopedN("Game::OldProfileVersionCallback"); // check what needs to be done with this version to update to the current // one @@ -991,6 +1019,7 @@ int Game::OldProfileVersionCallback(void* pParam, } void Game::ApplyGameSettingsChanged(int iPad) { + ZoneScopedN("Game::ApplyGameSettingsChanged"); ActionGameSettings(iPad, eGameSetting_MusicVolume); ActionGameSettings(iPad, eGameSetting_SoundFXVolume); ActionGameSettings(iPad, eGameSetting_Gamma); @@ -1024,6 +1053,7 @@ void Game::ApplyGameSettingsChanged(int iPad) { } void Game::ActionGameSettings(int iPad, eGameSetting eVal) { + ZoneScopedN("Game::ActionGameSettings"); Minecraft* pMinecraft = Minecraft::GetInstance(); switch (eVal) { case eGameSetting_MusicVolume: @@ -1264,12 +1294,14 @@ void Game::ActionGameSettings(int iPad, eGameSetting eVal) { } void Game::SetPlayerSkin(int iPad, const std::wstring& name) { + ZoneScopedN("Game::SetPlayerSkin"); std::uint32_t skinId = app.getSkinIdFromPath(name); SetPlayerSkin(iPad, skinId); } void Game::SetPlayerSkin(int iPad, std::uint32_t dwSkinId) { + ZoneScopedN("Game::SetPlayerSkin"); DebugPrintf("Setting skin for %d to %08X\n", iPad, dwSkinId); GameSettingsA[iPad]->dwSelectedSkin = dwSkinId; @@ -1281,10 +1313,12 @@ void Game::SetPlayerSkin(int iPad, std::uint32_t dwSkinId) { } std::wstring Game::GetPlayerSkinName(int iPad) { + ZoneScopedN("Game::GetPlayerSkinName"); return app.getSkinPathFromId(GameSettingsA[iPad]->dwSelectedSkin); } std::uint32_t Game::GetPlayerSkinId(int iPad) { + ZoneScopedN("Game::GetPlayerSkinId"); // 4J-PB -check the user has rights to use this skin - they may have had at // some point but the entitlement has been removed. DLCPack* Pack = nullptr; @@ -1320,16 +1354,19 @@ std::uint32_t Game::GetPlayerSkinId(int iPad) { } std::uint32_t Game::GetAdditionalModelParts(int iPad) { + ZoneScopedN("Game::GetAdditionalModelParts"); return m_dwAdditionalModelParts[iPad]; } void Game::SetPlayerCape(int iPad, const std::wstring& name) { + ZoneScopedN("Game::SetPlayerCape"); std::uint32_t capeId = Player::getCapeIdFromPath(name); SetPlayerCape(iPad, capeId); } void Game::SetPlayerCape(int iPad, std::uint32_t dwCapeId) { + ZoneScopedN("Game::SetPlayerCape"); DebugPrintf("Setting cape for %d to %08X\n", iPad, dwCapeId); GameSettingsA[iPad]->dwSelectedCape = dwCapeId; @@ -1344,15 +1381,18 @@ void Game::SetPlayerCape(int iPad, std::uint32_t dwCapeId) { } std::wstring Game::GetPlayerCapeName(int iPad) { + ZoneScopedN("Game::GetPlayerCapeName"); return Player::getCapePathFromId(GameSettingsA[iPad]->dwSelectedCape); } std::uint32_t Game::GetPlayerCapeId(int iPad) { + ZoneScopedN("Game::GetPlayerCapeId"); return GameSettingsA[iPad]->dwSelectedCape; } void Game::SetPlayerFavoriteSkin(int iPad, int iIndex, unsigned int uiSkinID) { + ZoneScopedN("Game::SetPlayerFavoriteSkin"); DebugPrintf("Setting favorite skin for %d to %08X\n", iPad, uiSkinID); GameSettingsA[iPad]->uiFavoriteSkinA[iIndex] = uiSkinID; @@ -1360,19 +1400,23 @@ void Game::SetPlayerFavoriteSkin(int iPad, int iIndex, } unsigned int Game::GetPlayerFavoriteSkin(int iPad, int iIndex) { + ZoneScopedN("Game::GetPlayerFavoriteSkin"); return GameSettingsA[iPad]->uiFavoriteSkinA[iIndex]; } unsigned char Game::GetPlayerFavoriteSkinsPos(int iPad) { + ZoneScopedN("Game::GetPlayerFavoriteSkinsPos"); return GameSettingsA[iPad]->ucCurrentFavoriteSkinPos; } void Game::SetPlayerFavoriteSkinsPos(int iPad, int iPos) { + ZoneScopedN("Game::SetPlayerFavoriteSkinsPos"); GameSettingsA[iPad]->ucCurrentFavoriteSkinPos = (unsigned char)iPos; GameSettingsA[iPad]->bSettingsChanged = true; } unsigned int Game::GetPlayerFavoriteSkinsCount(int iPad) { + ZoneScopedN("Game::GetPlayerFavoriteSkinsCount"); unsigned int uiCount = 0; for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { if (GameSettingsA[iPad]->uiFavoriteSkinA[i] != 0xFFFFFFFF) { @@ -1385,6 +1429,7 @@ unsigned int Game::GetPlayerFavoriteSkinsCount(int iPad) { } void Game::ValidateFavoriteSkins(int iPad) { + ZoneScopedN("Game::ValidateFavoriteSkins"); unsigned int uiCount = GetPlayerFavoriteSkinsCount(iPad); // remove invalid skins @@ -1421,26 +1466,31 @@ void Game::ValidateFavoriteSkins(int iPad) { // Mash-up pack worlds void Game::HideMashupPackWorld(int iPad, unsigned int iMashupPackID) { + ZoneScopedN("Game::HideMashupPackWorld"); unsigned int uiPackID = iMashupPackID - 1024; // mash-up ids start at 1024 GameSettingsA[iPad]->uiMashUpPackWorldsDisplay &= ~(1 << uiPackID); GameSettingsA[iPad]->bSettingsChanged = true; } void Game::EnableMashupPackWorlds(int iPad) { + ZoneScopedN("Game::EnableMashupPackWorlds"); GameSettingsA[iPad]->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; GameSettingsA[iPad]->bSettingsChanged = true; } unsigned int Game::GetMashupPackWorlds(int iPad) { + ZoneScopedN("Game::GetMashupPackWorlds"); return GameSettingsA[iPad]->uiMashUpPackWorldsDisplay; } void Game::SetMinecraftLanguage(int iPad, unsigned char ucLanguage) { + ZoneScopedN("Game::SetMinecraftLanguage"); GameSettingsA[iPad]->ucLanguage = ucLanguage; GameSettingsA[iPad]->bSettingsChanged = true; } unsigned char Game::GetMinecraftLanguage(int iPad) { + ZoneScopedN("Game::GetMinecraftLanguage"); // if there are no game settings read yet, return the default language if (GameSettingsA[iPad] == nullptr) { return 0; @@ -1450,11 +1500,13 @@ unsigned char Game::GetMinecraftLanguage(int iPad) { } void Game::SetMinecraftLocale(int iPad, unsigned char ucLocale) { + ZoneScopedN("Game::SetMinecraftLocale"); GameSettingsA[iPad]->ucLocale = ucLocale; GameSettingsA[iPad]->bSettingsChanged = true; } unsigned char Game::GetMinecraftLocale(int iPad) { + ZoneScopedN("Game::GetMinecraftLocale"); // if there are no game settings read yet, return the default language if (GameSettingsA[iPad] == nullptr) { return 0; @@ -1465,6 +1517,7 @@ unsigned char Game::GetMinecraftLocale(int iPad) { void Game::SetGameSettings(int iPad, eGameSetting eVal, unsigned char ucVal) { + ZoneScopedN("Game::SetGameSettings"); // Minecraft *pMinecraft=Minecraft::GetInstance(); switch (eVal) { @@ -1871,12 +1924,14 @@ void Game::SetGameSettings(int iPad, eGameSetting eVal, } unsigned char Game::GetGameSettings(eGameSetting eVal) { + ZoneScopedN("Game::GetGameSettings"); int iPad = ProfileManager.GetPrimaryPad(); return GetGameSettings(iPad, eVal); } unsigned char Game::GetGameSettings(int iPad, eGameSetting eVal) { + ZoneScopedN("Game::GetGameSettings"); switch (eVal) { case eGameSetting_MusicVolume: return GameSettingsA[iPad]->ucMusicVolume; @@ -2018,6 +2073,7 @@ unsigned char Game::GetGameSettings(int iPad, eGameSetting eVal) { void Game::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPad) { + ZoneScopedN("Game::CheckGameSettingsChanged"); // If the settings have changed, write them to the profile if (iPad == XUSER_INDEX_ANY) { @@ -2036,6 +2092,7 @@ void Game::CheckGameSettingsChanged(bool bOverride5MinuteTimer, } void Game::ClearGameSettingsChangedFlag(int iPad) { + ZoneScopedN("Game::ClearGameSettingsChangedFlag"); GameSettingsA[iPad]->bSettingsChanged = false; } @@ -2049,6 +2106,7 @@ unsigned int Game::GetGameSettingsDebugMask( int iPad, bool bOverridePlayer) // bOverridePlayer is to force the send for // the server to get the read options { + ZoneScopedN("Game::GetGameSettingsDebugMask"); return 0; } @@ -2062,6 +2120,7 @@ unsigned int Game::GetGameSettingsDebugMask( int iPad, bool bOverridePlayer) // bOverridePlayer is to force the send for // the server to get the read options { + ZoneScopedN("Game::GetGameSettingsDebugMask"); if (iPad == -1) { iPad = ProfileManager.GetPrimaryPad(); } @@ -2078,6 +2137,7 @@ unsigned int Game::GetGameSettingsDebugMask( } void Game::SetGameSettingsDebugMask(int iPad, unsigned int uiVal) { + ZoneScopedN("Game::SetGameSettingsDebugMask"); #if !defined(_CONTENT_PACKAGE) GameSettingsA[iPad]->bSettingsChanged = true; GameSettingsA[iPad]->uiDebugBitmask = uiVal; @@ -2094,6 +2154,7 @@ void Game::SetGameSettingsDebugMask(int iPad, unsigned int uiVal) { } void Game::ActionDebugMask(int iPad, bool bSetAllClear) { + ZoneScopedN("Game::ActionDebugMask"); unsigned int ulBitmask = app.GetGameSettingsDebugMask(iPad); if (bSetAllClear) ulBitmask = 0L; @@ -2198,18 +2259,20 @@ void Game::ActionDebugMask(int iPad, bool bSetAllClear) { int Game::displaySavingMessage(C4JStorage::ESavingMessage eVal, int iPad) { + ZoneScopedN("Game::displaySavingMessage"); ui.ShowSavingMessage(iPad, eVal); return 0; } void Game::SetActionConfirmed(void* param) { + ZoneScopedN("Game::SetActionConfirmed"); XuiActionParam* actionInfo = (XuiActionParam*)param; app.SetAction(actionInfo->iPad, actionInfo->action); } void Game::HandleXuiActions(void) { - ZoneScoped; + ZoneScopedN("Game::HandleXuiActions"); eXuiAction eAction; eTMSAction eTMS; void* param; @@ -3632,6 +3695,7 @@ void Game::HandleXuiActions(void) { int Game::BannedLevelDialogReturned( void* pParam, int iPad, const C4JStorage::EMessageResult result) { + ZoneScopedN("Game::BannedLevelDialogReturned"); Game* pApp = (Game*)pParam; // Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -3647,6 +3711,7 @@ int Game::BannedLevelDialogReturned( return 0; } void Game::loadMediaArchive() { + ZoneScopedN("Game::loadMediaArchive"); std::wstring mediapath = L""; #if _WINDOWS64 @@ -3672,6 +3737,7 @@ void Game::loadMediaArchive() { } void Game::loadStringTable() { + ZoneScopedN("Game::loadStringTable"); if (m_stringTable != nullptr) { // we need to unload the current std::string table, this is a reload delete m_stringTable; @@ -3690,6 +3756,7 @@ void Game::loadStringTable() { int Game::PrimaryPlayerSignedOutReturned( void* pParam, int iPad, const C4JStorage::EMessageResult) { + ZoneScopedN("Game::PrimaryPlayerSignedOutReturned"); // Game* pApp = (Game*)pParam; // Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -3709,6 +3776,7 @@ int Game::PrimaryPlayerSignedOutReturned( int Game::EthernetDisconnectReturned( void* pParam, int iPad, const C4JStorage::EMessageResult) { + ZoneScopedN("Game::EthernetDisconnectReturned"); // Game* pApp = (Game*)pParam; Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -3725,6 +3793,7 @@ int Game::EthernetDisconnectReturned( } int Game::SignoutExitWorldThreadProc(void* lpParameter) { + ZoneScopedN("Game::SignoutExitWorldThreadProc"); // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running Compression::UseDefaultThreadStorage(); @@ -3839,6 +3908,7 @@ int Game::SignoutExitWorldThreadProc(void* lpParameter) { int Game::UnlockFullInviteReturned(void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::UnlockFullInviteReturned"); // Game* pApp = (Game*)pParam; Minecraft* pMinecraft = Minecraft::GetInstance(); bool bNoPlayer; @@ -3856,11 +3926,13 @@ int Game::UnlockFullInviteReturned(void* pParam, int iPad, int Game::UnlockFullSaveReturned(void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::UnlockFullSaveReturned"); return 0; } int Game::UnlockFullExitReturned(void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::UnlockFullExitReturned"); Game* pApp = (Game*)pParam; Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -3874,6 +3946,7 @@ int Game::UnlockFullExitReturned(void* pParam, int iPad, int Game::TrialOverReturned(void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::TrialOverReturned"); Game* pApp = (Game*)pParam; Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -3885,12 +3958,14 @@ int Game::TrialOverReturned(void* pParam, int iPad, } void Game::ProfileReadErrorCallback(void* pParam) { + ZoneScopedN("Game::ProfileReadErrorCallback"); Game* pApp = (Game*)pParam; int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); pApp->SetAction(iPrimaryPlayer, eAppAction_ProfileReadError); } void Game::ClearSignInChangeUsersMask() { + ZoneScopedN("Game::ClearSignInChangeUsersMask"); // 4J-PB - When in the main menu, the user is on pad 0, and any change they // make to their profile will be to pad 0 data If they then go in as a // secondary player to a splitscreen game, their profile will not be read @@ -3912,6 +3987,7 @@ void Game::ClearSignInChangeUsersMask() { void Game::SignInChangeCallback(void* pParam, bool bPrimaryPlayerChanged, unsigned int uiSignInData) { + ZoneScopedN("Game::SignInChangeCallback"); Game* pApp = (Game*)pParam; // check if the primary player signed out int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); @@ -4086,6 +4162,7 @@ void Game::SignInChangeCallback(void* pParam, void Game::NotificationsCallback(void* pParam, std::uint32_t dwNotification, unsigned int uiParam) { + ZoneScopedN("Game::NotificationsCallback"); Game* pClass = (Game*)pParam; // push these on to the notifications to be handled in qnet's dowork @@ -4132,6 +4209,7 @@ void Game::NotificationsCallback(void* pParam, #if defined(_DEBUG_MENUS_ENABLED) bool Game::DebugArtToolsOn() { + ZoneScopedN("Game::DebugArtToolsOn"); return DebugSettingsOn() && (GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_ArtTools)) != 0; @@ -4139,6 +4217,7 @@ bool Game::DebugArtToolsOn() { #endif void Game::SetDebugSequence(const char* pchSeq) { + ZoneScopedN("Game::SetDebugSequence"); InputManager.SetDebugSequence(pchSeq, [this]() -> int { // printf("sequence matched\n"); m_bDebugOptions = !m_bDebugOptions; @@ -4157,6 +4236,7 @@ void Game::SetDebugSequence(const char* pchSeq) { } int Game::GetLocalPlayerCount(void) { + ZoneScopedN("Game::GetLocalPlayerCount"); int iPlayerC = 0; Minecraft* pMinecraft = Minecraft::GetInstance(); for (int i = 0; i < XUSER_MAX_COUNT; i++) { @@ -4170,6 +4250,7 @@ int Game::GetLocalPlayerCount(void) { int Game::MarketplaceCountsCallback( void* pParam, C4JStorage::DLC_TMS_DETAILS* pTMSDetails, int iPad) { + ZoneScopedN("Game::MarketplaceCountsCallback"); app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n", pTMSDetails->dwNewOffers, pTMSDetails->dwTotalOffers); @@ -4185,6 +4266,7 @@ int Game::MarketplaceCountsCallback( } bool Game::StartInstallDLCProcess(int iPad) { + ZoneScopedN("Game::StartInstallDLCProcess"); app.DebugPrintf("--- Game::StartInstallDLCProcess: pad=%i.\n", iPad); @@ -4217,6 +4299,7 @@ bool Game::StartInstallDLCProcess(int iPad) { // Installed DLC callback int Game::dlcInstalledCallback(int iInstalledC, int iPad) { + ZoneScopedN("Game::dlcInstalledCallback"); DebugPrintf( "--- Game::dlcInstalledCallback: totalDLC=%i, pad=%i.\n", iInstalledC, iPad); @@ -4226,6 +4309,7 @@ int Game::dlcInstalledCallback(int iInstalledC, int iPad) { } void Game::MountNextDLC(int iPad) { + ZoneScopedN("Game::MountNextDLC"); app.DebugPrintf("--- Game::MountNextDLC: pad=%i.\n", iPad); if (m_iTotalDLCInstalled < m_iTotalDLC) { // Mount it @@ -4272,6 +4356,7 @@ void Game::MountNextDLC(int iPad) { int Game::dlcMountedCallback(int iPad, std::uint32_t dwErr, std::uint32_t dwLicenceMask) { + ZoneScopedN("Game::dlcMountedCallback"); #if defined(_WINDOWS64) DebugPrintf("--- Game::dlcMountedCallback\n"); @@ -4363,6 +4448,7 @@ int Game::dlcMountedCallback(int iPad, std::uint32_t dwErr, // } void Game::HandleDLC(DLCPack* pack) { + ZoneScopedN("Game::HandleDLC"); unsigned int dwFilesProcessed = 0; #if defined(_WINDOWS64) || defined(__linux__) std::vector dlcFilenames; @@ -4388,6 +4474,7 @@ void Game::HandleDLC(DLCPack* pack) { // Desc: Initializes the timer variables //------------------------------------------------------------------------------------- void Game::InitTime() { + ZoneScopedN("Game::InitTime"); // Save the start time m_Time.qwTime = time_util::clock::now(); @@ -4402,7 +4489,7 @@ void Game::InitTime() { // Desc: Updates the elapsed time since our last frame. //------------------------------------------------------------------------------------- void Game::UpdateTime() { - ZoneScoped; + ZoneScopedN("Game::UpdateTime"); auto qwNewTime = time_util::clock::now(); auto qwDeltaTime = qwNewTime - m_Time.qwTime; @@ -4414,6 +4501,7 @@ void Game::UpdateTime() { } bool Game::isXuidNotch(PlayerUID xuid) { + ZoneScopedN("Game::isXuidNotch"); if (m_xuidNotch != INVALID_XUID && xuid != INVALID_XUID) { return ProfileManager.AreXUIDSEqual(xuid, m_xuidNotch); } @@ -4421,6 +4509,7 @@ bool Game::isXuidNotch(PlayerUID xuid) { } bool Game::isXuidDeadmau5(PlayerUID xuid) { + ZoneScopedN("Game::isXuidDeadmau5"); auto it = MojangData.find(xuid); // 4J Stu - The .at and [] accessors // insert elements if they don't exist if (it != MojangData.end()) { @@ -4436,6 +4525,7 @@ bool Game::isXuidDeadmau5(PlayerUID xuid) { void Game::AddMemoryTextureFile(const std::wstring& wName, std::uint8_t* pbData, unsigned int byteCount) { + ZoneScopedN("Game::AddMemoryTextureFile"); std::lock_guard lock(csMemFilesLock); // check it's not already in PMEMDATA pData = nullptr; @@ -4473,6 +4563,7 @@ void Game::AddMemoryTextureFile(const std::wstring& wName, } void Game::RemoveMemoryTextureFile(const std::wstring& wName) { + ZoneScopedN("Game::RemoveMemoryTextureFile"); std::lock_guard lock(csMemFilesLock); auto it = m_MEM_Files.find(wName); @@ -4495,6 +4586,7 @@ void Game::RemoveMemoryTextureFile(const std::wstring& wName) { } bool Game::DefaultCapeExists() { + ZoneScopedN("Game::DefaultCapeExists"); std::wstring wTex = L"Special_Cape.png"; bool val = false; @@ -4508,6 +4600,7 @@ bool Game::DefaultCapeExists() { } bool Game::IsFileInMemoryTextures(const std::wstring& wName) { + ZoneScopedN("Game::IsFileInMemoryTextures"); bool val = false; { @@ -4522,6 +4615,7 @@ bool Game::IsFileInMemoryTextures(const std::wstring& wName) { void Game::GetMemFileDetails(const std::wstring& wName, std::uint8_t** ppbData, unsigned int* pByteCount) { + ZoneScopedN("Game::GetMemFileDetails"); std::lock_guard lock(csMemFilesLock); auto it = m_MEM_Files.find(wName); if (it != m_MEM_Files.end()) { @@ -4533,6 +4627,7 @@ void Game::GetMemFileDetails(const std::wstring& wName, void Game::AddMemoryTPDFile(int iConfig, std::uint8_t* pbData, unsigned int byteCount) { + ZoneScopedN("Game::AddMemoryTPDFile"); std::lock_guard lock(csMemTPDLock); // check it's not already in PMEMDATA pData = nullptr; @@ -4548,6 +4643,7 @@ void Game::AddMemoryTPDFile(int iConfig, std::uint8_t* pbData, } void Game::RemoveMemoryTPDFile(int iConfig) { + ZoneScopedN("Game::RemoveMemoryTPDFile"); std::lock_guard lock(csMemTPDLock); // check it's not already in PMEMDATA pData = nullptr; @@ -4563,6 +4659,7 @@ void Game::RemoveMemoryTPDFile(int iConfig) { int Game::GetTPConfigVal(wchar_t* pwchDataFile) { return -1; } #endif bool Game::IsFileInTPD(int iConfig) { + ZoneScopedN("Game::IsFileInTPD"); bool val = false; { @@ -4576,6 +4673,7 @@ bool Game::IsFileInTPD(int iConfig) { void Game::GetTPD(int iConfig, std::uint8_t** ppbData, unsigned int* pByteCount) { + ZoneScopedN("Game::GetTPD"); std::lock_guard lock(csMemTPDLock); auto it = m_MEM_TPD.find(iConfig); if (it != m_MEM_TPD.end()) { @@ -4619,6 +4717,7 @@ void Game::ExitGame() {} void Game::ProcessInvite(std::uint32_t dwUserIndex, std::uint32_t dwLocalUsersMask, const INVITE_INFO* pInviteInfo) { + ZoneScopedN("Game::ProcessInvite"); m_InviteData.dwUserIndex = dwUserIndex; m_InviteData.dwLocalUsersMask = dwLocalUsersMask; m_InviteData.pInviteInfo = pInviteInfo; @@ -4628,6 +4727,7 @@ void Game::ProcessInvite(std::uint32_t dwUserIndex, int Game::ExitAndJoinFromInvite(void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::ExitAndJoinFromInvite"); Game* pApp = (Game*)pParam; // Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -4641,6 +4741,7 @@ int Game::ExitAndJoinFromInvite(void* pParam, int iPad, int Game::ExitAndJoinFromInviteSaveDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::ExitAndJoinFromInviteSaveDialogReturned"); Game* pClass = (Game*)pParam; // Exit with or without saving // Decline means save in this dialog @@ -4716,6 +4817,7 @@ int Game::ExitAndJoinFromInviteSaveDialogReturned( int Game::WarningTrialTexturePackReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::WarningTrialTexturePackReturned"); // 4J Stu - I added this in when fixing an X1 bug. We should probably add // this as well but I don't have time to test all platforms atm @@ -4724,6 +4826,7 @@ int Game::WarningTrialTexturePackReturned( int Game::ExitAndJoinFromInviteAndSaveReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::ExitAndJoinFromInviteAndSaveReturned"); // Game* pClass = (Game*)pParam; // results switched for this dialog @@ -4769,6 +4872,7 @@ int Game::ExitAndJoinFromInviteAndSaveReturned( int Game::ExitAndJoinFromInviteDeclineSaveReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::ExitAndJoinFromInviteDeclineSaveReturned"); // results switched for this dialog if (result == C4JStorage::EMessage_ResultDecline) { MinecraftServer::getInstance()->setSaveOnExit(false); @@ -4830,6 +4934,7 @@ TIPSTRUCT Game::m_TriviaTipA[MAX_TIPS_TRIVIATIP] = { Random* Game::TipRandom = new Random(); int Game::TipsSortFunction(const void* a, const void* b) { + ZoneScopedN("Game::TipsSortFunction"); // 4jcraft, scince the sortvalues can be negative, i changed it // to a three way comparison, // scince subtracting of signed integers can cause overflow. @@ -4848,6 +4953,7 @@ int Game::TipsSortFunction(const void* a, const void* b) { } void Game::InitialiseTips() { + ZoneScopedN("Game::InitialiseTips"); // We'll randomise the tips at start up based on their priority memset(m_TipIDA, 0, sizeof(m_TipIDA)); @@ -4906,6 +5012,7 @@ void Game::InitialiseTips() { } int Game::GetNextTip() { + ZoneScopedN("Game::GetNextTip"); static bool bShowSkinDLCTip = true; if (app.GetNewDLCAvailable() && app.DisplayNewDLCTip()) { return IDS_TIPS_GAMETIP_NEWDLC; @@ -4930,17 +5037,20 @@ int Game::GetNextTip() { } int Game::GetHTMLColour(eMinecraftColour colour) { + ZoneScopedN("Game::GetHTMLColour"); Minecraft* pMinecraft = Minecraft::GetInstance(); return pMinecraft->skins->getSelected()->getColourTable()->getColour( colour); } int Game::GetHTMLFontSize(EHTMLFontSize size) { + ZoneScopedN("Game::GetHTMLFontSize"); return s_iHTMLFontSizesA[size]; } std::wstring Game::FormatHTMLString( int iPad, const std::wstring& desc, int shadowColour /*= 0xFFFFFFFF*/) { + ZoneScopedN("Game::FormatHTMLString"); std::wstring text(desc); wchar_t replacements[64]; @@ -5108,6 +5218,7 @@ std::wstring Game::FormatHTMLString( std::wstring Game::GetActionReplacement(int iPad, unsigned char ucAction) { + ZoneScopedN("Game::GetActionReplacement"); unsigned int input = InputManager.GetGameJoypadMaps( InputManager.GetJoypadMapVal(iPad), ucAction); @@ -5175,6 +5286,7 @@ std::wstring Game::GetActionReplacement(int iPad, } std::wstring Game::GetVKReplacement(unsigned int uiVKey) { + ZoneScopedN("Game::GetVKReplacement"); std::wstring replacement = L""; switch (uiVKey) { case VK_PAD_A: @@ -5241,6 +5353,7 @@ std::wstring Game::GetVKReplacement(unsigned int uiVKey) { } std::wstring Game::GetIconReplacement(unsigned int uiIcon) { + ZoneScopedN("Game::GetIconReplacement"); wchar_t string[128]; #if defined(_WIN64) @@ -5276,6 +5389,7 @@ std::unordered_map Game::DLCInfo_SkinName; int32_t Game::RegisterMojangData(wchar_t* pXuidName, PlayerUID xuid, wchar_t* pSkin, wchar_t* pCape) { + ZoneScopedN("Game::RegisterMojangData"); int32_t hr = 0; eXUID eTempXuid = eXUID_Undefined; MOJANG_DATA* pMojangData = nullptr; @@ -5306,10 +5420,12 @@ int32_t Game::RegisterMojangData(wchar_t* pXuidName, PlayerUID xuid, } MOJANG_DATA* Game::GetMojangDataForXuid(PlayerUID xuid) { + ZoneScopedN("Game::GetMojangDataForXuid"); return MojangData[xuid]; } int32_t Game::RegisterConfigValues(wchar_t* pType, int iValue) { + ZoneScopedN("Game::RegisterConfigValues"); int32_t hr = 0; // #ifdef 0 @@ -5344,6 +5460,7 @@ int32_t Game::RegisterDLCData(wchar_t* pType, wchar_t* pBannerName, wchar_t* pFirstSkin, unsigned int uiSortIndex, int iConfig, wchar_t* pDataFile) { + ZoneScopedN("Game::RegisterDLCData"); int32_t hr = 0; DLC_INFO* pDLCData = new DLC_INFO; memset(pDLCData, 0, sizeof(DLC_INFO)); @@ -5394,6 +5511,7 @@ int32_t Game::RegisterDLCData(wchar_t* pType, wchar_t* pBannerName, wchar_t* pFirstSkin, unsigned int uiSortIndex, int iConfig, wchar_t* pDataFile) { + ZoneScopedN("Game::RegisterDLCData"); fprintf(stderr, "warning: Game::RegisterDLCData unimplemented for " "platform `__linux__`\n"); @@ -5404,6 +5522,7 @@ int32_t Game::RegisterDLCData(wchar_t* pType, wchar_t* pBannerName, int32_t Game::RegisterDLCData(char* pchDLCName, unsigned int uiSortIndex, char* pchImageURL) { + ZoneScopedN("Game::RegisterDLCData"); // on PS3 we get all the required info from the name char chDLCType[3]; int32_t hr = 0; @@ -5450,6 +5569,7 @@ int32_t Game::RegisterDLCData(char* pchDLCName, bool Game::GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, uint64_t* pullVal) { + ZoneScopedN("Game::GetDLCFullOfferIDForSkinID"); auto it = DLCInfo_SkinName.find(FirstSkin); if (it == DLCInfo_SkinName.end()) { return false; @@ -5460,6 +5580,7 @@ bool Game::GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, } bool Game::GetDLCFullOfferIDForPackID(const int iPackID, uint64_t* pullVal) { + ZoneScopedN("Game::GetDLCFullOfferIDForPackID"); auto it = DLCTextures_PackID.find(iPackID); if (it == DLCTextures_PackID.end()) { *pullVal = (uint64_t)0; @@ -5470,6 +5591,7 @@ bool Game::GetDLCFullOfferIDForPackID(const int iPackID, } } DLC_INFO* Game::GetDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial) { + ZoneScopedN("Game::GetDLCInfoForTrialOfferID"); // DLC_INFO *pDLCInfo=NULL; if (DLCInfo_Trial.size() > 0) { auto it = DLCInfo_Trial.find(ullOfferID_Trial); @@ -5485,6 +5607,7 @@ DLC_INFO* Game::GetDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial) { } DLC_INFO* Game::GetDLCInfoTrialOffer(int iIndex) { + ZoneScopedN("Game::GetDLCInfoTrialOffer"); std::unordered_map::iterator it = DLCInfo_Trial.begin(); @@ -5495,6 +5618,7 @@ DLC_INFO* Game::GetDLCInfoTrialOffer(int iIndex) { return it->second; } DLC_INFO* Game::GetDLCInfoFullOffer(int iIndex) { + ZoneScopedN("Game::GetDLCInfoFullOffer"); std::unordered_map::iterator it = DLCInfo_Full.begin(); for (int i = 0; i < iIndex; i++) { @@ -5504,6 +5628,7 @@ DLC_INFO* Game::GetDLCInfoFullOffer(int iIndex) { return it->second; } uint64_t Game::GetDLCInfoTexturesFullOffer(int iIndex) { + ZoneScopedN("Game::GetDLCInfoTexturesFullOffer"); std::unordered_map::iterator it = DLCTextures_PackID.begin(); for (int i = 0; i < iIndex; i++) { @@ -5514,6 +5639,7 @@ uint64_t Game::GetDLCInfoTexturesFullOffer(int iIndex) { } DLC_INFO* Game::GetDLCInfoForFullOfferID(uint64_t ullOfferID_Full) { + ZoneScopedN("Game::GetDLCInfoForFullOfferID"); if (DLCInfo_Full.size() > 0) { auto it = DLCInfo_Full.find(ullOfferID_Full); @@ -5528,6 +5654,7 @@ DLC_INFO* Game::GetDLCInfoForFullOfferID(uint64_t ullOfferID_Full) { } void Game::lockSaveNotification() { + ZoneScopedN("Game::lockSaveNotification"); std::lock_guard lock(m_saveNotificationMutex); if (m_saveNotificationDepth++ == 0) { if (g_NetworkManager @@ -5547,6 +5674,7 @@ void Game::lockSaveNotification() { } void Game::unlockSaveNotification() { + ZoneScopedN("Game::unlockSaveNotification"); std::lock_guard lock(m_saveNotificationMutex); if (--m_saveNotificationDepth == 0) { if (g_NetworkManager @@ -5566,7 +5694,7 @@ void Game::unlockSaveNotification() { } int Game::RemoteSaveThreadProc(void* lpParameter) { - ZoneScoped; + ZoneScopedN("Game::RemoteSaveThreadProc"); // The game should be stopped while we are doing this, but the connections // ticks may try to create some AABB's or Vec3's Compression::UseDefaultThreadStorage(); @@ -5614,6 +5742,7 @@ int Game::RemoteSaveThreadProc(void* lpParameter) { } void Game::ExitGameFromRemoteSave(void* lpParameter) { + ZoneScopedN("Game::ExitGameFromRemoteSave"); int primaryPad = ProfileManager.GetPrimaryPad(); unsigned int uiIDA[3]; @@ -5627,6 +5756,7 @@ void Game::ExitGameFromRemoteSave(void* lpParameter) { int Game::ExitGameFromRemoteSaveDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::ExitGameFromRemoteSaveDialogReturned"); // CScene_Pause* pClass = (CScene_Pause*)pParam; // results switched for this dialog @@ -5646,6 +5776,7 @@ int Game::ExitGameFromRemoteSaveDialogReturned( } void Game::SetSpecialTutorialCompletionFlag(int iPad, int index) { + ZoneScopedN("Game::SetSpecialTutorialCompletionFlag"); if (index >= 0 && index < 32 && GameSettingsA[iPad] != nullptr) { GameSettingsA[iPad]->uiSpecialTutorialBitmask |= (1 << index); } @@ -5654,12 +5785,14 @@ void Game::SetSpecialTutorialCompletionFlag(int iPad, int index) { // BANNED LIST FUNCTIONS void Game::SetUniqueMapName(char* pszUniqueMapName) { + ZoneScopedN("Game::SetUniqueMapName"); memcpy(m_pszUniqueMapName, pszUniqueMapName, 14); } char* Game::GetUniqueMapName(void) { return m_pszUniqueMapName; } void Game::InvalidateBannedList(int iPad) { + ZoneScopedN("Game::InvalidateBannedList"); if (m_bRead_BannedListA[iPad] == true) { m_bRead_BannedListA[iPad] = false; SetBanListCheck(iPad, false); @@ -5675,6 +5808,7 @@ void Game::InvalidateBannedList(int iPad) { void Game::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char* pszLevelName, bool bWriteToTMS) { + ZoneScopedN("Game::AddLevelToBannedLevelList"); // we will have retrieved the banned level list from TMS, so add this one to // it and write it back to TMS @@ -5710,6 +5844,7 @@ void Game::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, bool Game::IsInBannedLevelList(int iPad, PlayerUID xuid, char* pszLevelName) { + ZoneScopedN("Game::IsInBannedLevelList"); for (auto it = m_vBannedListA[iPad]->begin(); it != m_vBannedListA[iPad]->end(); ++it) { PBANNEDLISTDATA pData = *it; @@ -5724,6 +5859,7 @@ bool Game::IsInBannedLevelList(int iPad, PlayerUID xuid, void Game::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, char* pszLevelName) { + ZoneScopedN("Game::RemoveLevelFromBannedLevelList"); // bool bFound=false; // bool bRes; @@ -5768,6 +5904,7 @@ void Game::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, // function to add credits for the DLC packs void Game::AddCreditText(const wchar_t* lpStr) { + ZoneScopedN("Game::AddCreditText"); DebugPrintf("ADDING CREDIT - %ls\n", lpStr); // add a std::string from the DLC to a credits std::vector SCreditTextItemDef* pCreditStruct = new SCreditTextItemDef; @@ -5781,6 +5918,7 @@ void Game::AddCreditText(const wchar_t* lpStr) { } bool Game::AlreadySeenCreditText(const std::wstring& wstemp) { + ZoneScopedN("Game::AlreadySeenCreditText"); for (unsigned int i = 0; i < m_vCreditText.size(); i++) { std::wstring temp = m_vCreditText.at(i); @@ -5796,10 +5934,12 @@ bool Game::AlreadySeenCreditText(const std::wstring& wstemp) { } unsigned int Game::GetDLCCreditsCount() { + ZoneScopedN("Game::GetDLCCreditsCount"); return (unsigned int)vDLCCredits.size(); } SCreditTextItemDef* Game::GetDLCCredits(int iIndex) { + ZoneScopedN("Game::GetDLCCredits"); return vDLCCredits.at(iIndex); } @@ -5807,12 +5947,14 @@ SCreditTextItemDef* Game::GetDLCCredits(int iIndex) { void Game::SetGameHostOption(eGameHostOption eVal, unsigned int uiVal) { + ZoneScopedN("Game::SetGameHostOption"); SetGameHostOption(m_uiGameHostSettings, eVal, uiVal); } void Game::SetGameHostOption(unsigned int& uiHostSettings, eGameHostOption eVal, unsigned int uiVal) { + ZoneScopedN("Game::SetGameHostOption"); switch (eVal) { case eGameHostOption_FriendsOfFriends: if (uiVal != 0) { @@ -6046,11 +6188,13 @@ void Game::SetGameHostOption(unsigned int& uiHostSettings, } unsigned int Game::GetGameHostOption(eGameHostOption eVal) { + ZoneScopedN("Game::GetGameHostOption"); return GetGameHostOption(m_uiGameHostSettings, eVal); } unsigned int Game::GetGameHostOption(unsigned int uiHostSettings, eGameHostOption eVal) { + ZoneScopedN("Game::GetGameHostOption"); // unsigned int uiVal=0; switch (eVal) { case eGameHostOption_FriendsOfFriends: @@ -6151,6 +6295,7 @@ unsigned int Game::GetGameHostOption(unsigned int uiHostSettings, } bool Game::CanRecordStatsAndAchievements() { + ZoneScopedN("Game::CanRecordStatsAndAchievements"); bool isTutorial = Minecraft::GetInstance() != nullptr && Minecraft::GetInstance()->isTutorial(); // 4J Stu - All of these options give the host player some advantage, so @@ -6168,23 +6313,28 @@ bool Game::CanRecordStatsAndAchievements() { } void Game::processSchematics(LevelChunk* levelChunk) { + ZoneScopedN("Game::processSchematics"); m_gameRules.processSchematics(levelChunk); } void Game::processSchematicsLighting(LevelChunk* levelChunk) { + ZoneScopedN("Game::processSchematicsLighting"); m_gameRules.processSchematicsLighting(levelChunk); } void Game::loadDefaultGameRules() { + ZoneScopedN("Game::loadDefaultGameRules"); m_gameRules.loadDefaultGameRules(); } void Game::setLevelGenerationOptions( LevelGenerationOptions* levelGen) { + ZoneScopedN("Game::setLevelGenerationOptions"); m_gameRules.setLevelGenerationOptions(levelGen); } const wchar_t* Game::GetGameRulesString(const std::wstring& key) { + ZoneScopedN("Game::GetGameRulesString"); return m_gameRules.GetGameRulesString(key); } @@ -6193,6 +6343,7 @@ unsigned char Game::m_szPNG[8] = {137, 80, 78, 71, 13, 10, 26, 10}; #define PNG_TAG_tEXt 0x74455874 unsigned int Game::FromBigEndian(unsigned int uiValue) { + ZoneScopedN("Game::FromBigEndian"); unsigned int uiReturn = ((uiValue >> 24) & 0x000000ff) | ((uiValue >> 8) & 0x0000ff00) | ((uiValue << 8) & 0x00ff0000) | ((uiValue << 24) & 0xff000000); @@ -6205,6 +6356,7 @@ void Game::GetImageTextData(std::uint8_t* imageData, unsigned int& uiHostOptions, bool& bHostOptionsRead, std::uint32_t& uiTexturePack) { + ZoneScopedN("Game::GetImageTextData"); auto readPngUInt32 = [](const std::uint8_t* data) -> unsigned int { unsigned int value = 0; std::memcpy(&value, data, sizeof(value)); @@ -6301,6 +6453,7 @@ unsigned int Game::CreateImageTextData(std::uint8_t* textMetadata, int64_t seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId) { + ZoneScopedN("Game::CreateImageTextData"); int iTextMetadataBytes = 0; if (hasSeed) { strcpy((char*)textMetadata, "4J_SEED"); @@ -6336,6 +6489,7 @@ unsigned int Game::CreateImageTextData(std::uint8_t* textMetadata, void Game::AddTerrainFeaturePosition(_eTerrainFeatureType eFeatureType, int x, int z) { + ZoneScopedN("Game::AddTerrainFeaturePosition"); // check we don't already have this in for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end(); ++it) { @@ -6355,6 +6509,7 @@ void Game::AddTerrainFeaturePosition(_eTerrainFeatureType eFeatureType, } _eTerrainFeatureType Game::IsTerrainFeature(int x, int z) { + ZoneScopedN("Game::IsTerrainFeature"); for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end(); ++it) { FEATURE_DATA* pFeatureData = *it; @@ -6368,6 +6523,7 @@ _eTerrainFeatureType Game::IsTerrainFeature(int x, int z) { bool Game::GetTerrainFeaturePosition(_eTerrainFeatureType eType, int* pX, int* pZ) { + ZoneScopedN("Game::GetTerrainFeaturePosition"); for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end(); ++it) { FEATURE_DATA* pFeatureData = *it; @@ -6383,6 +6539,7 @@ bool Game::GetTerrainFeaturePosition(_eTerrainFeatureType eType, } void Game::ClearTerrainFeaturePosition() { + ZoneScopedN("Game::ClearTerrainFeaturePosition"); FEATURE_DATA* pFeatureData; while (m_vTerrainFeatures.size() > 0) { pFeatureData = m_vTerrainFeatures.back(); @@ -6394,6 +6551,7 @@ void Game::ClearTerrainFeaturePosition() { void Game::UpdatePlayerInfo(std::uint8_t networkSmallId, int16_t playerColourIndex, unsigned int playerGamePrivileges) { + ZoneScopedN("Game::UpdatePlayerInfo"); for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { if (m_playerColours[i] == networkSmallId) { m_playerColours[i] = 0; @@ -6408,6 +6566,7 @@ void Game::UpdatePlayerInfo(std::uint8_t networkSmallId, } short Game::GetPlayerColour(std::uint8_t networkSmallId) { + ZoneScopedN("Game::GetPlayerColour"); short index = -1; for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { if (m_playerColours[i] == networkSmallId) { @@ -6419,6 +6578,7 @@ short Game::GetPlayerColour(std::uint8_t networkSmallId) { } unsigned int Game::GetPlayerPrivileges(std::uint8_t networkSmallId) { + ZoneScopedN("Game::GetPlayerPrivileges"); unsigned int privileges = 0; for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { if (m_playerColours[i] == networkSmallId) { @@ -6430,6 +6590,7 @@ unsigned int Game::GetPlayerPrivileges(std::uint8_t networkSmallId) { } std::wstring Game::getEntityName(eINSTANCEOF type) { + ZoneScopedN("Game::getEntityName"); switch (type) { case eTYPE_WOLF: return app.GetString(IDS_WOLF); @@ -6491,6 +6652,7 @@ std::uint32_t Game::m_dwContentTypeA[e_Marketplace_MAX] = { unsigned int Game::AddDLCRequest(eDLCMarketplaceType eType, bool bPromote) { + ZoneScopedN("Game::AddDLCRequest"); // lock access { std::lock_guard lock(csDLCDownloadQueue); @@ -6536,6 +6698,7 @@ unsigned int Game::AddDLCRequest(eDLCMarketplaceType eType, unsigned int Game::AddTMSPPFileTypeRequest(eDLCContentType eType, bool bPromote) { + ZoneScopedN("Game::AddTMSPPFileTypeRequest"); // lock access std::lock_guard lock(csTMSPPDownloadQueue); @@ -6721,6 +6884,7 @@ unsigned int Game::AddTMSPPFileTypeRequest(eDLCContentType eType, } bool Game::CheckTMSDLCCanStop() { + ZoneScopedN("Game::CheckTMSDLCCanStop"); std::lock_guard lock(csTMSPPDownloadQueue); for (auto it = m_TMSPPDownloadQueue.begin(); it != m_TMSPPDownloadQueue.end(); ++it) { @@ -6735,6 +6899,7 @@ bool Game::CheckTMSDLCCanStop() { } bool Game::RetrieveNextDLCContent() { + ZoneScopedN("Game::RetrieveNextDLCContent"); // If there's already a retrieve in progress, quit // we may have re-ordered the list, so need to check every item @@ -6792,6 +6957,7 @@ bool Game::RetrieveNextDLCContent() { int Game::TMSPPFileReturned(void* pParam, int iPad, int iUserData, C4JStorage::PTMSPP_FILEDATA pFileData, const char* szFilename) { + ZoneScopedN("Game::TMSPPFileReturned"); Game* pClass = (Game*)pParam; // find the right one in the vector @@ -6844,6 +7010,7 @@ int Game::TMSPPFileReturned(void* pParam, int iPad, int iUserData, bool Game::RetrieveNextTMSPPContent() { return false; } void Game::TickDLCOffersRetrieved() { + ZoneScopedN("Game::TickDLCOffersRetrieved"); if (!m_bAllDLCContentRetrieved) { if (!app.RetrieveNextDLCContent()) { app.DebugPrintf("[Consoles_App] All content retrieved.\n"); @@ -6852,6 +7019,7 @@ void Game::TickDLCOffersRetrieved() { } } void Game::ClearAndResetDLCDownloadQueue() { + ZoneScopedN("Game::ClearAndResetDLCDownloadQueue"); app.DebugPrintf("[Consoles_App] Clear and reset download queue.\n"); int iPosition = 0; @@ -6870,6 +7038,7 @@ void Game::ClearAndResetDLCDownloadQueue() { } void Game::TickTMSPPFilesRetrieved() { + ZoneScopedN("Game::TickTMSPPFilesRetrieved"); if (m_bTickTMSDLCFiles && !m_bAllTMSContentRetrieved) { if (app.RetrieveNextTMSPPContent() == false) { m_bAllTMSContentRetrieved = true; @@ -6877,6 +7046,7 @@ void Game::TickTMSPPFilesRetrieved() { } } void Game::ClearTMSPPFilesRetrieved() { + ZoneScopedN("Game::ClearTMSPPFilesRetrieved"); int iPosition = 0; { std::lock_guard lock(csTMSPPDownloadQueue); @@ -6894,6 +7064,7 @@ void Game::ClearTMSPPFilesRetrieved() { int Game::dlcOffersReturned(int iOfferC, std::uint32_t dwType, int iPad) { + ZoneScopedN("Game::dlcOffersReturned"); // find the right one in the vector { std::lock_guard lock(csTMSPPDownloadQueue); @@ -6918,6 +7089,7 @@ int Game::dlcOffersReturned(int iOfferC, std::uint32_t dwType, } eDLCContentType Game::Find_eDLCContentType(std::uint32_t dwType) { + ZoneScopedN("Game::Find_eDLCContentType"); for (int i = 0; i < e_DLC_MAX; i++) { if (m_dwContentTypeA[i] == dwType) { return (eDLCContentType)i; @@ -6926,6 +7098,7 @@ eDLCContentType Game::Find_eDLCContentType(std::uint32_t dwType) { return (eDLCContentType)0; } bool Game::DLCContentRetrieved(eDLCMarketplaceType eType) { + ZoneScopedN("Game::DLCContentRetrieved"); // If there's already a retrieve in progress, quit // we may have re-ordered the list, so need to check every item std::lock_guard lock(csDLCDownloadQueue); @@ -6944,6 +7117,7 @@ bool Game::DLCContentRetrieved(eDLCMarketplaceType eType) { void Game::SetAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* SkinBoxA, unsigned int dwSkinBoxC) { + ZoneScopedN("Game::SetAdditionalSkinBoxes"); EntityRenderer* renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); Model* pModel = renderer->getModel(); @@ -6981,6 +7155,7 @@ void Game::SetAdditionalSkinBoxes(std::uint32_t dwSkinID, std::vector* Game::SetAdditionalSkinBoxes( std::uint32_t dwSkinID, std::vector* pvSkinBoxA) { + ZoneScopedN("Game::SetAdditionalSkinBoxes"); EntityRenderer* renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); Model* pModel = renderer->getModel(); @@ -7016,6 +7191,7 @@ std::vector* Game::SetAdditionalSkinBoxes( std::vector* Game::GetAdditionalModelParts( std::uint32_t dwSkinID) { + ZoneScopedN("Game::GetAdditionalModelParts"); std::lock_guard lock(csAdditionalModelParts); std::vector* pvModelParts = nullptr; if (m_AdditionalModelParts.size() > 0) { @@ -7030,6 +7206,7 @@ std::vector* Game::GetAdditionalModelParts( std::vector* Game::GetAdditionalSkinBoxes( std::uint32_t dwSkinID) { + ZoneScopedN("Game::GetAdditionalSkinBoxes"); std::lock_guard lock(csAdditionalSkinBoxes); std::vector* pvSkinBoxes = nullptr; if (m_AdditionalSkinBoxes.size() > 0) { @@ -7043,6 +7220,7 @@ std::vector* Game::GetAdditionalSkinBoxes( } unsigned int Game::GetAnimOverrideBitmask(std::uint32_t dwSkinID) { + ZoneScopedN("Game::GetAnimOverrideBitmask"); std::lock_guard lock(csAnimOverrideBitmask); unsigned int uiAnimOverrideBitmask = 0L; @@ -7058,6 +7236,7 @@ unsigned int Game::GetAnimOverrideBitmask(std::uint32_t dwSkinID) { void Game::SetAnimOverrideBitmask(std::uint32_t dwSkinID, unsigned int uiAnimOverrideBitmask) { + ZoneScopedN("Game::SetAnimOverrideBitmask"); // Make thread safe std::lock_guard lock(csAnimOverrideBitmask); @@ -7072,6 +7251,7 @@ void Game::SetAnimOverrideBitmask(std::uint32_t dwSkinID, } std::uint32_t Game::getSkinIdFromPath(const std::wstring& skin) { + ZoneScopedN("Game::getSkinIdFromPath"); bool dlcSkin = false; unsigned int skinId = 0; @@ -7097,6 +7277,7 @@ std::uint32_t Game::getSkinIdFromPath(const std::wstring& skin) { } std::wstring Game::getSkinPathFromId(std::uint32_t skinId) { + ZoneScopedN("Game::getSkinPathFromId"); // 4J Stu - This function maps the encoded uint32_t we store in the player // profile to a filename that is stored as a memory texture and shared // between systems in game @@ -7122,10 +7303,12 @@ std::wstring Game::getSkinPathFromId(std::uint32_t skinId) { int Game::TexturePackDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { + ZoneScopedN("Game::TexturePackDialogReturned"); return 0; } int Game::getArchiveFileSize(const std::wstring& filename) { + ZoneScopedN("Game::getArchiveFileSize"); TexturePack* tPack = nullptr; Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft && pMinecraft->skins) @@ -7138,6 +7321,7 @@ int Game::getArchiveFileSize(const std::wstring& filename) { } bool Game::hasArchiveFile(const std::wstring& filename) { + ZoneScopedN("Game::hasArchiveFile"); TexturePack* tPack = nullptr; Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft && pMinecraft->skins) @@ -7151,6 +7335,7 @@ bool Game::hasArchiveFile(const std::wstring& filename) { std::vector Game::getArchiveFile( const std::wstring& filename) { + ZoneScopedN("Game::getArchiveFile"); TexturePack* tPack = nullptr; Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft && pMinecraft->skins) @@ -7165,19 +7350,23 @@ std::vector Game::getArchiveFile( // DLC int Game::GetDLCInfoTrialOffersCount() { + ZoneScopedN("Game::GetDLCInfoTrialOffersCount"); return (int)DLCInfo_Trial.size(); } int Game::GetDLCInfoFullOffersCount() { + ZoneScopedN("Game::GetDLCInfoFullOffersCount"); return (int)DLCInfo_Full.size(); } int Game::GetDLCInfoTexturesOffersCount() { + ZoneScopedN("Game::GetDLCInfoTexturesOffersCount"); return (int)DLCTextures_PackID.size(); } // AUTOSAVE void Game::SetAutosaveTimerTime(void) { + ZoneScopedN("Game::SetAutosaveTimerTime"); int settingValue = GetGameSettings(ProfileManager.GetPrimaryPad(), eGameSetting_Autosave); m_uiAutosaveTimer = time_util::clock::now() + @@ -7185,23 +7374,28 @@ void Game::SetAutosaveTimerTime(void) { } // value x 15 to get mins bool Game::AutosaveDue(void) { + ZoneScopedN("Game::AutosaveDue"); return (time_util::clock::now() > m_uiAutosaveTimer); } int64_t Game::SecondsToAutosave() { + ZoneScopedN("Game::SecondsToAutosave"); return std::chrono::duration_cast(m_uiAutosaveTimer - time_util::clock::now()).count(); } void Game::SetTrialTimerStart(void) { + ZoneScopedN("Game::SetTrialTimerStart"); m_fTrialTimerStart = m_Time.fAppTime; mfTrialPausedTime = 0.0f; } float Game::getTrialTimer(void) { + ZoneScopedN("Game::getTrialTimer"); return m_Time.fAppTime - m_fTrialTimerStart - mfTrialPausedTime; } bool Game::IsLocalMultiplayerAvailable() { + ZoneScopedN("Game::IsLocalMultiplayerAvailable"); unsigned int connectedControllers = 0; for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { if (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) @@ -7236,6 +7430,7 @@ bool Game::IsLocalMultiplayerAvailable() { // 4J-PB - language and locale function void Game::getLocale(std::vector& vecWstrLocales) { + ZoneScopedN("Game::getLocale"); std::vector locales; const unsigned int systemLanguage = XGetLanguage(); @@ -7394,14 +7589,17 @@ void Game::getLocale(std::vector& vecWstrLocales) { } int Game::get_eMCLang(wchar_t* pwchLocale) { + ZoneScopedN("Game::get_eMCLang"); return m_eMCLangA[pwchLocale]; } int Game::get_xcLang(wchar_t* pwchLocale) { + ZoneScopedN("Game::get_xcLang"); return m_xcLangA[pwchLocale]; } void Game::LocaleAndLanguageInit() { + ZoneScopedN("Game::LocaleAndLanguageInit"); m_localeA[eMCLang_zhCHT] = L"zh-CHT"; m_localeA[eMCLang_csCS] = L"cs-CS"; m_localeA[eMCLang_laLAS] = L"la-LAS"; @@ -7603,6 +7801,7 @@ void Game::LocaleAndLanguageInit() { } void Game::SetTickTMSDLCFiles(bool bVal) { + ZoneScopedN("Game::SetTickTMSDLCFiles"); // 4J-PB - we need to stop the retrieval of minecraft store images from TMS // when we aren't in the DLC, since going in to Play Game will change the // title id group @@ -7613,6 +7812,7 @@ std::wstring Game::getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder, std::wstring mountPoint) { + ZoneScopedN("Game::getFilePath"); std::wstring path = getRootPath(packId, true, bAddDataFolder, mountPoint) + filename; File f(path); @@ -7647,6 +7847,7 @@ std::wstring titleUpdateTexturePackRoot = L"CU\\DLC\\"; std::wstring Game::getRootPath(std::uint32_t packId, bool allowOverride, bool bAddDataFolder, std::wstring mountPoint) { + ZoneScopedN("Game::getRootPath"); std::wstring path = mountPoint; if (allowOverride) { switch (packId) { diff --git a/targets/app/linux/Iggy/gdraw/gdraw.c b/targets/app/linux/Iggy/gdraw/gdraw.c index 8b9f716ea..404a537e6 100644 --- a/targets/app/linux/Iggy/gdraw/gdraw.c +++ b/targets/app/linux/Iggy/gdraw/gdraw.c @@ -13,16 +13,36 @@ #include "app/linux/Iggy/include/iggy.h" #include "SDL_video.h" +#ifdef TRACY_ENABLE + #include +#else + #define TracyCAlloc(ptr, size) + #define TracyCFree(ptr) + #define TracyCZone(ctx, active) + #define TracyCZoneN(ctx, name, active) + #define TracyCZoneEnd(ctx) +#endif + #ifndef _ENABLEIGGY void* IggyGDrawMallocAnnotated(SINTa size, const char* file, int line) { + TracyCZoneN(iggy_malloc, "IggyGDrawMallocAnnotated", 1); (void)file; (void)line; - return malloc((size_t)size); + void* ptr = malloc((size_t)size); + if (ptr) TracyCAlloc(ptr, (size_t)size); + TracyCZoneEnd(iggy_malloc); + return ptr; } -void IggyGDrawFree(void* ptr) { free(ptr); } +void IggyGDrawFree(void* ptr) { + TracyCZoneN(iggy_free, "IggyGDrawFree", 1); + if (ptr) TracyCFree(ptr); + free(ptr); + TracyCZoneEnd(iggy_free); +} void IggyGDrawSendWarning(Iggy* f, char const* message, ...) { + TracyCZoneN(iggy_warn, "IggyGDrawSendWarning", 1); (void)f; va_list args; va_start(args, message); @@ -30,15 +50,19 @@ void IggyGDrawSendWarning(Iggy* f, char const* message, ...) { vfprintf(stderr, message, args); fprintf(stderr, "\n"); va_end(args); + TracyCZoneEnd(iggy_warn); } void IggyDiscardVertexBufferCallback(void* owner, void* buf) { + TracyCZoneN(iggy_discard_vb, "IggyDiscardVertexBufferCallback", 1); (void)owner; (void)buf; + TracyCZoneEnd(iggy_discard_vb); } #endif static void* get_gl_proc(const char* name) { + TracyCZoneN(gdraw_get_gl_proc, "get_gl_proc", 1); void* p = SDL_GL_GetProcAddress(name); if (!p) p = dlsym(RTLD_DEFAULT, name); if (!p) { @@ -53,6 +77,7 @@ static void* get_gl_proc(const char* name) { if (!p) p = dlsym(RTLD_DEFAULT, buf); } } + TracyCZoneEnd(gdraw_get_gl_proc); return p; } @@ -184,7 +209,8 @@ static gdraw_texsubimage2d_fn gdraw_real_texsubimage2d = NULL; } while (0) static void load_extensions(void) { -// gl_shared requires ts shit ugh + TracyCZoneN(gdraw_load_extensions, "load_extensions", 1); + // gl_shared requires ts shit ugh #define GLE(id, import, procname) \ gl##id = (PFNGL##procname##PROC)get_gl_proc("gl" import); GDRAW_GL_EXTENSION_LIST @@ -224,7 +250,6 @@ static void load_extensions(void) { "glEnableVertexAttribArray"); TRY(glDisableVertexAttribArray, "glDisableVertexAttribArrayARB", "glDisableVertexAttribArray"); - TRY(glGenRenderbuffers, "glGenRenderbuffersEXT", "glGenRenderbuffers"); TRY(glDeleteRenderbuffers, "glDeleteRenderbuffersEXT", "glDeleteRenderbuffers"); @@ -273,6 +298,7 @@ static void load_extensions(void) { gdraw_glGenVertexArrays(1, &gdraw_vao); gdraw_glBindVertexArray(gdraw_vao); } + TracyCZoneEnd(gdraw_load_extensions); } #undef TRY @@ -314,23 +340,31 @@ static struct { static int gdraw_shader_type_count = 0; static GLenum gdraw_get_shader_type(GLuint shader) { - for (int i = 0; i < gdraw_shader_type_count; i++) - if (gdraw_shader_types[i].handle == shader) + TracyCZoneN(gdraw_get_shader_type, "gdraw_get_shader_type", 1); + for (int i = 0; i < gdraw_shader_type_count; i++) { + if (gdraw_shader_types[i].handle == shader) { + TracyCZoneEnd(gdraw_get_shader_type); return gdraw_shader_types[i].type; + } + } + TracyCZoneEnd(gdraw_get_shader_type); return GL_FRAGMENT_SHADER; } static GLuint gdraw_CreateShaderTracked(GLenum type) { + TracyCZoneN(gdraw_create_shader_tracked, "gdraw_CreateShaderTracked", 1); GLuint h = gdraw_real_createshader(type); if (h && gdraw_shader_type_count < GDRAW_MAX_SHADERS) { gdraw_shader_types[gdraw_shader_type_count].handle = h; gdraw_shader_types[gdraw_shader_type_count].type = type; gdraw_shader_type_count++; } + TracyCZoneEnd(gdraw_create_shader_tracked); return h; } static void gdraw_CompileShaderAndLog(GLuint shader) { + TracyCZoneN(gdraw_compile_shader, "gdraw_CompileShaderAndLog", 1); GLint status = 0; gdraw_real_compileshader(shader); glGetShaderiv(shader, GL_COMPILE_STATUS, &status); @@ -342,9 +376,11 @@ static void gdraw_CompileShaderAndLog(GLuint shader) { fprintf(stderr, "[GDraw GLSL] compile FAILED shader=%u:\n%s\n", shader, log); } + TracyCZoneEnd(gdraw_compile_shader); } static void gdraw_LinkProgramAndLog(GLuint program) { + TracyCZoneN(gdraw_link_program, "gdraw_LinkProgramAndLog", 1); GLint status = 0; gdraw_real_linkprogram(program); glGetProgramiv(program, GL_LINK_STATUS, &status); @@ -356,6 +392,7 @@ static void gdraw_LinkProgramAndLog(GLuint program) { fprintf(stderr, "[GDraw GLSL] link FAILED program=%u:\n%s\n", program, log); } + TracyCZoneEnd(gdraw_link_program); } #undef glCreateShader @@ -363,6 +400,7 @@ static void gdraw_LinkProgramAndLog(GLuint program) { // This is the part that turns the old ugly shaders to 330 static char* gdraw_strreplace(char* src, const char* find, const char* rep) { + TracyCZoneN(gdraw_strreplace_zone, "gdraw_strreplace", 1); char* result; char* pos; char* base = src; @@ -375,7 +413,10 @@ static char* gdraw_strreplace(char* src, const char* find, const char* rep) { count++; tmp += find_len; } - if (!count) return src; + if (!count) { + TracyCZoneEnd(gdraw_strreplace_zone); + return src; + } size_t src_len = strlen(src); ptrdiff_t delta = (ptrdiff_t)rep_len - (ptrdiff_t)find_len; @@ -385,7 +426,10 @@ static char* gdraw_strreplace(char* src, const char* find, const char* rep) { else new_len -= (size_t)(-delta) * count; result = (char*)malloc(new_len); - if (!result) return src; + if (!result) { + TracyCZoneEnd(gdraw_strreplace_zone); + return src; + } tmp = result; while ((pos = strstr(src, find))) { @@ -398,12 +442,14 @@ static char* gdraw_strreplace(char* src, const char* find, const char* rep) { } memcpy(tmp, src, strlen(src) + 1); free(base); + TracyCZoneEnd(gdraw_strreplace_zone); return result; } static void gdraw_ShaderSourceUpgraded(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths) { + TracyCZoneN(gdraw_shader_source_upgrade, "gdraw_ShaderSourceUpgraded", 1); size_t total = 0; for (int i = 0; i < count; i++) total += lengths ? (lengths[i] >= 0 ? (size_t)lengths[i] @@ -413,6 +459,7 @@ static void gdraw_ShaderSourceUpgraded(GLuint shader, GLsizei count, char* src = (char*)malloc(total + 1); if (!src) { gdraw_real_shadersource(shader, count, strings, lengths); + TracyCZoneEnd(gdraw_shader_source_upgrade); return; } @@ -469,6 +516,7 @@ static void gdraw_ShaderSourceUpgraded(GLuint shader, GLsizei count, if (!patched) { free(src); gdraw_real_shadersource(shader, count, strings, lengths); + TracyCZoneEnd(gdraw_shader_source_upgrade); return; } strcpy(patched, header); @@ -478,6 +526,7 @@ static void gdraw_ShaderSourceUpgraded(GLuint shader, GLsizei count, const GLchar* patched_ptr = (const GLchar*)patched; gdraw_real_shadersource(shader, 1, &patched_ptr, NULL); free(patched); + TracyCZoneEnd(gdraw_shader_source_upgrade); } #undef glShaderSource @@ -486,6 +535,7 @@ static void gdraw_ShaderSourceUpgraded(GLuint shader, GLsizei count, // Remap all the deprecated internal formats to their modern equivalents // (idk why but just the word "swizzle" is cracking me up) static void gdraw_apply_swizzle(GLenum internal_fmt) { + TracyCZoneN(gdraw_apply_swizzle, "gdraw_apply_swizzle", 1); if (internal_fmt == 0x1906 /* GL_ALPHA */ || internal_fmt == GL_RED) { GLint sw[4] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, sw); @@ -496,34 +546,49 @@ static void gdraw_apply_swizzle(GLenum internal_fmt) { GLint sw[4] = {GL_RED, GL_RED, GL_RED, GL_GREEN}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, sw); } + TracyCZoneEnd(gdraw_apply_swizzle); } static GLenum gdraw_remap_fmt(GLenum fmt) { + TracyCZoneN(gdraw_remap_fmt, "gdraw_remap_fmt", 1); + GLenum result = fmt; switch (fmt) { case 0x1906: - return GL_RED; // GL_ALPHA + result = GL_RED; // GL_ALPHA + break; case 0x1909: - return GL_RED; // GL_LUMINANCE + result = GL_RED; // GL_LUMINANCE + break; case 0x190A: - return GL_RG; // GL_LUMINANCE_ALPHA + result = GL_RG; // GL_LUMINANCE_ALPHA + break; case 0x8033: - return GL_RG; // GL_LUMINANCE4_ALPHA4 + result = GL_RG; // GL_LUMINANCE4_ALPHA4 + break; case 0x8045: - return GL_R8; // GL_LUMINANCE8 + result = GL_R8; // GL_LUMINANCE8 + break; case 0x8048: - return GL_RG8; // GL_LUMINANCE8_ALPHA8 + result = GL_RG8; // GL_LUMINANCE8_ALPHA8 + break; case 0x804F: - return GL_R8; // GL_INTENSITY4 + result = GL_R8; // GL_INTENSITY4 + break; case 0x8050: - return GL_R8; // GL_INTENSITY8 + result = GL_R8; // GL_INTENSITY8 + break; default: - return fmt; + result = fmt; + break; } + TracyCZoneEnd(gdraw_remap_fmt); + return result; } static void gdraw_TexImage2D(GLenum target, GLint level, GLint ifmt, GLsizei w, GLsizei h, GLint border, GLenum fmt, GLenum type, const void* data) { + TracyCZoneN(gdraw_teximage2d, "gdraw_TexImage2D", 1); // ES strictly requires explicitly sized formats & stuff if (ifmt == GL_RGBA && data == NULL) ifmt = GL_RGBA8; @@ -532,14 +597,17 @@ static void gdraw_TexImage2D(GLenum target, GLint level, GLint ifmt, GLsizei w, gdraw_real_teximage2d(target, level, (GLint)new_ifmt, w, h, border, new_fmt, type, data); if (new_ifmt != (GLenum)ifmt) gdraw_apply_swizzle((GLenum)ifmt); + TracyCZoneEnd(gdraw_teximage2d); } static void gdraw_TexSubImage2D(GLenum target, GLint level, GLint xoff, GLint yoff, GLsizei w, GLsizei h, GLenum fmt, GLenum type, const void* data) { + TracyCZoneN(gdraw_texsubimage2d, "gdraw_TexSubImage2D", 1); GLenum new_fmt = gdraw_remap_fmt(fmt); gdraw_real_texsubimage2d(target, level, xoff, yoff, w, h, new_fmt, type, data); + TracyCZoneEnd(gdraw_texsubimage2d); } #undef glTexImage2D @@ -552,6 +620,7 @@ static void gdraw_ClientVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) { + TracyCZoneN(gdraw_vertex_attrib_pointer, "gdraw_ClientVertexAttribPointer", 1); if (gdraw_glBindVertexArray && gdraw_vao) { GLint current_vao = 0; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, ¤t_vao); @@ -565,11 +634,13 @@ static void gdraw_ClientVertexAttribPointer(GLuint index, GLint size, if (current_vbo != 0 && current_vbo != (GLint)gdraw_screenvbo) { // no touchies gdraw_real_vtxattrib(index, size, type, normalized, stride, pointer); + TracyCZoneEnd(gdraw_vertex_attrib_pointer); return; } if (pointer == NULL) { gdraw_real_vtxattrib(index, size, type, normalized, stride, pointer); + TracyCZoneEnd(gdraw_vertex_attrib_pointer); return; } @@ -597,6 +668,7 @@ static void gdraw_ClientVertexAttribPointer(GLuint index, GLint size, gdraw_real_vtxattrib(index, size, type, normalized, stride, (const void*)offset); } + TracyCZoneEnd(gdraw_vertex_attrib_pointer); } #undef glVertexAttribPointer @@ -605,6 +677,7 @@ static void gdraw_ClientVertexAttribPointer(GLuint index, GLint size, // fake ibo static void hooked_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) { + TracyCZoneN(gdraw_draw_elements, "hooked_glDrawElements", 1); GLint current_ibo = 0; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, ¤t_ibo); @@ -622,12 +695,14 @@ static void hooked_glDrawElements(GLenum mode, GLsizei count, GLenum type, } else { gdraw_real_drawelements(mode, count, type, indices); } + TracyCZoneEnd(gdraw_draw_elements); } #define glDrawElements hooked_glDrawElements // dummy shader for glUseProgram(0) safety static void gdraw_UseProgramSafe(GLuint program) { + TracyCZoneN(gdraw_use_program_safe, "gdraw_UseProgramSafe", 1); if (!program) { if (!gdraw_null_program && gdraw_real_useprogram) { const char* vs = @@ -648,9 +723,11 @@ static void gdraw_UseProgramSafe(GLuint program) { glDeleteShader(f); } gdraw_real_useprogram(gdraw_null_program); + TracyCZoneEnd(gdraw_use_program_safe); return; } gdraw_real_useprogram(program); + TracyCZoneEnd(gdraw_use_program_safe); } #undef glUseProgram @@ -663,6 +740,8 @@ static void gdraw_UseProgramSafe(GLuint program) { static void gdraw_FramebufferRenderbufferSafe(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { + TracyCZoneN(gdraw_framebuffer_renderbuffer_safe, + "gdraw_FramebufferRenderbufferSafe", 1); static GLuint last_depth_rb = 0; if (attachment == GL_DEPTH_ATTACHMENT) { @@ -684,6 +763,7 @@ static void gdraw_FramebufferRenderbufferSafe(GLenum target, GLenum attachment, (glFramebufferRenderbuffer)(target, attachment, renderbuffertarget, renderbuffer); } + TracyCZoneEnd(gdraw_framebuffer_renderbuffer_safe); } #define glFramebufferRenderbuffer_SAFE gdraw_FramebufferRenderbufferSafe #define glFramebufferRenderbuffer glFramebufferRenderbuffer_SAFE @@ -694,14 +774,22 @@ static void gdraw_FramebufferRenderbufferSafe(GLenum target, GLenum attachment, #define glVertexAttribPointer gdraw_real_vtxattrib static int hasext_core(const char* name) { + TracyCZoneN(gdraw_hasext_core, "hasext_core", 1); GLint n = 0; - if (!gdraw_glGetStringi) return 0; + if (!gdraw_glGetStringi) { + TracyCZoneEnd(gdraw_hasext_core); + return 0; + } glGetIntegerv(GL_NUM_EXTENSIONS, &n); for (GLint i = 0; i < n; i++) { const char* e = (const char*)gdraw_glGetStringi(GL_EXTENSIONS, (GLuint)i); - if (e && strcmp(e, name) == 0) return 1; + if (e && strcmp(e, name) == 0) { + TracyCZoneEnd(gdraw_hasext_core); + return 1; + } } + TracyCZoneEnd(gdraw_hasext_core); return 0; } @@ -711,6 +799,7 @@ static void RADLINK hooked_DrawIndexedTriangles(GDrawRenderState* r, GDrawPrimitive* prim, GDrawVertexBuffer* buf, GDrawStats* stats) { + TracyCZoneN(gdraw_draw_indexed_triangles, "hooked_DrawIndexedTriangles", 1); if (buf == NULL && prim != NULL && prim->vertices != NULL) { size_t stride = 8; if (prim->vertex_format == GDRAW_vformat_v2aa) @@ -725,29 +814,35 @@ static void RADLINK hooked_DrawIndexedTriangles(GDrawRenderState* r, } gdraw_screenvbo_base = NULL; // Force VBO re-upload for each primitive real_DrawIndexedTriangles(r, prim, buf, stats); + TracyCZoneEnd(gdraw_draw_indexed_triangles); } static gdraw_filter_quad* real_FilterQuad = NULL; static void RADLINK hooked_FilterQuad(GDrawRenderState* r, S32 x0, S32 y0, S32 x1, S32 y1, GDrawStats* stats) { + TracyCZoneN(gdraw_filter_quad, "hooked_FilterQuad", 1); gdraw_expected_vbo_size = 4 * 20; // 4 vertices, max stride gdraw_screenvbo_base = NULL; real_FilterQuad(r, x0, y0, x1, y1, stats); + TracyCZoneEnd(gdraw_filter_quad); } static gdraw_rendering_begin* real_RenderingBegin = NULL; // stupid hack static void RADLINK hooked_RenderingBegin(void) { + TracyCZoneN(gdraw_rendering_begin, "hooked_RenderingBegin", 1); if (real_RenderingBegin) real_RenderingBegin(); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); OPENGL_CHECK_SITE("hooked_RenderingBegin:post_state"); + TracyCZoneEnd(gdraw_rendering_begin); } // Creating the context GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) { + TracyCZoneN(gdraw_create_context, "gdraw_GL_CreateContext", 1); static const TextureFormatDesc tex_formats[] = { {IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE}, {IFT_FORMAT_rgba_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA, @@ -779,6 +874,7 @@ GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) { if (major < 3) { fprintf(stderr, "[GDraw] GL 3.0 or higher required (got %d.%d)\n", major, minor); + TracyCZoneEnd(gdraw_create_context); return NULL; } @@ -788,7 +884,10 @@ GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) { gdraw_glBindVertexArray(gdraw_vao); GDrawFunctions* funcs = create_context(w, h); - if (!funcs) return NULL; + if (!funcs) { + TracyCZoneEnd(gdraw_create_context); + return NULL; + } // hook the vtable entries for VBO reset and render state real_DrawIndexedTriangles = funcs->DrawIndexedTriangles; @@ -820,21 +919,26 @@ GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) { opengl_check(); fprintf(stderr, "[GDraw] Context created successfully (%dx%d, msaa=%d)\n", w, h, msaa_samples); + TracyCZoneEnd(gdraw_create_context); return funcs; } // Custom draw callbacks void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion* region, F32* matrix) { + TracyCZoneN(gdraw_begin_custom_draw, "gdraw_GL_BeginCustomDraw_4J", 1); // rebind vbo if (gdraw_glBindVertexArray && gdraw_vao) gdraw_glBindVertexArray(gdraw_vao); clear_renderstate(); gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, depth_from_id(0), 0); + TracyCZoneEnd(gdraw_begin_custom_draw); } void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion* region, F32* matrix) { + TracyCZoneN(gdraw_calc_custom_draw, "gdraw_GL_CalculateCustomDraw_4J", 1); gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0); + TracyCZoneEnd(gdraw_calc_custom_draw); } diff --git a/targets/app/linux/LinuxGame.cpp b/targets/app/linux/LinuxGame.cpp index 844f43c09..919c79d12 100644 --- a/targets/app/linux/LinuxGame.cpp +++ b/targets/app/linux/LinuxGame.cpp @@ -17,35 +17,51 @@ #include "minecraft/server/MinecraftServer.h" #include "minecraft/world/level/LevelSettings.h" +#ifdef TRACY_ENABLE + #include +#else + #define ZoneScoped + #define ZoneScopedN(name) +#endif + LinuxGame app; #define CONTEXT_GAME_STATE 0 LinuxGame::LinuxGame() : Game() {} -void LinuxGame::SetRichPresenceContext(int iPad, int contextId) {} +void LinuxGame::SetRichPresenceContext(int iPad, int contextId) { + ZoneScoped; +} -void LinuxGame::StoreLaunchData() {} +void LinuxGame::StoreLaunchData() { ZoneScoped; } void LinuxGame::ExitGame() { + ZoneScoped; app.DebugPrintf("Linux_App LinuxGame::ExitGame AFTER START\n"); RenderManager.Close(); } void LinuxGame::FatalLoadError() { + ZoneScoped; app.DebugPrintf( "LinuxGame::FatalLoadError - asserting 0 and dying...\n"); assert(0); } -void LinuxGame::CaptureSaveThumbnail() {} +void LinuxGame::CaptureSaveThumbnail() { ZoneScoped; } void LinuxGame::GetSaveThumbnail(std::uint8_t** thumbnailData, - unsigned int* thumbnailSize) {} -void LinuxGame::ReleaseSaveThumbnail() {} + unsigned int* thumbnailSize) { + ZoneScoped; +} +void LinuxGame::ReleaseSaveThumbnail() { ZoneScoped; } void LinuxGame::GetScreenshot(int iPad, std::uint8_t** screenshotData, - unsigned int* screenshotSize) {} + unsigned int* screenshotSize) { + ZoneScoped; +} void LinuxGame::TemporaryCreateGameStart() { + ZoneScoped; ////////////////////////////////////////////////////////////////////////////////////////////// /// From CScene_Main::OnInit @@ -124,14 +140,22 @@ void LinuxGame::TemporaryCreateGameStart() { int LinuxGame::GetLocalTMSFileIndex(wchar_t* wchTMSFile, bool bFilenameIncludesExtension, eFileExtensionType eEXT) { + ZoneScoped; return -1; } -int LinuxGame::LoadLocalTMSFile(wchar_t* wchTMSFile) { return -1; } +int LinuxGame::LoadLocalTMSFile(wchar_t* wchTMSFile) { + ZoneScoped; + return -1; +} int LinuxGame::LoadLocalTMSFile(wchar_t* wchTMSFile, eFileExtensionType eExt) { + ZoneScoped; return -1; } -void LinuxGame::FreeLocalTMSFiles(eTMSFileType eType) {} +void LinuxGame::FreeLocalTMSFiles(eTMSFileType eType) { + ZoneScoped; +} + diff --git a/targets/app/linux/Linux_Minecraft.cpp b/targets/app/linux/Linux_Minecraft.cpp index 4c7ac5631..81cb0d3d7 100644 --- a/targets/app/linux/Linux_Minecraft.cpp +++ b/targets/app/linux/Linux_Minecraft.cpp @@ -70,6 +70,14 @@ static void sigsegv_handler(int sig) { #include "minecraft/world/level/tile/Tile.h" #include "strings.h" +#ifdef TRACY_ENABLE + #include +#else + #define ZoneScoped + #define ZoneScopedN(name) +#endif + + // #include "../Orbis/Leaderboards/OrbisLeaderboardManager.h" // #include "../Orbis/Network/Orbis_NPToolkit.h" @@ -105,6 +113,7 @@ void FreeRichPresenceStrings(); bool g_bWidescreen = true; void DefineActions(void) { + ZoneScoped; // The app needs to define the actions required, and the possible mappings // for these @@ -410,6 +419,7 @@ void DefineActions(void) { } int main(int argc, const char* argv[]) { + ZoneScoped; #if defined(__linux__) && defined(__GLIBC__) struct sigaction sa; sa.sa_handler = sigsegv_handler; @@ -646,6 +656,7 @@ int main(int argc, const char* argv[]) { std::vector vRichPresenceStrings; uint8_t* mallocAndCreateUTF8ArrayFromString(int iID) { + ZoneScoped; const wchar_t* wchString = app.GetString(iID); std::wstring srcString = wchString; @@ -659,6 +670,7 @@ uint8_t* mallocAndCreateUTF8ArrayFromString(int iID) { } uint8_t* AddRichPresenceString(int iID) { + ZoneScoped; uint8_t* strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); if (strUtf8 != nullptr) { vRichPresenceStrings.push_back(strUtf8); @@ -667,6 +679,7 @@ uint8_t* AddRichPresenceString(int iID) { } void FreeRichPresenceStrings() { + ZoneScoped; uint8_t* strUtf8; for (int i = 0; i < vRichPresenceStrings.size(); i++) { strUtf8 = vRichPresenceStrings.at(i); diff --git a/targets/minecraft/client/Minecraft.cpp b/targets/minecraft/client/Minecraft.cpp index c136761d6..80dd5614d 100644 --- a/targets/minecraft/client/Minecraft.cpp +++ b/targets/minecraft/client/Minecraft.cpp @@ -165,6 +165,7 @@ ResourceLocation Minecraft::ALT_FONT_LOCATION = ResourceLocation(TN_ALT_FONT); Minecraft::Minecraft(Component* mouseComponent, Canvas* parent, MinecraftApplet* minecraftApplet, int width, int height, bool fullscreen) { + ZoneScopedN("Minecraft::Minecraft"); // 4J - added this block of initialisers gameMode = nullptr; hasCrashed = false; @@ -283,6 +284,7 @@ Minecraft::Minecraft(Component* mouseComponent, Canvas* parent, } void Minecraft::clearConnectionFailed() { + ZoneScopedN("Minecraft::clearConnectionFailed"); for (int i = 0; i < XUSER_MAX_COUNT; i++) { m_connectionFailed[i] = false; m_connectionFailedReason[i] = DisconnectPacket::eDisconnect_None; @@ -291,11 +293,13 @@ void Minecraft::clearConnectionFailed() { } void Minecraft::connectTo(const std::wstring& server, int port) { + ZoneScopedN("Minecraft::connectTo"); connectToIp = server; connectToPort = port; } void Minecraft::init() { + ZoneScopedN("Minecraft::init"); // glClearColor(0.2f, 0.2f, 0.2f, 1); workingDirectory = getWorkingDirectory(); @@ -401,6 +405,7 @@ void Minecraft::init() { } void Minecraft::renderLoadingScreen() { + ZoneScopedN("Minecraft::renderLoadingScreen"); // 4J Unused // testing stuff on vita just now #if defined(ENABLE_JAVA_GUIS) @@ -453,6 +458,7 @@ void Minecraft::renderLoadingScreen() { } void Minecraft::blit(int x, int y, int sx, int sy, int w, int h) { + ZoneScopedN("Minecraft::blit"); float us = 1 / 256.0f; float vs = 1 / 256.0f; Tesselator* t = Tesselator::getInstance(); @@ -469,11 +475,13 @@ void Minecraft::blit(int x, int y, int sx, int sy, int w, int h) { } File Minecraft::getWorkingDirectory() { + ZoneScopedN("Minecraft::getWorkingDirectory"); if (workDir.getPath().empty()) workDir = getWorkingDirectory(L"4jcraft"); return workDir; } File Minecraft::getWorkingDirectory(const std::wstring& applicationName) { + ZoneScopedN("Minecraft::getWorkingDirectory"); // 4J - original version // 4jcraft: ported to C++ std::wstring userHome = convStringToWstring(getenv("HOME")); @@ -508,6 +516,7 @@ File Minecraft::getWorkingDirectory(const std::wstring& applicationName) { LevelStorageSource* Minecraft::getLevelSource() { return levelSource; } void Minecraft::setScreen(Screen* screen) { + ZoneScopedN("Minecraft::setScreen"); if (dynamic_cast(this->screen) != nullptr) return; if (this->screen != nullptr) { @@ -576,10 +585,12 @@ void Minecraft::setScreen(Screen* screen) { } void Minecraft::checkGlError(const std::wstring& string) { + ZoneScopedN("Minecraft::checkGlError"); // 4J - TODO } void Minecraft::destroy() { + ZoneScopedN("Minecraft::destroy"); // 4J Gordon: Do not force a stats save here /*stats->forceSend(); stats->forceSave();*/ @@ -666,6 +677,7 @@ void Minecraft::destroy() { // from our xbox game loop void Minecraft::run() { + ZoneScopedN("Minecraft::run"); running = true; // try { // 4J - removed try/catch init(); @@ -1026,7 +1038,6 @@ void Minecraft::createPrimaryLocalPlayer(int iPad) { } void Minecraft::run_middle() { - ZoneScoped; static int64_t lastTime = 0; static bool bFirstTimeIntoGame = true; static bool bAutosaveTimerSet = false; @@ -1174,7 +1185,6 @@ void Minecraft::run_middle() { // 4J-PB - Once we're in the level, check if the players have // the level in their banned list and ask if they want to play // it - ZoneScopedN("Render Viewports"); for (int i = 0; i < XUSER_MAX_COUNT; i++) { if (localplayers[i] && (app.GetBanListCheck(i) == false) && !Minecraft::GetInstance()->isTutorial() && @@ -1828,12 +1838,14 @@ void Minecraft::run_middle() { void Minecraft::run_end() { destroy(); } void Minecraft::emergencySave() { + ZoneScopedN("Minecraft::emergencySave"); // 4J - lots of try/catches removed here, and garbage collector things levelRenderer->clear(); setLevel(nullptr); } void Minecraft::renderFpsMeter(int64_t tickTime) { + ZoneScopedN("Minecraft::renderFpsMeter"); int nsPer60Fps = 1000000000l / 60; if (lastTimer == -1) { lastTimer = System::nanoTime(); @@ -1926,11 +1938,13 @@ void Minecraft::renderFpsMeter(int64_t tickTime) { } void Minecraft::stop() { + ZoneScopedN("Minecraft::stop"); running = false; // keepPolling = false; } void Minecraft::pauseGame() { + ZoneScopedN("Minecraft::pauseGame"); if (screen != nullptr) { // 4jcraft: Pass the keypress to the screen // normally this would've been done in updateEvents(), but it works @@ -1944,6 +1958,7 @@ void Minecraft::pauseGame() { } bool Minecraft::pollResize() { + ZoneScopedN("Minecraft::pollResize"); int fbw, fbh; RenderManager.GetFramebufferSize(fbw, fbh); if (fbw != width_phys || fbh != height_phys) { @@ -1954,6 +1969,7 @@ bool Minecraft::pollResize() { } void Minecraft::resize(int width, int height) { + ZoneScopedN("Minecraft::resize"); if (width <= 0) width = 1; if (height <= 0) height = 1; // 4jcraft: store physical framebuffer size and adjust logical width @@ -1981,6 +1997,7 @@ void Minecraft::resize(int width, int height) { } void Minecraft::verify() { + ZoneScopedN("Minecraft::verify"); /* 4J - TODO new Thread() { public void run() { @@ -2000,12 +2017,13 @@ void Minecraft::verify() { } void Minecraft::levelTickUpdateFunc(void* pParam) { - ZoneScoped; + ZoneScopedN("Minecraft::levelTickUpdateFunc"); Level* pLevel = (Level*)pParam; pLevel->tick(); } void Minecraft::levelTickThreadInitFunc() { + ZoneScopedN("Minecraft::levelTickThreadInitFunc"); Compression::UseDefaultThreadStorage(); } @@ -2014,7 +2032,7 @@ void Minecraft::levelTickThreadInitFunc() { // textures are to be updated - this will be true for the last time this tick // runs with bFirst true void Minecraft::tick(bool bFirst, bool bUpdateTextures) { - ZoneScoped; + ZoneScopedN("Minecraft::tick"); int iPad = player->GetXboxPad(); // OutputDebugString("Minecraft::tick\n"); @@ -3667,6 +3685,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { } void Minecraft::reloadSound() { + ZoneScopedN("Minecraft::reloadSound"); // System.out.println("FORCING RELOAD!"); // 4J - removed soundEngine = new SoundEngine(); soundEngine->init(options); @@ -3674,6 +3693,7 @@ void Minecraft::reloadSound() { } bool Minecraft::isClientSide() { + ZoneScopedN("Minecraft::isClientSide"); return level != nullptr && level->isClientSide; } @@ -3685,10 +3705,12 @@ void Minecraft::selectLevel(ConsoleSaveFile* saveFile, bool Minecraft::saveSlot(int slot, const std::wstring& name) { return false; } bool Minecraft::loadSlot(const std::wstring& userName, int slot) { + ZoneScopedN("Minecraft::loadSlot"); return false; } void Minecraft::releaseLevel(int message) { + ZoneScopedN("Minecraft::releaseLevel"); // this->level = nullptr; setLevel(nullptr, message); } @@ -3696,6 +3718,7 @@ void Minecraft::releaseLevel(int message) { // 4J Stu - This code was within setLevel, but I moved it out so that I can call // it at a better time when exiting from an online game void Minecraft::forceStatsSave(int idx) { + ZoneScopedN("Minecraft::forceStatsSave"); // 4J Gordon: Force a stats save stats[idx]->save(idx, true); @@ -3710,6 +3733,7 @@ void Minecraft::forceStatsSave(int idx) { // 4J Added MultiPlayerLevel* Minecraft::getLevel(int dimension) { + ZoneScopedN("Minecraft::getLevel"); if (dimension == -1) return levels[1]; else if (dimension == 1) @@ -3734,6 +3758,7 @@ MultiPlayerLevel* Minecraft::getLevel(int dimension) { //} void Minecraft::forceaddLevel(MultiPlayerLevel* level) { + ZoneScopedN("Minecraft::forceaddLevel"); int dimId = level->dimension->id; if (dimId == -1) levels[1] = level; @@ -3922,6 +3947,7 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, } void Minecraft::prepareLevel(int title) { + ZoneScopedN("Minecraft::prepareLevel"); if (progressRenderer != nullptr) { this->progressRenderer->progressStart(title); this->progressRenderer->progressStage(IDS_PROGRESS_BUILDING_TERRAIN); @@ -3960,6 +3986,7 @@ void Minecraft::prepareLevel(int title) { } void Minecraft::fileDownloaded(const std::wstring& name, File* file) { + ZoneScopedN("Minecraft::fileDownloaded"); int p = (int)name.find(L"/"); std::wstring category = name.substr(0, p); std::wstring name2 = name.substr(p + 1); @@ -3978,27 +4005,32 @@ void Minecraft::fileDownloaded(const std::wstring& name, File* file) { } std::wstring Minecraft::gatherStats1() { + ZoneScopedN("Minecraft::gatherStats1"); // return levelRenderer->gatherStats1(); return L"Time to autosave: " + toWString(app.SecondsToAutosave()) + L"s"; } std::wstring Minecraft::gatherStats2() { + ZoneScopedN("Minecraft::gatherStats2"); return g_NetworkManager.GatherStats(); // return levelRenderer->gatherStats2(); } std::wstring Minecraft::gatherStats3() { + ZoneScopedN("Minecraft::gatherStats3"); return g_NetworkManager.GatherRTTStats(); // return L"P: " + particleEngine->countParticles() + L". T: " + // level->gatherStats(); } std::wstring Minecraft::gatherStats4() { + ZoneScopedN("Minecraft::gatherStats4"); return level->gatherChunkSourceStats(); } void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) { + ZoneScopedN("Minecraft::respawnPlayer"); gameRenderer ->DisableUpdateThread(); // 4J - don't do updating whilst we are // adjusting the player & localplayer array @@ -4102,12 +4134,14 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) { } void Minecraft::start(const std::wstring& name, const std::wstring& sid) { + ZoneScopedN("Minecraft::start"); startAndConnectTo(name, sid, L""); } void Minecraft::startAndConnectTo(const std::wstring& name, const std::wstring& sid, const std::wstring& url) { + ZoneScopedN("Minecraft::startAndConnectTo"); bool fullScreen = false; std::wstring userName = name; @@ -4192,6 +4226,7 @@ void Minecraft::startAndConnectTo(const std::wstring& name, } ClientConnection* Minecraft::getConnection(int iPad) { + ZoneScopedN("Minecraft::getConnection"); return localplayers[iPad]->connection; } @@ -4203,6 +4238,7 @@ bool useLomp = false; int g_iMainThreadId; void Minecraft::main() { + ZoneScopedN("Minecraft::main"); std::wstring name; std::wstring sessionId; @@ -4246,6 +4282,7 @@ void Minecraft::main() { } bool Minecraft::renderNames() { + ZoneScopedN("Minecraft::renderNames"); if (m_instance == nullptr || !m_instance->options->hideGui) { return true; } @@ -4253,23 +4290,28 @@ bool Minecraft::renderNames() { } bool Minecraft::useFancyGraphics() { + ZoneScopedN("Minecraft::useFancyGraphics"); return (m_instance != nullptr && m_instance->options->fancyGraphics); } bool Minecraft::useAmbientOcclusion() { + ZoneScopedN("Minecraft::useAmbientOcclusion"); return (m_instance != nullptr && m_instance->options->ambientOcclusion != Options::AO_OFF); } bool Minecraft::renderDebug() { + ZoneScopedN("Minecraft::renderDebug"); return (m_instance != nullptr && m_instance->options->renderDebug); } bool Minecraft::handleClientSideCommand(const std::wstring& chatMessage) { + ZoneScopedN("Minecraft::handleClientSideCommand"); return false; } int Minecraft::maxSupportedTextureSize() { + ZoneScopedN("Minecraft::maxSupportedTextureSize"); // 4J Force value return 1024; @@ -4287,6 +4329,7 @@ int Minecraft::maxSupportedTextureSize() { void Minecraft::delayTextureReload() { reloadTextures = true; } int64_t Minecraft::currentTimeMillis() { + ZoneScopedN("Minecraft::currentTimeMillis"); return System::currentTimeMillis(); //(Sys.getTime() * 1000) / // Sys.getTimerResolution(); } @@ -4314,6 +4357,7 @@ gameMode->stopDestroyBlock(); void Minecraft::handleMouseClick(int button) { + ZoneScopedN("Minecraft::handleMouseClick"); if (button == 0 && missTime > 0) return; if (button == 0) { @@ -4429,6 +4473,7 @@ gameRenderer->itemInHandRenderer->itemUsed(); Screen* Minecraft::getScreen() { return screen; } bool Minecraft::isTutorial() { + ZoneScopedN("Minecraft::isTutorial"); return m_inFullTutorialBits > 0; /*if( gameMode != nullptr && gameMode->isTutorial() ) @@ -4442,6 +4487,7 @@ bool Minecraft::isTutorial() { } void Minecraft::playerStartedTutorial(int iPad) { + ZoneScopedN("Minecraft::playerStartedTutorial"); // If the app doesn't think we are in a tutorial mode then just ignore this // add if (app.GetTutorialMode()) @@ -4449,6 +4495,7 @@ void Minecraft::playerStartedTutorial(int iPad) { } void Minecraft::playerLeftTutorial(int iPad) { + ZoneScopedN("Minecraft::playerLeftTutorial"); // 4J Stu - Fix for bug that was flooding Sentient with LevelStart events // If the tutorial bits are already 0 then don't need to update anything if (m_inFullTutorialBits == 0) { @@ -4463,6 +4510,7 @@ void Minecraft::playerLeftTutorial(int iPad) { } int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) { + ZoneScopedN("Minecraft::InGame_SignInReturned"); Minecraft* pMinecraftClass = (Minecraft*)pParam; if (g_NetworkManager.IsInSession()) { @@ -4529,7 +4577,7 @@ int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) { } void Minecraft::tickAllConnections() { - ZoneScoped; + ZoneScopedN("Minecraft::tickAllConnections"); int oldIdx = getLocalPlayerIdx(); for (unsigned int i = 0; i < XUSER_MAX_COUNT; i++) { std::shared_ptr mplp = localplayers[i]; @@ -4543,6 +4591,7 @@ void Minecraft::tickAllConnections() { bool Minecraft::addPendingClientTextureRequest( const std::wstring& textureName) { + ZoneScopedN("Minecraft::addPendingClientTextureRequest"); auto it = find(m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName); if (it == m_pendingTextureRequests.end()) { @@ -4553,6 +4602,7 @@ bool Minecraft::addPendingClientTextureRequest( } void Minecraft::handleClientTextureReceived(const std::wstring& textureName) { + ZoneScopedN("Minecraft::handleClientTextureReceived"); auto it = find(m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName); if (it != m_pendingTextureRequests.end()) { @@ -4561,10 +4611,12 @@ void Minecraft::handleClientTextureReceived(const std::wstring& textureName) { } unsigned int Minecraft::getCurrentTexturePackId() { + ZoneScopedN("Minecraft::getCurrentTexturePackId"); return skins->getSelected()->getId(); } ColourTable* Minecraft::getColourTable() { + ZoneScopedN("Minecraft::getColourTable"); TexturePack* selected = skins->getSelected(); ColourTable* colours = selected->getColourTable(); diff --git a/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp b/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp index 41e24a74b..0dc7b6b8c 100644 --- a/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp +++ b/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp @@ -1,3 +1,6 @@ +#ifdef TRACY_ENABLE +#include +#endif #include "McRegionChunkStorage.h" #include @@ -45,7 +48,8 @@ C4JThread* McRegionChunkStorage::s_saveThreads[3]; McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile* saveFile, const std::wstring& prefix) : m_prefix(prefix) { - m_saveFile = saveFile; + ZoneScopedN("m_prefix"); + m_saveFile = saveFile; // Make sure that if there are any files for regions to be created, that // they are created in the order that suits us for making the initial level @@ -89,17 +93,20 @@ McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile* saveFile, memcpy(savedData.data(), bos.buf.data(), bos.size()); m_entityData[index] = savedData; +#ifdef TRACY_ENABLE + TracyPlot("McRegion EntityData Map Size", (int64_t)m_entityData.size()); +#endif } } #endif } McRegionChunkStorage::~McRegionChunkStorage() { - // vectors manage their own memory; clearing the map is sufficient + ZoneScopedN("McRegionChunkStorage"); // vectors manage their own memory; clearing the map is sufficient } LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { - DataInputStream* regionChunkInputStream = + ZoneScopedN("McRegionChunkStorage::load"); DataInputStream* regionChunkInputStream = RegionFileCache::getChunkDataInputStream(m_saveFile, m_prefix, x, z); #if defined(SPLIT_SAVES) @@ -114,6 +121,9 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { auto it = m_entityData.find(index); if (it != m_entityData.end()) { m_entityData.erase(it); +#ifdef TRACY_ENABLE + TracyPlot("McRegion EntityData Map Size", (int64_t)m_entityData.size()); +#endif } } #endif @@ -193,7 +203,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { } void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) { - level->checkSession(); + ZoneScopedN("McRegionChunkStorage::save"); level->checkSession(); // 4J - removed try/catch // try { @@ -212,6 +222,9 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) { { std::lock_guard lock(cs_memory); s_chunkDataQueue.push_back(output); +#ifdef TRACY_ENABLE + TracyPlot("McRegion ChunkDataQueue Size", (int64_t)s_chunkDataQueue.size()); +#endif } // 4jcraft: WAKE UP, WAKE THE FUCK.. UP s_queueCondition.notify_one(); @@ -254,6 +267,7 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) { } void McRegionChunkStorage::saveEntities(Level* level, LevelChunk* levelChunk) { + ZoneScopedN("McRegionChunkStorage::saveEntities"); #if defined(SPLIT_SAVES) // 4j added cast to unsigned and changed index to u uint64_t index = ((uint64_t)(uint32_t)(levelChunk->x) << 32) | @@ -272,10 +286,16 @@ void McRegionChunkStorage::saveEntities(Level* level, LevelChunk* levelChunk) { memcpy(savedData.data(), bos.buf.data(), bos.size()); m_entityData[index] = savedData; +#ifdef TRACY_ENABLE + TracyPlot("McRegion EntityData Map Size", (int64_t)m_entityData.size()); +#endif } else { auto it = m_entityData.find(index); if (it != m_entityData.end()) { m_entityData.erase(it); +#ifdef TRACY_ENABLE + TracyPlot("McRegion EntityData Map Size", (int64_t)m_entityData.size()); +#endif } } delete newTag; @@ -284,6 +304,7 @@ void McRegionChunkStorage::saveEntities(Level* level, LevelChunk* levelChunk) { } void McRegionChunkStorage::loadEntities(Level* level, LevelChunk* levelChunk) { + ZoneScopedN("McRegionChunkStorage::loadEntities"); #if defined(SPLIT_SAVES) int64_t index = ((int64_t)(levelChunk->x) << 32) | (((int64_t)(levelChunk->z)) & 0x00000000FFFFFFFF); @@ -303,6 +324,7 @@ void McRegionChunkStorage::loadEntities(Level* level, LevelChunk* levelChunk) { void McRegionChunkStorage::tick() { m_saveFile->tick(); } void McRegionChunkStorage::flush() { + ZoneScopedN("McRegionChunkStorage::flush"); #if defined(SPLIT_SAVES) ConsoleSavePath currentFile = ConsoleSavePath(m_prefix + std::wstring(L"entities.dat")); @@ -323,7 +345,7 @@ void McRegionChunkStorage::flush() { } void McRegionChunkStorage::staticCtor() { - for (unsigned int i = 0; i < 3; ++i) { + ZoneScopedN("McRegionChunkStorage::staticCtor"); for (unsigned int i = 0; i < 3; ++i) { char threadName[256]; sprintf(threadName, "McRegion Save thread %d\n", i); C4JThread::setThreadName(0, threadName); @@ -342,6 +364,10 @@ void McRegionChunkStorage::staticCtor() { // 4jcraft: removed the wasting 100ms chunk loading part. int McRegionChunkStorage::runSaveThreadProc(void* lpParam) { + ZoneScopedN("McRegionChunkStorage::runSaveThreadProc"); + #ifdef TRACY_ENABLE + tracy::SetThreadName("McRegionChunkStorage Save Thread"); + #endif Compression::CreateNewThreadStorage(); bool running = true; @@ -352,6 +378,9 @@ int McRegionChunkStorage::runSaveThreadProc(void* lpParam) { s_queueCondition.wait(lock, [] { return !s_chunkDataQueue.empty(); }); dos = s_chunkDataQueue.front(); s_chunkDataQueue.pop_front(); +#ifdef TRACY_ENABLE + TracyPlot("McRegion ChunkDataQueue Size", (int64_t)s_chunkDataQueue.size()); +#endif s_runningThreadCount++; } // Unlock so the main thread can keep working @@ -382,7 +411,7 @@ void McRegionChunkStorage::WaitIfTooManyQueuedChunks() { WaitForSaves(); } // Static // 4jcraft: Better waiting system void McRegionChunkStorage::WaitForAllSaves() { - std::unique_lock lock(cs_memory); + ZoneScopedN("McRegionChunkStorage::WaitForAllSaves"); std::unique_lock lock(cs_memory); // Pause the main thread instantly until queue is 0 AND workers are done s_waitCondition.wait(lock, [] { return s_chunkDataQueue.empty() && s_runningThreadCount == 0; @@ -391,7 +420,7 @@ void McRegionChunkStorage::WaitForAllSaves() { // Static void McRegionChunkStorage::WaitForSaves() { - static const int MAX_QUEUE_SIZE = 12; + ZoneScopedN("McRegionChunkStorage::WaitForSaves"); static const int MAX_QUEUE_SIZE = 12; static const int DESIRED_QUEUE_SIZE = 6; diff --git a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp index 7f778a06f..c6c0cabb5 100644 --- a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp +++ b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp @@ -1,3 +1,6 @@ +#ifdef TRACY_ENABLE +#include +#endif #include "RegionFile.h" #include @@ -19,7 +22,8 @@ std::vector RegionFile::emptySector(SECTOR_BYTES); RegionFile::RegionFile(ConsoleSaveFile* saveFile, File* path) { - _lastModified = 0; + _lastModified = 0; + ZoneScopedN("RegionFile::RegionFile"); m_saveFile = saveFile; @@ -143,7 +147,7 @@ RegionFile::RegionFile(ConsoleSaveFile* saveFile, File* path) { void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile // conversion between platforms { - if (m_bIsEmpty == false) { + ZoneScopedN("RegionFile::writeAllOffsets"); if (m_bIsEmpty == false) { // save all the offsets and timestamps m_saveFile->LockSaveAccess(); @@ -162,7 +166,7 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile } } RegionFile::~RegionFile() { - delete[] offsets; + ZoneScopedN("RegionFile"); delete[] offsets; delete[] chunkTimestamps; delete sectorFree; m_saveFile->closeHandle(fileEntry); @@ -180,7 +184,7 @@ int RegionFile::getSizeDelta() // TODO - was synchronized DataInputStream* RegionFile::getChunkDataInputStream( int x, int z) // TODO - was synchronized { - if (outOfBounds(x, z)) { + ZoneScopedN("RegionFile::getChunkDataInputStream"); if (outOfBounds(x, z)) { // debugln("READ", x, z, "out of bounds"); return nullptr; } @@ -281,7 +285,7 @@ DataInputStream* RegionFile::getChunkDataInputStream( } DataOutputStream* RegionFile::getChunkDataOutputStream(int x, int z) { - // 4J - was DeflatorOutputStream in here too, but we've already compressed + ZoneScopedN("RegionFile::getChunkDataOutputStream"); // 4J - was DeflatorOutputStream in here too, but we've already compressed return new DataOutputStream(new ChunkBuffer(this, x, z)); } @@ -289,7 +293,7 @@ DataOutputStream* RegionFile::getChunkDataOutputStream(int x, int z) { void RegionFile::write(int x, int z, std::uint8_t* data, int length) // TODO - was synchronized { - // 4J Stu - Do the compression here so that we know how much space we need + ZoneScopedN("RegionFile::write"); // 4J Stu - Do the compression here so that we know how much space we need // to store the compressed data std::uint8_t* compData = new std::uint8_t[length + @@ -404,7 +408,7 @@ void RegionFile::write(int x, int z, std::uint8_t* data, /* write a chunk data to the region file at specified sector number */ void RegionFile::write(int sectorNumber, std::uint8_t* data, int length, unsigned int compLength) { - unsigned int numberOfBytesWritten = 0; + ZoneScopedN("RegionFile::write"); unsigned int numberOfBytesWritten = 0; // SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); m_saveFile->setFilePointer(fileEntry, sectorNumber * SECTOR_BYTES, SaveFileSeekOrigin::Begin); @@ -429,7 +433,7 @@ void RegionFile::write(int sectorNumber, std::uint8_t* data, int length, } void RegionFile::zero(int sectorNumber, int length) { - unsigned int numberOfBytesWritten = 0; + ZoneScopedN("RegionFile::zero"); unsigned int numberOfBytesWritten = 0; // SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); m_saveFile->setFilePointer(fileEntry, sectorNumber * SECTOR_BYTES, SaveFileSeekOrigin::Begin); @@ -448,7 +452,7 @@ bool RegionFile::hasChunk(int x, int z) { return getOffset(x, z) != 0; } // 4J added - write the initial two sectors that used to be written in the ctor // when the file was empty void RegionFile::insertInitialSectors() { - m_saveFile->setFilePointer(fileEntry, 0, SaveFileSeekOrigin::Begin); + ZoneScopedN("RegionFile::insertInitialSectors"); m_saveFile->setFilePointer(fileEntry, 0, SaveFileSeekOrigin::Begin); unsigned int numberOfBytesWritten = 0; std::uint8_t zeroBytes[SECTOR_BYTES]; memset(zeroBytes, 0, SECTOR_BYTES); diff --git a/targets/minecraft/world/level/chunk/storage/RegionFileCache.cpp b/targets/minecraft/world/level/chunk/storage/RegionFileCache.cpp index ac6abe580..f79740556 100644 --- a/targets/minecraft/world/level/chunk/storage/RegionFileCache.cpp +++ b/targets/minecraft/world/level/chunk/storage/RegionFileCache.cpp @@ -1,3 +1,6 @@ +#ifdef TRACY_ENABLE +#include +#endif #include "RegionFileCache.h" #include @@ -14,7 +17,7 @@ class DataOutputStream; RegionFileCache RegionFileCache::s_defaultCache; bool RegionFileCache::useSplitSaves(ESavePlatform platform) { - switch (platform) { + ZoneScopedN("RegionFileCache::useSplitSaves"); switch (platform) { case SAVE_FILE_PLATFORM_XBONE: case SAVE_FILE_PLATFORM_PS4: return true; @@ -27,7 +30,7 @@ RegionFile* RegionFileCache::_getRegionFile( ConsoleSaveFile* saveFile, const std::wstring& prefix, int chunkX, int chunkZ) // 4J - TODO was synchronized { - // 4J Jev - changed back to use of the File class. + ZoneScopedN("RegionFileCache::_getRegionFile"); // 4J Jev - changed back to use of the File class. // char file[MAX_PATH_SIZE]; // sprintf(file,"%s\\region\\r.%d.%d.mcr",basePath,chunkX >> 5,chunkZ >> 5); @@ -71,7 +74,7 @@ if (!regionDir.exists()) void RegionFileCache::_clear() // 4J - TODO was synchronized { - auto itEnd = cache.end(); + ZoneScopedN("RegionFileCache::_clear"); auto itEnd = cache.end(); for (auto it = cache.begin(); it != itEnd; it++) { // 4J - removed try/catch // try { @@ -90,14 +93,14 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized int RegionFileCache::_getSizeDelta(ConsoleSaveFile* saveFile, const std::wstring& prefix, int chunkX, int chunkZ) { - RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ); + ZoneScopedN("RegionFileCache::_getSizeDelta"); RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ); return r->getSizeDelta(); } DataInputStream* RegionFileCache::_getChunkDataInputStream( ConsoleSaveFile* saveFile, const std::wstring& prefix, int chunkX, int chunkZ) { - RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ); + ZoneScopedN("RegionFileCache::_getChunkDataInputStream"); RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ); if (useSplitSaves(saveFile->getSavePlatform())) { return r->getChunkDataInputStream(chunkX & 15, chunkZ & 15); } else { @@ -108,7 +111,7 @@ DataInputStream* RegionFileCache::_getChunkDataInputStream( DataOutputStream* RegionFileCache::_getChunkDataOutputStream( ConsoleSaveFile* saveFile, const std::wstring& prefix, int chunkX, int chunkZ) { - RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ); + ZoneScopedN("RegionFileCache::_getChunkDataOutputStream"); RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ); if (useSplitSaves(saveFile->getSavePlatform())) { return r->getChunkDataOutputStream(chunkX & 15, chunkZ & 15); } else { diff --git a/targets/platform/meson.build b/targets/platform/meson.build index 893bcf60c..6e242bb53 100644 --- a/targets/platform/meson.build +++ b/targets/platform/meson.build @@ -35,7 +35,7 @@ sdl2_sources = files( lib_platform_sdl2 = static_library('platform_sdl2', sdl2_sources, include_directories: [platform_inc, include_directories('sdl2')], - dependencies: [_sdl2, _gl, _threads, glm_dep, stb_dep], + dependencies: [_sdl2, _gl, _threads, glm_dep, stb_dep, tracy_client_dep], cpp_args: _defs + global_cpp_args + global_cpp_defs, ) @@ -44,7 +44,7 @@ lib_platform_sdl2 = static_library('platform_sdl2', render_dep = declare_dependency( link_with: lib_platform_sdl2, include_directories: [platform_inc, include_directories('sdl2')], - dependencies: [_sdl2, _gl, _threads, glm_dep], + dependencies: [_sdl2, _gl, _threads, glm_dep, tracy_client_dep], ) input_dep = render_dep profile_dep = render_dep diff --git a/targets/platform/sdl2/Render.cpp b/targets/platform/sdl2/Render.cpp index 0e570dc1d..9ca3c13dd 100644 --- a/targets/platform/sdl2/Render.cpp +++ b/targets/platform/sdl2/Render.cpp @@ -8,6 +8,19 @@ #include "SDL_video.h" #include "gl3_loader.h" +#ifdef TRACY_ENABLE + #include + #include +#else + #define ZoneScoped + #define ZoneScopedN(name) + #define TracyGpuContext + #define TracyGpuContextName(name, size) + #define TracyGpuCollect + #define TracyGpuZone(name) + #define TracyGpuZoneC(name, color) +#endif + // undefine macros from header to avoid argument mismatch #undef glGenTextures #undef glDeleteTextures @@ -92,7 +105,10 @@ static bool s_fullscreen = false; static pthread_key_t s_glCtxKey; static pthread_once_t s_glCtxKeyOnce = PTHREAD_ONCE_INIT; -static void makeGLCtxKey() { pthread_key_create(&s_glCtxKey, nullptr); } +static void makeGLCtxKey() { + ZoneScoped; + pthread_key_create(&s_glCtxKey, nullptr); +} static const int MAX_SHARED_CTXS = 6; static SDL_Window* s_sharedWins[MAX_SHARED_CTXS] = {}; static SDL_GLContext s_sharedCtxs[MAX_SHARED_CTXS] = {}; @@ -622,6 +638,7 @@ static GLenum mapPrim(int pt) { // Initialises the renderer void C4JRender::Initialise() { + ZoneScoped; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "[4J_Render] SDL_Init: %s\n", SDL_GetError()); return; @@ -664,6 +681,8 @@ void C4JRender::Initialise() { #ifndef GLES gl3_load(); #endif + TracyGpuContext; + TracyGpuContextName("OpenGL", 6); int fw, fh; SDL_GetWindowSize(s_window, &fw, &fh); onFramebufferResize(fw, fh); @@ -713,6 +732,7 @@ void C4JRender::Initialise() { } void C4JRender::InitialiseContext() { + ZoneScoped; if (!s_window) return; pthread_once(&s_glCtxKeyOnce, makeGLCtxKey); if (s_mainThreadSet && pthread_equal(pthread_self(), s_mainThread)) { @@ -743,6 +763,7 @@ void C4JRender::InitialiseContext() { } void C4JRender::StartFrame() { + ZoneScoped; Set_matrixDirty(); int w, h; SDL_GetWindowSize(s_window, &w, &h); @@ -752,6 +773,7 @@ void C4JRender::StartFrame() { } void C4JRender::Present() { + ZoneScoped; if (!s_window) return; SDL_Event ev; while (SDL_PollEvent(&ev)) { @@ -766,6 +788,7 @@ void C4JRender::Present() { } glFlush(); SDL_GL_SwapWindow(s_window); + TracyGpuCollect; } void C4JRender::SetWindowSize(int w, int h) { @@ -785,6 +808,7 @@ void C4JRender::GetFramebufferSize(int& w, int& h) { void C4JRender::Close() { s_window = nullptr; } void C4JRender::Shutdown() { + ZoneScoped; pthread_mutex_lock(&s_glCallMtx); for (auto& kv : s_chunkPool) kv.second.destroy(); s_chunkPool.clear(); @@ -809,6 +833,7 @@ void C4JRender::Shutdown() { void C4JRender::DrawVertices(ePrimitiveType ptype, int count, void* dataIn, eVertexType vType, ePixelShaderType) { + ZoneScoped; if (count <= 0 || !dataIn) return; bool wasQuad = isQuadPrim((int)ptype); @@ -908,6 +933,7 @@ void C4JRender::DrawVertices(ePrimitiveType ptype, int count, void* dataIn, glBufferSubData(GL_ARRAY_BUFFER, 0, (GLsizeiptr)bytes, dataIn); s_streamVBOSize = (GLsizeiptr)bytes; + TracyGpuZone("DrawVertices"); glDrawArrays(glMode, 0, count); glBindVertexArray(0); @@ -916,6 +942,7 @@ void C4JRender::DrawVertices(ePrimitiveType ptype, int count, void* dataIn, } void C4JRender::ReadPixels(int x, int y, int w, int h, void* buf) { + ZoneScoped; if (!buf) return; pthread_mutex_lock(&s_glCallMtx); glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf); @@ -923,6 +950,7 @@ void C4JRender::ReadPixels(int x, int y, int w, int h, void* buf) { } int C4JRender::CBuffCreate(int count) { + ZoneScoped; pthread_mutex_lock(&s_glCallMtx); int b = s_nextListBase; s_nextListBase += count; @@ -931,6 +959,7 @@ int C4JRender::CBuffCreate(int count) { } void C4JRender::CBuffDelete(int first, int count) { + ZoneScoped; pthread_mutex_lock(&s_glCallMtx); for (int i = first; i < first + count; i++) { auto it = s_chunkPool.find(i); @@ -943,6 +972,7 @@ void C4JRender::CBuffDelete(int first, int count) { } void C4JRender::CBuffDeleteAll() { + ZoneScoped; pthread_mutex_lock(&s_glCallMtx); for (auto& kv : s_chunkPool) { kv.second.destroy(); @@ -953,12 +983,14 @@ void C4JRender::CBuffDeleteAll() { } void C4JRender::CBuffStart(int index, bool) { + ZoneScoped; s_recListId = index; s_recVerts.clear(); s_recDraws.clear(); } void C4JRender::CBuffEnd() { + ZoneScoped; if (s_recListId < 0) return; pthread_mutex_lock(&s_glCallMtx); ChunkBuffer& cb = s_chunkPool[s_recListId]; @@ -978,6 +1010,7 @@ void C4JRender::CBuffEnd() { } void C4JRender::CBuffClear(int index) { + ZoneScoped; pthread_mutex_lock(&s_glCallMtx); auto it = s_chunkPool.find(index); if (it != s_chunkPool.end()) { @@ -988,6 +1021,7 @@ void C4JRender::CBuffClear(int index) { } bool C4JRender::CBuffCall(int index, bool) { + ZoneScoped; pthread_mutex_lock(&s_glCallMtx); auto it = s_chunkPool.find(index); if (it == s_chunkPool.end() || !it->second.valid) { @@ -1018,6 +1052,7 @@ bool C4JRender::CBuffCall(int index, bool) { pushRenderState(); + TracyGpuZone("ChunkBufferDraw"); glBindVertexArray(cb.vao); for (const auto& dc : cb.draws) glDrawArrays(dc.prim, dc.first, dc.count); glBindVertexArray(0); @@ -1271,19 +1306,23 @@ void C4JRender::StateSetActiveTexture(int tex) { } int C4JRender::TextureCreate() { + ZoneScoped; GLuint id; glGenTextures(1, &id); return (int)id; } void C4JRender::TextureFree(int i) { + ZoneScoped; GLuint id = (GLuint)i; glDeleteTextures(1, &id); } void C4JRender::TextureBind(int idx) { + ZoneScoped; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, idx < 0 ? 0 : (GLuint)idx); } void C4JRender::TextureBindVertex(int idx, bool scaleLight) { + ZoneScoped; if (idx < 0) { if (s_rs.useLightmap) { s_rs.useLightmap = false; @@ -1312,6 +1351,7 @@ void C4JRender::TextureBindVertex(int idx, bool scaleLight) { } } void C4JRender::TextureSetTextureLevels(int l) { + ZoneScoped; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, l > 0 ? l - 1 : 0); if (l > 1) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, @@ -1321,6 +1361,7 @@ void C4JRender::TextureSetTextureLevels(int l) { } int C4JRender::TextureGetTextureLevels() { return 1; } void C4JRender::TextureData(int w, int h, void* d, int lvl, eTextureFormat) { + ZoneScoped; glTexImage2D(GL_TEXTURE_2D, lvl, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, d); if (lvl == 0) { @@ -1333,15 +1374,18 @@ void C4JRender::TextureData(int w, int h, void* d, int lvl, eTextureFormat) { } void C4JRender::TextureDataUpdate(int xo, int yo, int w, int h, void* d, int lvl) { + ZoneScoped; glTexSubImage2D(GL_TEXTURE_2D, lvl, xo, yo, w, h, GL_RGBA, GL_UNSIGNED_BYTE, d); } void C4JRender::TextureSetParam(int p, int v) { + ZoneScoped; glTexParameteri(GL_TEXTURE_2D, p, v); } static int stbLoad(unsigned char* data, int w, int h, D3DXIMAGE_INFO* info, int** out) { + ZoneScoped; int* px = new int[w * h]; for (int i = 0; i < w * h; i++) { unsigned char r = data[i * 4], g = data[i * 4 + 1], b = data[i * 4 + 2], @@ -1356,6 +1400,7 @@ static int stbLoad(unsigned char* data, int w, int h, D3DXIMAGE_INFO* info, return 0; // Success } int C4JRender::LoadTextureData(const char* fn, D3DXIMAGE_INFO* i, int** o) { + ZoneScoped; int w, h, c; unsigned char* d = stbi_load(fn, &w, &h, &c, 4); if (!d) return -1; // Failure @@ -1365,6 +1410,7 @@ int C4JRender::LoadTextureData(const char* fn, D3DXIMAGE_INFO* i, int** o) { } int C4JRender::LoadTextureData(uint8_t* pb, uint32_t nb, D3DXIMAGE_INFO* i, int** o) { + ZoneScoped; int w, h, c; unsigned char* d = stbi_load_from_memory(pb, (int)nb, &w, &h, &c, 4); if (!d) return -1; // Failure