From babfe9b1e27b4169e83499b95b51ad97dd2add90 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 6 Aug 2026 12:34:06 +1000 Subject: [PATCH] [idd] d3d12: harvest completed command slots Check a busy slot fence before waiting for its thread-pool callback. This lets the caller complete finished GPU work inline and avoids a scheduler delay before the allocator and command list can be reused. --- idd/LGIdd/CD3D12CommandQueue.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/idd/LGIdd/CD3D12CommandQueue.cpp b/idd/LGIdd/CD3D12CommandQueue.cpp index 5d48f362..98cff4a3 100644 --- a/idd/LGIdd/CD3D12CommandQueue.cpp +++ b/idd/LGIdd/CD3D12CommandQueue.cpp @@ -510,6 +510,12 @@ CD3D12CommandSlot * CD3D12CommandQueue::Acquire(UINT slotIndex) const ULONGLONG deadline = GetTickCount64() + 100; for (;;) { + if (m_slots[slotIndex].Acquire()) + return &m_slots[slotIndex]; + + // The GPU may already be finished while its thread-pool callback is + // still pending. Complete it here before sleeping on callback dispatch. + m_slots[slotIndex].OnCompletion(false); if (m_slots[slotIndex].Acquire()) return &m_slots[slotIndex]; if (m_failed.load(std::memory_order_acquire))