From c3c9f9d60139a7913c911b6f3f600c8a69848b07 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 23 Feb 2022 03:19:46 -0500 Subject: [PATCH] Remove shader warmup --- Runtime/CMain.cpp | 6 --- Runtime/Graphics/CModel.hpp | 3 -- Runtime/Graphics/CModelBoo.cpp | 28 -------------- Runtime/IMain.hpp | 1 - Runtime/MP1/MP1.cpp | 70 ---------------------------------- Runtime/MP1/MP1.hpp | 8 ---- Runtime/World/CGameArea.cpp | 4 -- Runtime/World/CGameArea.hpp | 1 - 8 files changed, 121 deletions(-) diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index f517dc1a7..b80c866cd 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -261,7 +261,6 @@ private: std::unique_ptr m_voiceEngine; Limiter m_limiter{}; - bool m_noShaderWarmup = false; bool m_firstFrame = true; bool m_fullscreenToggleRequested = false; @@ -290,8 +289,6 @@ public: auto arg = static_cast(str); if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+')) m_deferredProject = arg; - if (arg == "--no-shader-warmup") - m_noShaderWarmup = true; else if (arg == "--no-sound") m_voiceEngine->setVolume(0.f); } @@ -368,9 +365,6 @@ public: if (!g_mainMP1 && m_projectInitialized) { g_mainMP1.emplace(nullptr, nullptr); g_mainMP1->Init(m_fileMgr, &m_cvarManager, m_voiceEngine.get(), *m_amuseAllocWrapper); - if (!m_noShaderWarmup) { - g_mainMP1->WarmupShaders(); - } } float dt = 1 / 60.f; diff --git a/Runtime/Graphics/CModel.hpp b/Runtime/Graphics/CModel.hpp index 44b8bffe8..1e3255d23 100644 --- a/Runtime/Graphics/CModel.hpp +++ b/Runtime/Graphics/CModel.hpp @@ -304,9 +304,6 @@ public: // void ApplyVerticesCPU(const boo::ObjToken& vertBuf, // const std::vector>& vn) const; // void RestoreVerticesCPU(const boo::ObjToken& vertBuf) const; - - void _WarmupShaders(); - static void WarmupShaders(const SObjectTag& cmdlTag); }; CFactoryFnReturn FPCModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr&& in, u32 len, diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index 0cf0e6b51..b2afb8c5c 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -1313,34 +1313,6 @@ zeus::CVector3f CModel::GetPoolNormal(size_t idx) const { // vertBuf->unmap(); //} -void CModel::_WarmupShaders() { -// CBooModel::SetDummyTextures(true); -// CBooModel::EnableShadowMaps(g_Renderer->x220_sphereRamp.get(), zeus::CTransform()); -// CGraphics::CProjectionState backupProj = CGraphics::GetProjectionState(); -// zeus::CTransform backupViewPoint = CGraphics::g_ViewMatrix; -// zeus::CTransform backupModel = CGraphics::g_GXModelMatrix; -// CGraphics::SetModelMatrix(zeus::CTransform::Translate(-m_aabb.center())); -// CGraphics::SetViewPointMatrix(zeus::CTransform::Translate(0.f, -2048.f, 0.f)); -// CGraphics::SetOrtho(-2048.f, 2048.f, 2048.f, -2048.f, 0.f, 4096.f); -// CModelFlags defaultFlags; -// for (SShader& shader : x18_matSets) { -// GetInstance().RemapMaterialData(shader); -// GetInstance().UpdateUniformData(defaultFlags, nullptr, nullptr); -// GetInstance().WarmupDrawSurfaces(); -// } -// CGraphics::SetProjectionState(backupProj); -// CGraphics::SetViewPointMatrix(backupViewPoint); -// CGraphics::SetModelMatrix(backupModel); -// CBooModel::DisableShadowMaps(); -// CBooModel::SetDummyTextures(false); -} - -void CModel::WarmupShaders(const SObjectTag& cmdlTag) { - TToken model = g_SimplePool->GetObj(cmdlTag); - CModel* modelObj = model.GetObj(); - modelObj->_WarmupShaders(); -} - CFactoryFnReturn FPCModelFactory(const metaforce::SObjectTag& tag, std::unique_ptr&& in, u32 len, const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef) { CSimplePool* sp = vparms.GetOwnedObj(); diff --git a/Runtime/IMain.hpp b/Runtime/IMain.hpp index 0a7a24449..a32b7b46a 100644 --- a/Runtime/IMain.hpp +++ b/Runtime/IMain.hpp @@ -45,7 +45,6 @@ public: virtual EClientFlowStates GetFlowState() const = 0; virtual void SetFlowState(EClientFlowStates) = 0; virtual size_t GetExpectedIdSize() const = 0; - virtual void WarmupShaders() = 0; virtual EGame GetGame() const = 0; virtual ERegion GetRegion() const = 0; virtual bool IsPAL() const = 0; diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 23c5105bc..ea8525fb1 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -582,7 +582,6 @@ void CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IA amuse::IBackendVoiceAllocator& backend) { InitializeDiscord(); m_cvarMgr = cvarMgr; - m_cvarCommons = std::make_unique(*m_cvarMgr); { const auto discInfo = CDvdFile::DiscInfo(); @@ -723,46 +722,8 @@ void CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IA // g_TweakManager->ReadFromMemoryCard("AudioTweaks"); } -static logvisor::Module WarmupLog("ShaderWarmup"); - -void CMain::WarmupShaders() { - if (!m_warmupTags.empty()) - return; - - m_needsWarmupClear = true; - size_t modelCount = 0; - g_ResFactory->EnumerateResources([&](const SObjectTag& tag) { - if (tag.type == FOURCC('CMDL') || tag.type == FOURCC('MREA')) { - ++modelCount; - } - return true; - }); - m_warmupTags.reserve(modelCount); - - std::unordered_set addedTags; - addedTags.reserve(modelCount); - - g_ResFactory->EnumerateResources([&](const SObjectTag& tag) { - if (tag.type == FOURCC('CMDL') || tag.type == FOURCC('MREA')) { - if (addedTags.find(tag) != addedTags.end()) { - return true; - } - addedTags.insert(tag); - m_warmupTags.push_back(tag); - } - return true; - }); - - m_warmupIt = m_warmupTags.begin(); - - WarmupLog.report(logvisor::Info, FMT_STRING("Began warmup of {} objects"), m_warmupTags.size()); -} - bool CMain::Proc(float dt) { CRandom16::ResetNumNextCalls(); - // Warmup cycle overrides update - if (m_warmupTags.size()) - return false; if (!m_loadedPersistentResources) { x128_globalObjects->m_gameResFactory->LoadPersistentResources(*g_SimplePool); m_loadedPersistentResources = true; @@ -794,37 +755,7 @@ bool CMain::Proc(float dt) { } void CMain::Draw() { - // Warmup cycle overrides draw - if (m_warmupTags.size()) { - if (m_needsWarmupClear) { -// CGraphics::g_BooMainCommandQueue->clearTarget(true, true); - m_needsWarmupClear = false; - } - auto startTime = std::chrono::steady_clock::now(); - while (m_warmupIt != m_warmupTags.end()) { - WarmupLog.report(logvisor::Info, FMT_STRING("[{} / {}] Warming {}"), int(m_warmupIt - m_warmupTags.begin() + 1), - int(m_warmupTags.size()), *m_warmupIt); - - if (m_warmupIt->type == FOURCC('CMDL')) - CModel::WarmupShaders(*m_warmupIt); - else if (m_warmupIt->type == FOURCC('MREA')) - CGameArea::WarmupShaders(*m_warmupIt); - ++m_warmupIt; - - // Approximately 3/4 frame of warmups - auto curTime = std::chrono::steady_clock::now(); - if (std::chrono::duration_cast(curTime - startTime).count() > 12) - break; - } - if (m_warmupIt == m_warmupTags.end()) { - m_warmupTags = std::vector(); - WarmupLog.report(logvisor::Info, FMT_STRING("Finished warmup")); - } - return; - } - x164_archSupport->Draw(); -// m_console->draw(CGraphics::g_BooMainCommandQueue); } void CMain::ShutdownSubsystems() { @@ -839,7 +770,6 @@ void CMain::ShutdownSubsystems() { } void CMain::Shutdown() { -// m_console->unregisterCommand("Give"); x128_globalObjects->m_gameResFactory->UnloadPersistentResources(); x164_archSupport.reset(); ShutdownSubsystems(); diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index e89707ef0..8c4e97dbb 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -215,14 +215,7 @@ private: bool x161_24_gameFrameDrawn : 1 = false; std::unique_ptr x164_archSupport; -// boo::IWindow* m_mainWindow = nullptr; CVarManager* m_cvarMgr = nullptr; - std::unique_ptr m_cvarCommons; -// std::unique_ptr m_console; - // Warmup state - std::vector m_warmupTags; - std::vector::iterator m_warmupIt; - bool m_needsWarmupClear = false; bool m_loadedPersistentResources = false; bool m_doQuit = false; bool m_paused = false; @@ -254,7 +247,6 @@ public: // backend); void Init(const FileStoreManager& storeMgr, CVarManager* cvarManager, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) override; - void WarmupShaders() override; bool Proc(float dt) override; void Draw() override; void Shutdown() override; diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 2a4688b9d..a80e6a870 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -1197,10 +1197,6 @@ void CGameArea::SetAreaAttributes(const CScriptAreaAttributes* areaAttributes) { bool CGameArea::CAreaObjectList::IsQualified(const CEntity& ent) const { return (ent.GetAreaIdAlways() == x200c_areaIdx); } -void CGameArea::WarmupShaders(const SObjectTag& mreaTag) { - // Calling this version of the constructor performs warmup implicitly - [[maybe_unused]] CGameArea area(mreaTag.id); -} void CGameArea::DebugDraw() { if (!m_debugSphereRes) { diff --git a/Runtime/World/CGameArea.hpp b/Runtime/World/CGameArea.hpp index e13c4e580..21feaf747 100644 --- a/Runtime/World/CGameArea.hpp +++ b/Runtime/World/CGameArea.hpp @@ -364,7 +364,6 @@ public: CGameArea* GetNext() const { return x130_next; } - static void WarmupShaders(const SObjectTag& mreaTag); void DebugDraw(); void DebugDrawLight(const CLight& light); };