File tree Expand file tree Collapse file tree
src/graphics/host_gpu/renderer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -426,11 +426,16 @@ size_t CommandScheduler::GrowCommandBuffers() {
426426void 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 ;
You can’t perform that action at this time.
0 commit comments