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

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-02-10 19:02:34 -06:00 committed by Alexandre Julliard
parent d53f9d5f88
commit f30d3ac214
2 changed files with 17 additions and 6 deletions

View File

@ -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);

View File

@ -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