summaryrefslogtreecommitdiff
path: root/libavfilter/vf_overlay_vulkan.c
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2021-11-10 03:50:54 +0100
committerLynne <dev@lynne.ee>2021-11-12 05:23:41 +0100
commitf705e9ea0567c8dcf800ae1ee0647fca157c6199 (patch)
tree529e20c9015f3ee93e297097d77f38ba52c29037 /libavfilter/vf_overlay_vulkan.c
parent246f841b53e16f2cccf3101cb61c264014f54e5c (diff)
lavfi/vulkan: refactor, fix and fully implement multiple queues
Diffstat (limited to 'libavfilter/vf_overlay_vulkan.c')
-rw-r--r--libavfilter/vf_overlay_vulkan.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/libavfilter/vf_overlay_vulkan.c b/libavfilter/vf_overlay_vulkan.c
index f08800af2c..b902ad83f5 100644
--- a/libavfilter/vf_overlay_vulkan.c
+++ b/libavfilter/vf_overlay_vulkan.c
@@ -25,11 +25,12 @@
#define CGROUPS (int [3]){ 32, 32, 1 }
typedef struct OverlayVulkanContext {
- VulkanFilterContext vkctx;
+ FFVulkanContext vkctx;
int initialized;
- VulkanPipeline *pl;
+ FFVkQueueFamilyCtx qf;
FFVkExecContext *exec;
+ FFVulkanPipeline *pl;
FFFrameSync fs;
FFVkBuffer params_buf;
@@ -79,23 +80,24 @@ static const char overlay_alpha[] = {
static av_cold int init_filter(AVFilterContext *ctx)
{
int err;
+ FFVkSampler *sampler;
OverlayVulkanContext *s = ctx->priv;
- VkSampler *sampler = ff_vk_init_sampler(ctx, 1, VK_FILTER_NEAREST);
+ const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
+
+ ff_vk_qf_init(ctx, &s->qf, VK_QUEUE_COMPUTE_BIT, 0);
+
+ sampler = ff_vk_init_sampler(ctx, 1, VK_FILTER_NEAREST);
if (!sampler)
return AVERROR_EXTERNAL;
- s->pl = ff_vk_create_pipeline(ctx);
+ s->pl = ff_vk_create_pipeline(ctx, &s->qf);
if (!s->pl)
return AVERROR(ENOMEM);
- s->vkctx.queue_family_idx = s->vkctx.hwctx->queue_family_comp_index;
- s->vkctx.queue_count = s->vkctx.hwctx->nb_comp_queues;
-
{ /* Create the shader */
- const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
const int ialpha = av_pix_fmt_desc_get(s->vkctx.input_format)->flags & AV_PIX_FMT_FLAG_ALPHA;
- VulkanDescriptorSetBinding desc_i[3] = {
+ FFVulkanDescriptorSetBinding desc_i[3] = {
{
.name = "main_img",
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
@@ -103,7 +105,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
.elems = planes,
.stages = VK_SHADER_STAGE_COMPUTE_BIT,
.updater = s->main_images,
- .samplers = DUP_SAMPLER_ARRAY4(*sampler),
+ .sampler = sampler,
},
{
.name = "overlay_img",
@@ -112,7 +114,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
.elems = planes,
.stages = VK_SHADER_STAGE_COMPUTE_BIT,
.updater = s->overlay_images,
- .samplers = DUP_SAMPLER_ARRAY4(*sampler),
+ .sampler = sampler,
},
{
.name = "output_img",
@@ -126,7 +128,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
},
};
- VulkanDescriptorSetBinding desc_b = {
+ FFVulkanDescriptorSetBinding desc_b = {
.name = "params",
.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.mem_quali = "readonly",
@@ -215,7 +217,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
}
/* Execution context */
- RET(ff_vk_create_exec_ctx(ctx, &s->exec));
+ RET(ff_vk_create_exec_ctx(ctx, &s->exec, &s->qf));
s->initialized = 1;
@@ -339,6 +341,8 @@ static int process_frames(AVFilterContext *avctx, AVFrame *out_f,
if (err)
return err;
+ ff_vk_qf_rotate(&s->qf);
+
return err;
fail: