From e8fce74abfd1aa4ad13f4daf103e7f71954459ba Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 23 Nov 2022 13:03:58 +0100 Subject: [PATCH] vulkan: add ff_vk_qf_fill() --- libavutil/vulkan.c | 25 +++++++++++++++++++++++++ libavutil/vulkan.h | 9 +++++++++ 2 files changed, 34 insertions(+) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index ae6adc5104..eceef295a8 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -108,6 +108,31 @@ const char *ff_vk_ret2str(VkResult res) #undef CASE } +void ff_vk_qf_fill(FFVulkanContext *s) +{ + 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; +} + void ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family, int nb_queues) { diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index c6cfb779fc..4540c3eda1 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -207,6 +207,9 @@ typedef struct FFVulkanContext { AVHWFramesContext *frames; AVVulkanFramesContext *hwfc; + uint32_t qfs[5]; + int nb_qfs; + FFVkSPIRVCompiler *spirv_compiler; /* Properties */ @@ -249,6 +252,12 @@ int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt); */ const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt); +/** + * Setup the queue families from the hardware device context. + * Necessary for image creation to work. + */ +void ff_vk_qf_fill(FFVulkanContext *s); + /** * Initialize a queue family with a specific number of queues. * If nb_queues == 0, use however many queues the queue family has.