Skip to content

Commit

Permalink
vkd3d: Just use DIRECT queue for sparse inits when we have plenty.
Browse files Browse the repository at this point in the history
Games rarely use more than 1 DIRECT queue anyway, but compute/copy can
be more strained.

Signed-off-by: Hans-Kristian Arntzen <[email protected]>
  • Loading branch information
HansKristian-Work committed Jan 3, 2025
1 parent ceb53e9 commit ec4d059
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions libs/vkd3d/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit ec4d059

Please sign in to comment.