History

avgblur_vulkan: port to imageLoad()

Lynne committed 1 year ago

Commit 389fb361 parent 77976311 file · +7 −12Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_avgblur_vulkan.c+7−12
@@ -32,7 +32,6 @@ typedef struct AvgBlurVulkanContext { · 31 unmodified lines
3232 int initialized;
3333 FFVkExecPool e;
3434 AVVulkanDeviceQueueFamily *qf;
35− VkSampler sampler;
3635 FFVulkanShader shd;
3736
3837 /* Push constants / options */
@@ -52,7 +51,7 @@ static const char blur_kernel[] = { · 13 unmodified lines
5251 C(1, vec4 sum = vec4(0); )
5352 C(1, for (int y = -filter_len.y; y <= filter_len.y; y++) )
5453 C(1, for (int x = -filter_len.x; x <= filter_len.x; x++) )
55− C(2, sum += texture(input_img[idx], pos + ivec2(x, y)); )
54+ C(2, sum += imageLoad(input_img[idx], pos + ivec2(x, y)); )
5655 C(0, )
5756 C(1, imageStore(output_img[idx], pos, sum * filter_norm); )
5857 C(0, } )
@@ -85,7 +84,6 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 26 unmodified lines
8584 }
8685
8786 RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
88− RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
8987 RET(ff_vk_shader_init(vkctx, &s->shd, "avgblur",
9088 VK_SHADER_STAGE_COMPUTE_BIT,
9189 NULL, 0,
@@ -96,11 +94,12 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 4 unmodified lines
9694 desc = (FFVulkanDescriptorSetBinding []) {
9795 {
9896 .name = "input_img",
99− .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
97+ .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
98+ .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.input_format, FF_VK_REP_FLOAT),
99+ .mem_quali = "readonly",
100100 .dimensions = 2,
101101 .elems = planes,
102102 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
103− .samplers = DUP_SAMPLER(s->sampler),
104103 },
105104 {
106105 .name = "output_img",
@@ -137,7 +136,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 30 unmodified lines
137136 if (s->planes & (1 << i)) {
138137 GLSLF(1, distort(pos, %i); ,i);
139138 } else {
140− GLSLF(1, vec4 res = texture(input_img[%i], pos); ,i);
139+ GLSLF(1, vec4 res = imageLoad(input_img[%i], pos); ,i);
141140 GLSLF(1, imageStore(output_img[%i], pos, res); ,i);
142141 }
143142 }
@@ -186,7 +185,8 @@ static int avgblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) · 42 unmodified lines
186185 RET(init_filter(ctx, in));
187186
188187 RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd,
189− out, in, s->sampler, &s->opts, sizeof(s->opts)));
188+ out, in, VK_NULL_HANDLE,
189+ &s->opts, sizeof(s->opts)));
190190
191191 err = av_frame_copy_props(out, in);
192192 if (err < 0)
@@ -206,15 +206,10 @@ static void avgblur_vulkan_uninit(AVFilterContext *avctx) · 13 unmodified lines
206206 {
207207 AvgBlurVulkanContext *s = avctx->priv;
208208 FFVulkanContext *vkctx = &s->vkctx;
209− FFVulkanFunctions *vk = &vkctx->vkfn;
210209
211210 ff_vk_exec_pool_free(vkctx, &s->e);
212211 ff_vk_shader_free(vkctx, &s->shd);
213212
214− if (s->sampler)
215− vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
216− vkctx->hwctx->alloc);
217−
218213 ff_vk_uninit(&s->vkctx);
219214
220215 s->initialized = 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