History

vulkan: do not reinvent a queue context struct

We recently introduced a public field which was a superset of the queue context we used to have. Switch to using it entirely. This also allows us to get rid of the NIH function which was valid only for video queues.

Lynne committed 1 year ago

Commit 2e06b841 parent 157cd8222 files · +157 −123Browse files

Showing the changes to libavfilter (12 of 22 files). Show all

Unified · Split

12 files
  1. libavfilter/vf_avgblur_vulkan.c +9 −3
  2. libavfilter/vf_blend_vulkan.c +9 −3
  3. libavfilter/vf_bwdif_vulkan.c +9 −3
  4. libavfilter/vf_chromaber_vulkan.c +9 −3
  5. libavfilter/vf_flip_vulkan.c +9 −3
  6. libavfilter/vf_gblur_vulkan.c +9 −3
  7. libavfilter/vf_nlmeans_vulkan.c +9 −3
  8. libavfilter/vf_overlay_vulkan.c +9 −3
  9. libavfilter/vf_scale_vulkan.c +9 −3
  10. libavfilter/vf_transpose_vulkan.c +9 −3
  11. libavfilter/vf_xfade_vulkan.c +9 −3
  12. libavfilter/vsrc_testsrc_vulkan.c +9 −3
libavfilter/vf_avgblur_vulkan.c+9−3
@@ -31,7 +31,7 @@ typedef struct AvgBlurVulkanContext { · 30 unmodified lines
3131
3232 int initialized;
3333 FFVkExecPool e;
34− FFVkQueueFamilyCtx qf;
34+ AVVulkanDeviceQueueFamily *qf;
3535 VkSampler sampler;
3636 FFVulkanShader shd;
3737
@@ -77,8 +77,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 39 unmodified lines
7777 return AVERROR_EXTERNAL;
7878 }
7979
80− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
81− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
80+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
81+ if (!s->qf) {
82+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
83+ err = AVERROR(ENOTSUP);
84+ goto fail;
85+ }
86+
87+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
8288 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
8389 RET(ff_vk_shader_init(vkctx, &s->shd, "avgblur",
8490 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vf_blend_vulkan.c+9−3
@@ -47,7 +47,7 @@ typedef struct BlendVulkanContext { · 46 unmodified lines
4747
4848 int initialized;
4949 FFVkExecPool e;
50− FFVkQueueFamilyCtx qf;
50+ AVVulkanDeviceQueueFamily *qf;
5151 FFVulkanShader shd;
5252 VkSampler sampler;
5353
@@ -141,8 +141,14 @@ static av_cold int init_filter(AVFilterContext *avctx) · 87 unmodified lines
141141 return AVERROR_EXTERNAL;
142142 }
143143
144− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
145− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
144+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
145+ if (!s->qf) {
146+ av_log(avctx, AV_LOG_ERROR, "Device has no compute queues\n");
147+ err = AVERROR(ENOTSUP);
148+ goto fail;
149+ }
150+
151+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
146152 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
147153 RET(ff_vk_shader_init(vkctx, &s->shd, "blend",
148154 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vf_bwdif_vulkan.c+9−3
@@ -33,7 +33,7 @@ typedef struct BWDIFVulkanContext { · 32 unmodified lines
3333
3434 int initialized;
3535 FFVkExecPool e;
36− FFVkQueueFamilyCtx qf;
36+ AVVulkanDeviceQueueFamily *qf;
3737 VkSampler sampler;
3838 FFVulkanShader shd;
3939 } BWDIFVulkanContext;
@@ -65,8 +65,14 @@ static av_cold int init_filter(AVFilterContext *ctx) · 25 unmodified lines
6565 return AVERROR_EXTERNAL;
6666 }
6767
68− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
69− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
68+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
69+ if (!s->qf) {
70+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
71+ err = AVERROR(ENOTSUP);
72+ goto fail;
73+ }
74+
75+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
7076 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
7177
7278 RET(ff_vk_shader_init(vkctx, &s->shd, "bwdif",
libavfilter/vf_chromaber_vulkan.c+9−3
@@ -31,7 +31,7 @@ typedef struct ChromaticAberrationVulkanContext { · 30 unmodified lines
3131
3232 int initialized;
3333 FFVkExecPool e;
34− FFVkQueueFamilyCtx qf;
34+ AVVulkanDeviceQueueFamily *qf;
3535 FFVulkanShader shd;
3636 VkSampler sampler;
3737
@@ -88,8 +88,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 50 unmodified lines
8888 return AVERROR_EXTERNAL;
8989 }
9090
91− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
92− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
91+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
92+ if (!s->qf) {
93+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
94+ err = AVERROR(ENOTSUP);
95+ goto fail;
96+ }
97+
98+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
9399 RET(ff_vk_init_sampler(vkctx, &s->sampler, 0, VK_FILTER_LINEAR));
94100 RET(ff_vk_shader_init(vkctx, &s->shd, "chromatic_abberation",
95101 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vf_flip_vulkan.c+9−3
@@ -38,7 +38,7 @@ typedef struct FlipVulkanContext { · 37 unmodified lines
3838
3939 int initialized;
4040 FFVkExecPool e;
41− FFVkQueueFamilyCtx qf;
41+ AVVulkanDeviceQueueFamily *qf;
4242 FFVulkanShader shd;
4343 VkSampler sampler;
4444 } FlipVulkanContext;
@@ -62,8 +62,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType · 17 unmodified lines
6262 return AVERROR_EXTERNAL;
6363 }
6464
65− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
66− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
65+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
66+ if (!s->qf) {
67+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
68+ err = AVERROR(ENOTSUP);
69+ goto fail;
70+ }
71+
72+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
6773 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
6874 RET(ff_vk_shader_init(vkctx, &s->shd, "flip",
6975 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vf_gblur_vulkan.c+9−3
@@ -36,7 +36,7 @@ typedef struct GBlurVulkanContext { · 35 unmodified lines
3636
3737 int initialized;
3838 FFVkExecPool e;
39− FFVkQueueFamilyCtx qf;
39+ AVVulkanDeviceQueueFamily *qf;
4040 VkSampler sampler;
4141 FFVulkanShader shd_hor;
4242 FFVkBuffer params_hor;
@@ -212,8 +212,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 169 unmodified lines
212212 return AVERROR_EXTERNAL;
213213 }
214214
215− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
216− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
215+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
216+ if (!s->qf) {
217+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
218+ err = AVERROR(ENOTSUP);
219+ goto fail;
220+ }
221+
222+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
217223 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
218224
219225 desc = (FFVulkanDescriptorSetBinding []) {
libavfilter/vf_nlmeans_vulkan.c+9−3
@@ -36,7 +36,7 @@ typedef struct NLMeansVulkanContext { · 35 unmodified lines
3636
3737 int initialized;
3838 FFVkExecPool e;
39− FFVkQueueFamilyCtx qf;
39+ AVVulkanDeviceQueueFamily *qf;
4040 VkSampler sampler;
4141
4242 AVBufferPool *integral_buf_pool;
@@ -652,8 +652,14 @@ static av_cold int init_filter(AVFilterContext *ctx) · 609 unmodified lines
652652 return AVERROR_EXTERNAL;
653653 }
654654
655− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
656− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, 1, 0, 0, 0, NULL));
655+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
656+ if (!s->qf) {
657+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
658+ err = AVERROR(ENOTSUP);
659+ goto fail;
660+ }
661+
662+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, 1, 0, 0, 0, NULL));
657663 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
658664
659665 RET(init_weights_pipeline(vkctx, &s->e, &s->shd_weights, s->sampler,
libavfilter/vf_overlay_vulkan.c+9−3
@@ -33,7 +33,7 @@ typedef struct OverlayVulkanContext { · 32 unmodified lines
3333
3434 int initialized;
3535 FFVkExecPool e;
36− FFVkQueueFamilyCtx qf;
36+ AVVulkanDeviceQueueFamily *qf;
3737 FFVulkanShader shd;
3838 VkSampler sampler;
3939
@@ -101,8 +101,14 @@ static av_cold int init_filter(AVFilterContext *ctx) · 61 unmodified lines
101101 return AVERROR_EXTERNAL;
102102 }
103103
104− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
105− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
104+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
105+ if (!s->qf) {
106+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
107+ err = AVERROR(ENOTSUP);
108+ goto fail;
109+ }
110+
111+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
106112 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
107113 RET(ff_vk_shader_init(vkctx, &s->shd, "overlay",
108114 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vf_scale_vulkan.c+9−3
@@ -39,7 +39,7 @@ typedef struct ScaleVulkanContext { · 38 unmodified lines
3939
4040 int initialized;
4141 FFVkExecPool e;
42− FFVkQueueFamilyCtx qf;
42+ AVVulkanDeviceQueueFamily *qf;
4343 FFVulkanShader shd;
4444 VkSampler sampler;
4545
@@ -142,8 +142,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 96 unmodified lines
142142 return AVERROR_EXTERNAL;
143143 }
144144
145− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
146− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
145+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
146+ if (!s->qf) {
147+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
148+ err = AVERROR(ENOTSUP);
149+ goto fail;
150+ }
151+
152+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
147153 RET(ff_vk_init_sampler(vkctx, &s->sampler, 0, sampler_mode));
148154 RET(ff_vk_shader_init(vkctx, &s->shd, "scale",
149155 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vf_transpose_vulkan.c+9−3
@@ -33,7 +33,7 @@ typedef struct TransposeVulkanContext { · 32 unmodified lines
3333
3434 int initialized;
3535 FFVkExecPool e;
36− FFVkQueueFamilyCtx qf;
36+ AVVulkanDeviceQueueFamily *qf;
3737 FFVulkanShader shd;
3838 VkSampler sampler;
3939
@@ -61,8 +61,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 21 unmodified lines
6161 return AVERROR_EXTERNAL;
6262 }
6363
64− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
65− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
64+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
65+ if (!s->qf) {
66+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
67+ err = AVERROR(ENOTSUP);
68+ goto fail;
69+ }
70+
71+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
6672 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
6773 RET(ff_vk_shader_init(vkctx, &s->shd, "transpose",
6874 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vf_xfade_vulkan.c+9−3
@@ -41,7 +41,7 @@ typedef struct XFadeVulkanContext { · 40 unmodified lines
4141
4242 int initialized;
4343 FFVkExecPool e;
44− FFVkQueueFamilyCtx qf;
44+ AVVulkanDeviceQueueFamily *qf;
4545 FFVulkanShader shd;
4646 VkSampler sampler;
4747
@@ -335,8 +335,14 @@ static av_cold int init_vulkan(AVFilterContext *avctx) · 287 unmodified lines
335335 return AVERROR_EXTERNAL;
336336 }
337337
338− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
339− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
338+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
339+ if (!s->qf) {
340+ av_log(avctx, AV_LOG_ERROR, "Device has no compute queues\n");
341+ err = AVERROR(ENOTSUP);
342+ goto fail;
343+ }
344+
345+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
340346 RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
341347 RET(ff_vk_shader_init(vkctx, &s->shd, "xfade",
342348 VK_SHADER_STAGE_COMPUTE_BIT,
libavfilter/vsrc_testsrc_vulkan.c+9−3
@@ -40,7 +40,7 @@ typedef struct TestSrcVulkanContext { · 39 unmodified lines
4040
4141 int initialized;
4242 FFVkExecPool e;
43− FFVkQueueFamilyCtx qf;
43+ AVVulkanDeviceQueueFamily *qf;
4444 FFVulkanShader shd;
4545
4646 /* Only used by color_vulkan */
@@ -82,8 +82,14 @@ static av_cold int init_filter(AVFilterContext *ctx, enum TestSrcVulkanMode mode · 35 unmodified lines
8282 return AVERROR_EXTERNAL;
8383 }
8484
85− ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
86− RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
85+ s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
86+ if (!s->qf) {
87+ av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
88+ err = AVERROR(ENOTSUP);
89+ goto fail;
90+ }
91+
92+ RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
8793 RET(ff_vk_shader_init(vkctx, &s->shd, "scale",
8894 VK_SHADER_STAGE_COMPUTE_BIT,
8995 NULL, 0,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t