fix: call draw preLoad before rendering foreground (#1763)

Bug Fixes:
- Improved rendering sequencing so preload work runs before any foreground interface draw tasks, reducing timing-related inconsistencies.
- Refined foreground UI rendering logic: it now renders immediately only when appropriate for offline play, and otherwise enqueues foreground UI updates when map rendering is available—removing the prior fallback that could render at the wrong time.
This commit is contained in:
karlo 2026-07-18 21:46:59 +02:00 committed by GitHub
parent 225ce4d5b5
commit 350e506aa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,6 +26,7 @@
#include "clock.h"
#include "eventdispatcher.h"
#include "garbagecollection.h"
#include "client/game.h"
#include "framework/graphics/drawpoolmanager.h"
#include "framework/graphics/graphics.h"
#include "framework/graphics/image.h"
@ -210,20 +211,22 @@ void GraphicalApplication::run()
continue;
}
const bool canDrawForeground = !g_drawPool.isDrawing(DrawPoolType::FOREGROUND) && m_drawEvents->canDraw(DrawPoolType::FOREGROUND);
{
AutoStat s(STATS_RENDER, "DrawPreload");
m_drawEvents->preLoad();
}
if (canDrawMap()) {
if (canDrawForeground) {
tasks.emplace_back(g_asyncDispatcher->submit_task([] {
AutoStat s(STATS_RENDER, "DrawForegroundUI");
g_ui.render(DrawPoolType::FOREGROUND);
}));
}
bool canDrawForeground = !g_drawPool.isDrawing(DrawPoolType::FOREGROUND) && m_drawEvents->canDraw(DrawPoolType::FOREGROUND);
if (!g_game.isOnline() && canDrawForeground) {
AutoStat s(STATS_RENDER, "DrawForegroundUI");
g_ui.render(DrawPoolType::FOREGROUND);
} else if (canDrawMap() && canDrawForeground) {
tasks.emplace_back(g_asyncDispatcher->submit_task([] {
AutoStat s(STATS_RENDER, "DrawForegroundUI");
g_ui.render(DrawPoolType::FOREGROUND);
}));
{
AutoStat s(STATS_RENDER, "DrawPreload");
m_drawEvents->preLoad();
}
static constexpr std::array<DrawPoolType, 2> types{ DrawPoolType::LIGHT, DrawPoolType::FOREGROUND_MAP };
for (const auto type : types) {
if (m_drawEvents->canDraw(type)) {
@ -241,9 +244,6 @@ void GraphicalApplication::run()
tasks.wait();
tasks.clear();
} else if (canDrawForeground) {
AutoStat s(STATS_RENDER, "DrawForegroundUI");
g_ui.render(DrawPoolType::FOREGROUND);
}
m_mapProcessFrameCounter.update();