Zebediah Figura : wined3d: Introduce wined3d_lock_init() and wined3d_lock_cleanup() helpers.

Alexandre Julliard julliard at winehq.org
Fri Feb 11 14:33:58 CST 2022


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Thu Feb 10 19:02:34 2022 -0600

wined3d: Introduce wined3d_lock_init() and wined3d_lock_cleanup() helpers.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/adapter_vk.c      |  8 ++------
 dlls/wined3d/wined3d_private.h | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index 343abac1004..8e149de028f 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -518,9 +518,7 @@ static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wi
         goto fail;
     }
 
-    InitializeCriticalSection(&device_vk->allocator_cs);
-    if (device_vk->allocator_cs.DebugInfo != (RTL_CRITICAL_SECTION_DEBUG *)-1)
-        device_vk->allocator_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": wined3d_device_vk.allocator_cs");
+    wined3d_lock_init(&device_vk->allocator_cs, "wined3d_device_vk.allocator_cs");
 
     *device = &device_vk->d;
 
@@ -540,9 +538,7 @@ static void adapter_vk_destroy_device(struct wined3d_device *device)
     wined3d_device_cleanup(&device_vk->d);
     wined3d_allocator_cleanup(&device_vk->allocator);
 
-    if (device_vk->allocator_cs.DebugInfo != (RTL_CRITICAL_SECTION_DEBUG *)-1)
-        device_vk->allocator_cs.DebugInfo->Spare[0] = 0;
-    DeleteCriticalSection(&device_vk->allocator_cs);
+    wined3d_lock_cleanup(&device_vk->allocator_cs);
 
     VK_CALL(vkDestroyDevice(device_vk->vk_device, NULL));
     heap_free(device_vk);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ef1062ec9b4..88c2f5ba285 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -5650,6 +5650,21 @@ struct wined3d_shader_limits
     unsigned int packed_input;
 };
 
+#define wined3d_lock_init(lock, name) wined3d_lock_init_(lock, __FILE__ ": " name)
+static inline void wined3d_lock_init_(CRITICAL_SECTION *lock, const char *name)
+{
+    InitializeCriticalSection(lock);
+    if (lock->DebugInfo != (RTL_CRITICAL_SECTION_DEBUG *)-1)
+        lock->DebugInfo->Spare[0] = (DWORD_PTR)name;
+}
+
+static inline void wined3d_lock_cleanup(CRITICAL_SECTION *lock)
+{
+    if (lock->DebugInfo != (RTL_CRITICAL_SECTION_DEBUG *)-1)
+        lock->DebugInfo->Spare[0] = 0;
+    DeleteCriticalSection(lock);
+}
+
 #ifdef __GNUC__
 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
 #else




More information about the wine-cvs mailing list