Piotr Caban : d3dx10: Add ID3DX10ThreadPump:PurgeAllItems implementation.

Alexandre Julliard julliard at winehq.org
Mon Jul 4 16:42:26 CDT 2022


Module: wine
Branch: master
Commit: a63f7b1c815123770b7e3c9a3faa0d7ddc61c66c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a63f7b1c815123770b7e3c9a3faa0d7ddc61c66c

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue Jun 14 21:02:53 2022 +0200

d3dx10: Add ID3DX10ThreadPump:PurgeAllItems implementation.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>

---

 dlls/d3dx10_43/async.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c
index 8fc232681c5..667219b3500 100644
--- a/dlls/d3dx10_43/async.c
+++ b/dlls/d3dx10_43/async.c
@@ -845,10 +845,52 @@ static HRESULT WINAPI thread_pump_ProcessDeviceWorkItems(ID3DX10ThreadPump *ifac
     return S_OK;
 }
 
+static void purge_list(struct list *list, LONG *count)
+{
+    struct work_item *work_item;
+
+    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 (count && !InterlockedDecrement(count))
+            RtlWakeAddressAll(count);
+    }
+}
+
 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);
+    LONG v;
+
+    TRACE("iface %p.\n", iface);
+
+    for (;;)
+    {
+        AcquireSRWLockExclusive(&thread_pump->io_lock);
+        purge_list(&thread_pump->io_queue, &thread_pump->processing_count);
+        thread_pump->io_count = 0;
+        ReleaseSRWLockExclusive(&thread_pump->io_lock);
+
+        AcquireSRWLockExclusive(&thread_pump->proc_lock);
+        purge_list(&thread_pump->proc_queue, &thread_pump->processing_count);
+        thread_pump->proc_count = 0;
+        ReleaseSRWLockExclusive(&thread_pump->proc_lock);
+
+        AcquireSRWLockExclusive(&thread_pump->device_lock);
+        purge_list(&thread_pump->device_queue, NULL);
+        thread_pump->device_count = 0;
+        v = thread_pump->processing_count;
+        ReleaseSRWLockExclusive(&thread_pump->device_lock);
+        if (!v)
+            break;
+
+        RtlWaitOnAddress(&thread_pump->processing_count, &v, sizeof(v), NULL);
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI thread_pump_GetQueueStatus(ID3DX10ThreadPump *iface,




More information about the wine-cvs mailing list