From 3b883bf9fed14de06dea4786a67e37a63a9d0e01 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 30 Mar 2025 04:28:49 +0000 Subject: [PATCH] [idd] driver: use a timeout instead of an event wait. Waiting on the events is dangerous as there is a race here where we may end up stuck as the events need to be auto-reset --- idd/LGIdd/CD3D12Device.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/idd/LGIdd/CD3D12Device.cpp b/idd/LGIdd/CD3D12Device.cpp index e8533d15..46804dab 100644 --- a/idd/LGIdd/CD3D12Device.cpp +++ b/idd/LGIdd/CD3D12Device.cpp @@ -171,21 +171,17 @@ bool CD3D12Device::HeapTest() CD3D12CommandQueue * CD3D12Device::GetCopyQueue() { - HANDLE waitOn[ARRAYSIZE(m_copyQueue)]; - - for (int i = 0; i < ARRAYSIZE(m_copyQueue); ++i) + for(int c = 0; c < 100; ++c) { - auto& queue = m_copyQueue[i]; - if (queue.IsReady()) - return &queue; - - waitOn[i] = queue.GetEvent(); + for (int i = 0; i < ARRAYSIZE(m_copyQueue); ++i) + { + auto& queue = m_copyQueue[i]; + if (queue.IsReady()) + return &queue; + } + Sleep(1); } - DEBUG_TRACE("Wait"); - DWORD ready = WaitForMultipleObjects(ARRAYSIZE(waitOn), waitOn, FALSE, INFINITE); - if (ready < ARRAYSIZE(waitOn)) - return &m_copyQueue[ready]; - + DEBUG_ERROR("Failed to get a copy queue"); return nullptr; } \ No newline at end of file