vkd3d: Simplify checking if a descriptor has a view.

Saves a few CPU cycles on a potentially very hot code path.
Based on a vkd3d-proton patch by Philip Rebohle.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2021-12-09 01:00:20 +10:00 committed by Alexandre Julliard
parent 3816fa403f
commit 7d609770c4
2 changed files with 12 additions and 14 deletions

View File

@ -2130,9 +2130,7 @@ void d3d12_desc_write_atomic(struct d3d12_desc *dst, const struct d3d12_desc *sr
pthread_mutex_lock(mutex);
/* Nothing to do for VKD3D_DESCRIPTOR_MAGIC_CBV. */
if ((dst->magic == VKD3D_DESCRIPTOR_MAGIC_SRV
|| dst->magic == VKD3D_DESCRIPTOR_MAGIC_UAV
|| dst->magic == VKD3D_DESCRIPTOR_MAGIC_SAMPLER)
if ((dst->magic & VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW)
&& !InterlockedDecrement(&dst->u.view->refcount))
destroy_desc = *dst;
@ -2165,12 +2163,8 @@ void d3d12_desc_copy(struct d3d12_desc *dst, const struct d3d12_desc *src,
mutex = d3d12_device_get_descriptor_mutex(device, src);
pthread_mutex_lock(mutex);
if (src->magic == VKD3D_DESCRIPTOR_MAGIC_SRV
|| src->magic == VKD3D_DESCRIPTOR_MAGIC_UAV
|| src->magic == VKD3D_DESCRIPTOR_MAGIC_SAMPLER)
{
if (src->magic & VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW)
vkd3d_view_incref(src->u.view);
}
tmp = *src;

View File

@ -41,13 +41,17 @@
#define VK_CALL(f) (vk_procs->f)
#define MAKE_MAGIC(a,b,c,f) (((uint32_t)a) | (((uint32_t)b) << 8) | (((uint32_t)c) << 16) | f)
#define VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW 0x01000000u
#define VKD3D_DESCRIPTOR_MAGIC_FREE 0x00000000u
#define VKD3D_DESCRIPTOR_MAGIC_CBV 0x00564243u
#define VKD3D_DESCRIPTOR_MAGIC_SRV 0x00565253u
#define VKD3D_DESCRIPTOR_MAGIC_UAV 0x00564155u
#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER 0x504d4153u
#define VKD3D_DESCRIPTOR_MAGIC_DSV 0x00565344u
#define VKD3D_DESCRIPTOR_MAGIC_RTV 0x00565452u
#define VKD3D_DESCRIPTOR_MAGIC_CBV MAKE_MAGIC('C', 'B', 'V', 0)
#define VKD3D_DESCRIPTOR_MAGIC_SRV MAKE_MAGIC('S', 'R', 'V', VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW)
#define VKD3D_DESCRIPTOR_MAGIC_UAV MAKE_MAGIC('U', 'A', 'V', VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW)
#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER MAKE_MAGIC('S', 'M', 'P', VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW)
#define VKD3D_DESCRIPTOR_MAGIC_DSV MAKE_MAGIC('D', 'S', 'V', 0)
#define VKD3D_DESCRIPTOR_MAGIC_RTV MAKE_MAGIC('R', 'T', 'V', 0)
#define VKD3D_MAX_COMPATIBLE_FORMAT_COUNT 6u
#define VKD3D_MAX_QUEUE_FAMILY_COUNT 3u