Update async load / frame limiter logic

Update nod
This commit is contained in:
Luke Street 2021-06-30 17:54:31 -04:00
parent 78f8716150
commit 6430f6c765
2 changed files with 23 additions and 15 deletions

View File

@ -388,10 +388,29 @@ public:
return; return;
} }
{ const auto targetFrameTime = getTargetFrameTime();
OPTICK_EVENT("Wait for Retrace"); bool skipRetrace = false;
m_window->waitForRetrace(); if (g_ResFactory != nullptr) {
OPTICK_EVENT("Async Load Resources");
const auto idleTime = m_limiter.SleepTime(targetFrameTime);
skipRetrace = g_ResFactory->AsyncIdle(idleTime);
} }
if (skipRetrace) {
// We stopped loading resources to catch the next frame
m_limiter.Reset();
} else {
// No more to load, and we're under frame time
{
OPTICK_EVENT("Wait for Retrace");
m_window->waitForRetrace();
}
{
OPTICK_EVENT("Sleep");
m_limiter.Sleep(targetFrameTime);
}
}
OPTICK_FRAME("MainThread"); OPTICK_FRAME("MainThread");
boo::SWindowRect rect = m_windowCallback.m_lastRect; boo::SWindowRect rect = m_windowCallback.m_lastRect;
@ -490,17 +509,6 @@ public:
gfxQ->resolveDisplay(m_renderTex); gfxQ->resolveDisplay(m_renderTex);
if (g_ResFactory != nullptr) {
const auto targetFrameTime = getTargetFrameTime();
const auto idleTime = m_limiter.SleepTime(targetFrameTime);
if (g_ResFactory->AsyncIdle(idleTime)) {
m_limiter.Reset();
} else {
// No more to load; sleep
m_limiter.Sleep(targetFrameTime);
}
}
if (m_voiceEngine) { if (m_voiceEngine) {
m_voiceEngine->pumpAndMixVoices(); m_voiceEngine->pumpAndMixVoices();
} }

2
extern/nod vendored

@ -1 +1 @@
Subproject commit 0985c63958024d054517216fc2dc0f7c7970a8a3 Subproject commit 0396cf467b1cbd68779db200ff390e4330160254