summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavfilter/vulkan.c33
-rw-r--r--libavfilter/vulkan.h7
2 files changed, 22 insertions, 18 deletions
diff --git a/libavfilter/vulkan.c b/libavfilter/vulkan.c
index 5258e0c3d6..3bb4eea7a1 100644
--- a/libavfilter/vulkan.c
+++ b/libavfilter/vulkan.c
@@ -90,38 +90,40 @@ const char *ff_vk_ret2str(VkResult res)
}
void ff_vk_qf_init(AVFilterContext *avctx, FFVkQueueFamilyCtx *qf,
- VkQueueFlagBits dev_family, int queue_limit)
+ VkQueueFlagBits dev_family, int nb_queues)
{
FFVulkanContext *s = avctx->priv;
- if (!queue_limit)
- queue_limit = INT32_MAX;
-
switch (dev_family) {
case VK_QUEUE_GRAPHICS_BIT:
qf->queue_family = s->hwctx->queue_family_index;
- qf->nb_queues = FFMIN(s->hwctx->nb_graphics_queues, queue_limit);
- return;
+ qf->actual_queues = s->hwctx->nb_graphics_queues;
+ break;
case VK_QUEUE_COMPUTE_BIT:
qf->queue_family = s->hwctx->queue_family_comp_index;
- qf->nb_queues = FFMIN(s->hwctx->nb_comp_queues, queue_limit);
- return;
+ qf->actual_queues = s->hwctx->nb_comp_queues;
+ break;
case VK_QUEUE_TRANSFER_BIT:
qf->queue_family = s->hwctx->queue_family_tx_index;
- qf->nb_queues = FFMIN(s->hwctx->nb_tx_queues, queue_limit);
- return;
+ qf->actual_queues = s->hwctx->nb_tx_queues;
+ break;
case VK_QUEUE_VIDEO_ENCODE_BIT_KHR:
qf->queue_family = s->hwctx->queue_family_encode_index;
- qf->nb_queues = FFMIN(s->hwctx->nb_encode_queues, queue_limit);
- return;
+ qf->actual_queues = s->hwctx->nb_encode_queues;
+ break;
case VK_QUEUE_VIDEO_DECODE_BIT_KHR:
qf->queue_family = s->hwctx->queue_family_decode_index;
- qf->nb_queues = FFMIN(s->hwctx->nb_decode_queues, queue_limit);
- return;
+ qf->actual_queues = s->hwctx->nb_decode_queues;
+ break;
default:
av_assert0(0); /* Should never happen */
}
+ if (qf->actual_queues)
+ qf->nb_queues = qf->actual_queues;
+ else
+ qf->nb_queues = nb_queues;
+
return;
}
@@ -435,7 +437,8 @@ int ff_vk_create_exec_ctx(AVFilterContext *avctx, FFVkExecContext **ctx,
for (int i = 0; i < qf->nb_queues; i++) {
FFVkQueueCtx *q = &e->queues[i];
- vk->GetDeviceQueue(s->hwctx->act_dev, qf->queue_family, i, &q->queue);
+ vk->GetDeviceQueue(s->hwctx->act_dev, qf->queue_family,
+ i % qf->actual_queues, &q->queue);
}
*ctx = e;
diff --git a/libavfilter/vulkan.h b/libavfilter/vulkan.h
index df8abf9e30..df0e830af8 100644
--- a/libavfilter/vulkan.h
+++ b/libavfilter/vulkan.h
@@ -87,6 +87,7 @@ typedef struct FFVkQueueFamilyCtx {
int queue_family;
int nb_queues;
int cur_queue;
+ int actual_queues;
} FFVkQueueFamilyCtx;
typedef struct FFVulkanPipeline {
@@ -235,11 +236,11 @@ int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt);
const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt);
/**
- * Initialize a queue family.
- * A queue limit of 0 means no limit.
+ * Initialize a queue family with a specific number of queues.
+ * If nb_queues == 0, use however many queues the queue family has.
*/
void ff_vk_qf_init(AVFilterContext *avctx, FFVkQueueFamilyCtx *qf,
- VkQueueFlagBits dev_family, int queue_limit);
+ VkQueueFlagBits dev_family, int nb_queues);
/**
* Rotate through the queues in a queue family.