aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2024-07-10 01:52:42 +0200
committerLynne <dev@lynne.ee>2024-08-11 05:13:09 +0200
commitbedfabc4373d1cf84e75107c42a56657f2c26520 (patch)
tree3f244ab27529b4a210d5485ab25fa94a76ce4b56
parent13489c8a2154a2e0e8fd3c3c45f7856b4c3110b0 (diff)
downloadffmpeg-bedfabc4373d1cf84e75107c42a56657f2c26520.tar.gz
vulkan: use the new queue family mechanism
-rw-r--r--libavutil/vulkan.c68
-rw-r--r--libavutil/vulkan.h2
2 files changed, 21 insertions, 49 deletions
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 11c17ee6f3..cec8354ba6 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -189,37 +189,14 @@ int ff_vk_load_props(FFVulkanContext *s)
static int vk_qf_get_index(FFVulkanContext *s, VkQueueFlagBits dev_family, int *nb)
{
- int ret, num;
-
- switch (dev_family) {
- case VK_QUEUE_GRAPHICS_BIT:
- ret = s->hwctx->queue_family_index;
- num = s->hwctx->nb_graphics_queues;
- break;
- case VK_QUEUE_COMPUTE_BIT:
- ret = s->hwctx->queue_family_comp_index;
- num = s->hwctx->nb_comp_queues;
- break;
- case VK_QUEUE_TRANSFER_BIT:
- ret = s->hwctx->queue_family_tx_index;
- num = s->hwctx->nb_tx_queues;
- break;
- case VK_QUEUE_VIDEO_ENCODE_BIT_KHR:
- ret = s->hwctx->queue_family_encode_index;
- num = s->hwctx->nb_encode_queues;
- break;
- case VK_QUEUE_VIDEO_DECODE_BIT_KHR:
- ret = s->hwctx->queue_family_decode_index;
- num = s->hwctx->nb_decode_queues;
- break;
- default:
- av_assert0(0); /* Should never happen */
+ for (int i = 0; i < s->hwctx->nb_qf; i++) {
+ if (s->hwctx->qf[i].flags & dev_family) {
+ *nb = s->hwctx->qf[i].num;
+ return s->hwctx->qf[i].idx;
+ }
}
- if (nb)
- *nb = num;
-
- return ret;
+ av_assert0(0); /* Should never happen */
}
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
@@ -229,25 +206,20 @@ int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
if (!s->nb_qfs) {
s->nb_qfs = 0;
- /* Simply fills in all unique queues into s->qfs */
- if (s->hwctx->queue_family_index >= 0)
- s->qfs[s->nb_qfs++] = s->hwctx->queue_family_index;
- if (!s->nb_qfs || s->qfs[0] != s->hwctx->queue_family_tx_index)
- s->qfs[s->nb_qfs++] = s->hwctx->queue_family_tx_index;
- if (!s->nb_qfs || (s->qfs[0] != s->hwctx->queue_family_comp_index &&
- s->qfs[1] != s->hwctx->queue_family_comp_index))
- s->qfs[s->nb_qfs++] = s->hwctx->queue_family_comp_index;
- if (s->hwctx->queue_family_decode_index >= 0 &&
- (s->qfs[0] != s->hwctx->queue_family_decode_index &&
- s->qfs[1] != s->hwctx->queue_family_decode_index &&
- s->qfs[2] != s->hwctx->queue_family_decode_index))
- s->qfs[s->nb_qfs++] = s->hwctx->queue_family_decode_index;
- if (s->hwctx->queue_family_encode_index >= 0 &&
- (s->qfs[0] != s->hwctx->queue_family_encode_index &&
- s->qfs[1] != s->hwctx->queue_family_encode_index &&
- s->qfs[2] != s->hwctx->queue_family_encode_index &&
- s->qfs[3] != s->hwctx->queue_family_encode_index))
- s->qfs[s->nb_qfs++] = s->hwctx->queue_family_encode_index;
+ 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));
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 81898841ad..4b4705a25e 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -258,7 +258,7 @@ typedef struct FFVulkanContext {
AVHWFramesContext *frames;
AVVulkanFramesContext *hwfc;
- uint32_t qfs[5];
+ uint32_t qfs[64];
int nb_qfs;
/* Properties */