From baa36d6c0ff50965463ddb1b5c8763005a60c33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Or=C5=82owski?= Date: Sun, 31 May 2026 11:34:12 +0200 Subject: [PATCH] Fix InstanceStorage upload wait --- game/game/compatibility/cpu32.cpp | 2 +- game/graphics/instancestorage.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/game/game/compatibility/cpu32.cpp b/game/game/compatibility/cpu32.cpp index c5f9a5fdf..c41bcf6be 100644 --- a/game/game/compatibility/cpu32.cpp +++ b/game/game/compatibility/cpu32.cpp @@ -255,7 +255,7 @@ void Cpu32::callFunction(ptr32_t func) { std::string Cpu32::popString() { if(stack.size()==0) - return 0; + return ""; auto ptr = stack.back(); stack.pop_back(); diff --git a/game/graphics/instancestorage.cpp b/game/graphics/instancestorage.cpp index 40c79398a..be52ee868 100644 --- a/game/graphics/instancestorage.cpp +++ b/game/graphics/instancestorage.cpp @@ -207,11 +207,10 @@ bool InstanceStorage::commit(Encoder& cmd, uint8_t fId) { } void InstanceStorage::join() { - while(true) { - std::unique_lock lck(sync); - if(uploadFId<0) - break; - } + std::unique_lock lck(sync); + uploadCnd.wait(lck, [this] { + return uploadFId < 0; + }); } InstanceStorage::Id InstanceStorage::alloc(const size_t size) { @@ -307,13 +306,15 @@ void InstanceStorage::uploadMain() { Workers::setThreadName("InstanceStorage upload"); while(true) { std::unique_lock lck(sync); - uploadCnd.wait(lck); + uploadCnd.wait(lck, [this] { + return uploadFId >= 0; + }); if(uploadFId==Resources::MaxFramesInFlight) break; - if(uploadFId<0) - continue; patchGpu[uploadFId].update(patchCpu); uploadFId = -1; + lck.unlock(); + uploadCnd.notify_all(); } }