Skip to content

Commit 9937a8f

Browse files
Fix commandScheduler.cpp: add progressive fallback in BeginNext()
1 parent 366bab4 commit 9937a8f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/graphics/host_gpu/renderer/commandScheduler.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,16 @@ size_t CommandScheduler::GrowCommandBuffers() {
426426
void CommandScheduler::BeginNext() {
427427
EXIT_IF(m_recording);
428428

429+
// Try to find a reusable buffer with progressive fallback
429430
auto candidate = FindReusableBuffer(m_master.KnownGpuTick());
430-
bool refreshed = false;
431431
if (candidate < 0) {
432432
m_master.Refresh();
433-
refreshed = true;
433+
candidate = FindReusableBuffer(m_master.KnownGpuTick());
434+
}
435+
if (candidate < 0) {
436+
// Last resort: wait for master and try again
437+
m_master.Wait(m_master.NextTick() - 1);
438+
m_master.Refresh();
434439
candidate = FindReusableBuffer(m_master.KnownGpuTick());
435440
}
436441
if (candidate < 0) {
@@ -439,7 +444,7 @@ void CommandScheduler::BeginNext() {
439444

440445
m_current = candidate;
441446
Current().WaitForFenceAndReset();
442-
PopPendingOperations(!refreshed);
447+
PopPendingOperations(candidate >= static_cast<int>(m_buffers.size()));
443448
BindCurrent();
444449
Current().Begin();
445450
m_recording = true;

0 commit comments

Comments
 (0)