mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
perf: limit NPC composite texture processing to 2ms per frame
processAsyncNpcCompositeResults() had no per-frame budget cap, so when many NPCs finished async skin compositing simultaneously (e.g. right after world load), all results were finalized in a single frame causing up to 284ms frame stalls. Apply the same 2ms budget pattern used by processAsyncCreatureResults. Load screen still processes all pending composites without the cap (unlimited=true).
This commit is contained in:
parent
ac0fe1bd61
commit
dc2aab5e90
2 changed files with 13 additions and 3 deletions
|
|
@ -4397,7 +4397,7 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
|||
// During load screen warmup: lift per-frame budgets so GPU uploads
|
||||
// and spawns happen in bulk while the loading screen is still visible.
|
||||
processCreatureSpawnQueue(true);
|
||||
processAsyncNpcCompositeResults();
|
||||
processAsyncNpcCompositeResults(true);
|
||||
// Process equipment queue more aggressively during warmup (multiple per iteration)
|
||||
for (int i = 0; i < 8 && (!deferredEquipmentQueue_.empty() || !asyncEquipmentLoads_.empty()); i++) {
|
||||
processDeferredEquipmentQueue();
|
||||
|
|
@ -7072,11 +7072,21 @@ void Application::processAsyncCreatureResults(bool unlimited) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::processAsyncNpcCompositeResults() {
|
||||
void Application::processAsyncNpcCompositeResults(bool unlimited) {
|
||||
auto* charRenderer = renderer ? renderer->getCharacterRenderer() : nullptr;
|
||||
if (!charRenderer) return;
|
||||
|
||||
// Budget: 2ms per frame to avoid stalling when many NPCs complete skin compositing
|
||||
// simultaneously. In unlimited mode (load screen), process everything without cap.
|
||||
static constexpr float kCompositeBudgetMs = 2.0f;
|
||||
auto startTime = std::chrono::steady_clock::now();
|
||||
|
||||
for (auto it = asyncNpcCompositeLoads_.begin(); it != asyncNpcCompositeLoads_.end(); ) {
|
||||
if (!unlimited) {
|
||||
float elapsed = std::chrono::duration<float, std::milli>(
|
||||
std::chrono::steady_clock::now() - startTime).count();
|
||||
if (elapsed >= kCompositeBudgetMs) break;
|
||||
}
|
||||
if (!it->future.valid() ||
|
||||
it->future.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready) {
|
||||
++it;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue