Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- 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 c2e71342bb0..f09cd1b0fae 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -521,9 +521,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;
@@ -543,9 +541,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 adf1a15926f..807a002b1f1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -5659,6 +5659,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