vulkan: load queue families upon loading properties

Avoids the need to call ff_vk_qf_init if manually filling in
a queue family structure.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Lynne 2024-08-10 21:51:32 +02:00 committed by Paul B Mahol
parent d3bd090e0d
commit 90c4647828

View File

@ -83,6 +83,25 @@ const char *ff_vk_ret2str(VkResult res)
#undef CASE #undef CASE
} }
static void load_enabled_qfs(FFVulkanContext *s)
{
s->nb_qfs = 0;
for (int i = 0; i < s->hwctx->nb_qf; i++) {
/* Skip duplicates */
int skip = 0;
for (int j = 0; j < s->nb_qfs; j++) {
if (s->qfs[j] == s->hwctx->qf[i].idx) {
skip = 1;
break;
}
}
if (skip)
continue;
s->qfs[s->nb_qfs++] = s->hwctx->qf[i].idx;
}
}
int ff_vk_load_props(FFVulkanContext *s) int ff_vk_load_props(FFVulkanContext *s)
{ {
FFVulkanFunctions *vk = &s->vkfn; FFVulkanFunctions *vk = &s->vkfn;
@ -131,6 +150,8 @@ int ff_vk_load_props(FFVulkanContext *s)
vk->GetPhysicalDeviceMemoryProperties(s->hwctx->phys_dev, &s->mprops); vk->GetPhysicalDeviceMemoryProperties(s->hwctx->phys_dev, &s->mprops);
vk->GetPhysicalDeviceFeatures2(s->hwctx->phys_dev, &s->feats); vk->GetPhysicalDeviceFeatures2(s->hwctx->phys_dev, &s->feats);
load_enabled_qfs(s);
if (s->qf_props) if (s->qf_props)
return 0; return 0;
@ -207,24 +228,8 @@ int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
VkQueueFlagBits dev_family) VkQueueFlagBits dev_family)
{ {
/* Fill in queue families from context if not done yet */ /* Fill in queue families from context if not done yet */
if (!s->nb_qfs) { if (!s->nb_qfs)
s->nb_qfs = 0; load_enabled_qfs(s);
for (int i = 0; i < s->hwctx->nb_qf; i++) {
/* Skip duplicates */
int skip = 0;
for (int j = 0; j < s->nb_qfs; j++) {
if (s->qfs[j] == s->hwctx->qf[i].idx) {
skip = 1;
break;
}
}
if (skip)
continue;
s->qfs[s->nb_qfs++] = s->hwctx->qf[i].idx;
}
}
return (qf->queue_family = vk_qf_get_index(s, dev_family, &qf->nb_queues)); return (qf->queue_family = vk_qf_get_index(s, dev_family, &qf->nb_queues));
} }