[PATCH v2 6/9] d3dx10: Add ID3DX10ThreadPump:WaitForAllItems implementation.

Piotr Caban wine at gitlab.winehq.org
Sat Jun 18 14:17:26 CDT 2022


From: Piotr Caban <piotr at codeweavers.com>

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
---
 dlls/d3dx10_43/d3dx10_43_main.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/dlls/d3dx10_43/d3dx10_43_main.c b/dlls/d3dx10_43/d3dx10_43_main.c
index 795d052af83..198cf14b7d0 100644
--- a/dlls/d3dx10_43/d3dx10_43_main.c
+++ b/dlls/d3dx10_43/d3dx10_43_main.c
@@ -350,8 +350,24 @@ static UINT WINAPI thread_pump_GetWorkItemCount(ID3DX10ThreadPump *iface)
 
 static HRESULT WINAPI thread_pump_WaitForAllItems(ID3DX10ThreadPump *iface)
 {
-    FIXME("iface %p stub!\n", iface);
-    return E_NOTIMPL;
+    struct thread_pump *thread_pump = impl_from_ID3DX10ThreadPump(iface);
+    HRESULT hr;
+    LONG v;
+
+    TRACE("iface %p.\n", iface);
+
+    while(1)
+    {
+        if (FAILED((hr = ID3DX10ThreadPump_ProcessDeviceWorkItems(iface, UINT_MAX))))
+            return hr;
+
+        if (!(v = thread_pump->processing_count))
+            break;
+
+        RtlWaitOnAddress((void *)&thread_pump->processing_count, &v, sizeof(v), NULL);
+    }
+
+    return ID3DX10ThreadPump_ProcessDeviceWorkItems(iface, UINT_MAX);
 }
 
 static HRESULT WINAPI thread_pump_ProcessDeviceWorkItems(ID3DX10ThreadPump *iface, UINT count)
@@ -447,7 +463,8 @@ static DWORD WINAPI io_thread(void *arg)
             if (work_item->result)
                 *work_item->result = hr;
             work_item_free(work_item, FALSE);
-            InterlockedDecrement(&thread_pump->processing_count);
+            if (!InterlockedDecrement(&thread_pump->processing_count))
+                RtlWakeAddressAll((void *)&thread_pump->processing_count);
             continue;
         }
 
@@ -503,7 +520,8 @@ static DWORD WINAPI proc_thread(void *arg)
             if (work_item->result)
                 *work_item->result = hr;
             work_item_free(work_item, FALSE);
-            InterlockedDecrement(&thread_pump->processing_count);
+            if (!InterlockedDecrement(&thread_pump->processing_count))
+                RtlWakeAddressAll((void *)&thread_pump->processing_count);
             continue;
         }
 
@@ -518,7 +536,8 @@ static DWORD WINAPI proc_thread(void *arg)
             if (work_item->result)
                 *work_item->result = hr;
             work_item_free(work_item, FALSE);
-            InterlockedDecrement(&thread_pump->processing_count);
+            if (!InterlockedDecrement(&thread_pump->processing_count))
+                RtlWakeAddressAll((void *)&thread_pump->processing_count);
             continue;
         }
 
@@ -533,6 +552,7 @@ static DWORD WINAPI proc_thread(void *arg)
         list_add_tail(&thread_pump->device_queue, &work_item->entry);
         thread_pump->device_count++;
         InterlockedDecrement(&thread_pump->processing_count);
+        RtlWakeAddressAll((void *)&thread_pump->processing_count);
         ReleaseSRWLockExclusive(&thread_pump->device_lock);
     }
     return 0;
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/272



More information about the wine-devel mailing list