From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/d3dx10_43_main.c | 48 +++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx10_43/d3dx10_43_main.c b/dlls/d3dx10_43/d3dx10_43_main.c index 5804a1058b0..df1e3f413f5 100644 --- a/dlls/d3dx10_43/d3dx10_43_main.c +++ b/dlls/d3dx10_43/d3dx10_43_main.c @@ -404,8 +404,52 @@ static HRESULT WINAPI thread_pump_ProcessDeviceWorkItems(ID3DX10ThreadPump *ifac
static HRESULT WINAPI thread_pump_PurgeAllItems(ID3DX10ThreadPump *iface) { - FIXME("iface %p stub!\n", iface); - return E_NOTIMPL; + struct thread_pump *thread_pump = impl_from_ID3DX10ThreadPump(iface); + struct list list = LIST_INIT(list); + struct work_item *work_item; + LONG v; + + TRACE("iface %p.\n", iface); + + while (1) + { + AcquireSRWLockExclusive(&thread_pump->io_lock); + list_move_tail(&list, &thread_pump->io_queue); + thread_pump->io_count = 0; + ReleaseSRWLockExclusive(&thread_pump->io_lock); + + AcquireSRWLockExclusive(&thread_pump->proc_lock); + list_move_tail(&list, &thread_pump->proc_queue); + thread_pump->proc_count = 0; + ReleaseSRWLockExclusive(&thread_pump->proc_lock); + + while (!list_empty(&list)) + { + work_item = LIST_ENTRY(list_head(&list), struct work_item, entry); + list_remove(&work_item->entry); + work_item_free(work_item, TRUE); + if (!InterlockedDecrement(&thread_pump->processing_count)) + RtlWakeAddressAll((void *)&thread_pump->processing_count); + } + + if (!(v = thread_pump->processing_count)) + break; + + RtlWaitOnAddress((void *)&thread_pump->processing_count, &v, sizeof(v), NULL); + } + + AcquireSRWLockExclusive(&thread_pump->device_lock); + list_move_tail(&list, &thread_pump->device_queue); + thread_pump->device_count = 0; + ReleaseSRWLockExclusive(&thread_pump->device_lock); + + while(!list_empty(&list)) + { + work_item = LIST_ENTRY(list_head(&list), struct work_item, entry); + list_remove(&work_item->entry); + work_item_free(work_item, TRUE); + } + return S_OK; }
static HRESULT WINAPI thread_pump_GetQueueStatus(ID3DX10ThreadPump *iface,