mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavfi/vulkan: add mutliqueue emulation code
This helps with testing multiple queues when the hardware only has a single queue.
This commit is contained in:
parent
8f9888a8d4
commit
8af7bcb6c3
@ -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;
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user