From ec4d059d8fb68f935ec174a84f037bd4b09b873c Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Fri, 3 Jan 2025 16:26:25 +0100 Subject: [PATCH] vkd3d: Just use DIRECT queue for sparse inits when we have plenty. Games rarely use more than 1 DIRECT queue anyway, but compute/copy can be more strained. Signed-off-by: Hans-Kristian Arntzen --- libs/vkd3d/device.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 62b1581aec..7c4f01f79c 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -2929,6 +2929,13 @@ static HRESULT vkd3d_select_queues(const struct d3d12_device *device, info->family_index[VKD3D_QUEUE_FAMILY_GRAPHICS] = vkd3d_find_queue(count, queue_properties, VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT, VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT); + if (info->family_index[VKD3D_QUEUE_FAMILY_GRAPHICS] == VK_QUEUE_FAMILY_IGNORED) + { + ERR("Could not find a suitable queue family for a direct command queue.\n"); + vkd3d_free(queue_properties); + return E_FAIL; + } + info->family_index[VKD3D_QUEUE_FAMILY_COMPUTE] = vkd3d_find_queue(count, queue_properties, VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT, VK_QUEUE_COMPUTE_BIT); @@ -2938,10 +2945,23 @@ static HRESULT vkd3d_select_queues(const struct d3d12_device *device, VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT, VK_QUEUE_SPARSE_BINDING_BIT); - /* Try to find a queue family that isn't graphics. */ if (info->family_index[VKD3D_QUEUE_FAMILY_SPARSE_BINDING] == VK_QUEUE_FAMILY_IGNORED) - info->family_index[VKD3D_QUEUE_FAMILY_SPARSE_BINDING] = vkd3d_find_queue(count, queue_properties, - VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_BINDING_BIT, VK_QUEUE_SPARSE_BINDING_BIT); + { + if (queue_properties[info->family_index[VKD3D_QUEUE_FAMILY_GRAPHICS]].queueCount >= + VKD3D_MAX_QUEUE_COUNT_PER_FAMILY) + { + /* If the graphics queue has a lot of queues available, just use that. Async compute/copy may be more strained. */ + info->family_index[VKD3D_QUEUE_FAMILY_SPARSE_BINDING] = vkd3d_find_queue(count, queue_properties, + VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_BINDING_BIT, + VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_BINDING_BIT); + } + else + { + /* Try to find a queue family that isn't graphics. */ + info->family_index[VKD3D_QUEUE_FAMILY_SPARSE_BINDING] = vkd3d_find_queue(count, queue_properties, + VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_BINDING_BIT, VK_QUEUE_SPARSE_BINDING_BIT); + } + } /* Last resort, pick any queue family that supports sparse. */ if (info->family_index[VKD3D_QUEUE_FAMILY_SPARSE_BINDING] == VK_QUEUE_FAMILY_IGNORED) @@ -3011,12 +3031,6 @@ static HRESULT vkd3d_select_queues(const struct d3d12_device *device, vkd3d_free(queue_properties); - if (info->family_index[VKD3D_QUEUE_FAMILY_GRAPHICS] == VK_QUEUE_FAMILY_IGNORED) - { - ERR("Could not find a suitable queue family for a direct command queue.\n"); - return E_FAIL; - } - return S_OK; }