From d2ae2b38187b9865a00e7be28db12eea086f52e1 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 29 Jun 2021 23:09:30 +0300 Subject: [PATCH] Support lazy CGraphics::CommitResources --- Runtime/CMain.cpp | 6 ++++++ Runtime/Graphics/CGraphics.cpp | 1 + Runtime/Graphics/CGraphics.hpp | 24 +++++++++++++++++++++++- extern/boo | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index c23abf78b..d39f0e5da 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -397,6 +397,7 @@ public: m_window->waitForRetrace(); } OPTICK_FRAME("MainThread"); + CGraphics::SetCommitResourcesAsLazy(true); boo::SWindowRect rect = m_windowCallback.m_lastRect; rect.location = {0, 0}; @@ -465,6 +466,11 @@ public: m_imGuiConsole.ShowAboutWindow(false, m_errorString); } + { + OPTICK_EVENT("Flush"); + CGraphics::SetCommitResourcesAsLazy(false); + } + { OPTICK_EVENT("Draw"); gfxQ->setRenderTarget(m_renderTex); diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index 36ed24dfa..0547130ee 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -37,6 +37,7 @@ u32 CGraphics::g_FrameCounter = 0; u32 CGraphics::g_Framerate = 0; u32 CGraphics::g_FramesPast = 0; frame_clock::time_point CGraphics::g_FrameStartTime = frame_clock::now(); +bool CGraphics::g_commitAsLazy = false; const std::array CGraphics::skCubeBasisMats{{ /* Right */ diff --git a/Runtime/Graphics/CGraphics.hpp b/Runtime/Graphics/CGraphics.hpp index 6f018da9d..81c82d720 100644 --- a/Runtime/Graphics/CGraphics.hpp +++ b/Runtime/Graphics/CGraphics.hpp @@ -346,8 +346,30 @@ public: static const boo::SystemChar* PlatformName() { return g_BooPlatformName; } + + static bool g_commitAsLazy; + static void SetCommitResourcesAsLazy(bool newStatus) { + if (newStatus != g_commitAsLazy) { + g_commitAsLazy = newStatus; + if (!newStatus && g_BooFactory) { + g_BooFactory->commitPendingTransaction(); + } + } + } + static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs) { - g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse); + CommitResources(commitFunc __BooTraceArgsUse, g_commitAsLazy); + } + + static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs, bool lazy) { + if (!g_BooFactory) { + return; + } + if (lazy) { + g_BooFactory->lazyCommitTransaction(commitFunc __BooTraceArgsUse); + } else { + g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse); + } } static void SetShaderDataBinding(const boo::ObjToken& binding) { diff --git a/extern/boo b/extern/boo index 542191fd7..c6aed360e 160000 --- a/extern/boo +++ b/extern/boo @@ -1 +1 @@ -Subproject commit 542191fd70e8835576f2d1320859291518972e8a +Subproject commit c6aed360e6bb0537afc4f597104810f76e1340fc