1
0
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:
Lynne 2021-11-16 10:28:27 +01:00
parent 8f9888a8d4
commit 8af7bcb6c3
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
2 changed files with 22 additions and 18 deletions

View File

@ -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;

View File

@ -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.