Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -32,7 +32,6 @@ typedef struct AvgBlurVulkanContext { · 31 unmodified lines | |||
| 32 | int initialized; | 32 | int initialized; |
| 33 | FFVkExecPool e; | 33 | FFVkExecPool e; |
| 34 | AVVulkanDeviceQueueFamily *qf; | 34 | AVVulkanDeviceQueueFamily *qf; |
| 35 | VkSampler sampler; | ||
| 36 | FFVulkanShader shd; | 35 | FFVulkanShader shd; |
| 37 | 36 | ||
| 38 | /* Push constants / options */ | 37 | /* Push constants / options */ |
| @@ -52,7 +51,7 @@ static const char blur_kernel[] = { · 13 unmodified lines | |||
| 52 | C(1, vec4 sum = vec4(0); ) | 51 | C(1, vec4 sum = vec4(0); ) |
| 53 | C(1, for (int y = -filter_len.y; y <= filter_len.y; y++) ) | 52 | C(1, for (int y = -filter_len.y; y <= filter_len.y; y++) ) |
| 54 | C(1, for (int x = -filter_len.x; x <= filter_len.x; x++) ) | 53 | 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)); ) |
| 56 | C(0, ) | 55 | C(0, ) |
| 57 | C(1, imageStore(output_img[idx], pos, sum * filter_norm); ) | 56 | C(1, imageStore(output_img[idx], pos, sum * filter_norm); ) |
| 58 | C(0, } ) | 57 | C(0, } ) |
| @@ -85,7 +84,6 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 26 unmodified lines | |||
| 85 | } | 84 | } |
| 86 | 85 | ||
| 87 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL)); | 86 | 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)); | ||
| 89 | RET(ff_vk_shader_init(vkctx, &s->shd, "avgblur", | 87 | RET(ff_vk_shader_init(vkctx, &s->shd, "avgblur", |
| 90 | VK_SHADER_STAGE_COMPUTE_BIT, | 88 | VK_SHADER_STAGE_COMPUTE_BIT, |
| 91 | NULL, 0, | 89 | NULL, 0, |
| @@ -96,11 +94,12 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 4 unmodified lines | |||
| 96 | desc = (FFVulkanDescriptorSetBinding []) { | 94 | desc = (FFVulkanDescriptorSetBinding []) { |
| 97 | { | 95 | { |
| 98 | .name = "input_img", | 96 | .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", | ||
| 100 | .dimensions = 2, | 100 | .dimensions = 2, |
| 101 | .elems = planes, | 101 | .elems = planes, |
| 102 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, | 102 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, |
| 103 | .samplers = DUP_SAMPLER(s->sampler), | ||
| 104 | }, | 103 | }, |
| 105 | { | 104 | { |
| 106 | .name = "output_img", | 105 | .name = "output_img", |
| @@ -137,7 +136,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 30 unmodified lines | |||
| 137 | if (s->planes & (1 << i)) { | 136 | if (s->planes & (1 << i)) { |
| 138 | GLSLF(1, distort(pos, %i); ,i); | 137 | GLSLF(1, distort(pos, %i); ,i); |
| 139 | } else { | 138 | } else { |
| 140 | GLSLF(1, vec4 res = texture(input_img[%i], pos); ,i); | 139 | GLSLF(1, vec4 res = imageLoad(input_img[%i], pos); ,i); |
| 141 | GLSLF(1, imageStore(output_img[%i], pos, res); ,i); | 140 | GLSLF(1, imageStore(output_img[%i], pos, res); ,i); |
| 142 | } | 141 | } |
| 143 | } | 142 | } |
| @@ -186,7 +185,8 @@ static int avgblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) · 42 unmodified lines | |||
| 186 | RET(init_filter(ctx, in)); | 185 | RET(init_filter(ctx, in)); |
| 187 | 186 | ||
| 188 | RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd, | 187 | 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))); | ||
| 190 | 190 | ||
| 191 | err = av_frame_copy_props(out, in); | 191 | err = av_frame_copy_props(out, in); |
| 192 | if (err < 0) | 192 | if (err < 0) |
| @@ -206,15 +206,10 @@ static void avgblur_vulkan_uninit(AVFilterContext *avctx) · 13 unmodified lines | |||
| 206 | { | 206 | { |
| 207 | AvgBlurVulkanContext *s = avctx->priv; | 207 | AvgBlurVulkanContext *s = avctx->priv; |
| 208 | FFVulkanContext *vkctx = &s->vkctx; | 208 | FFVulkanContext *vkctx = &s->vkctx; |
| 209 | FFVulkanFunctions *vk = &vkctx->vkfn; | ||
| 210 | 209 | ||
| 211 | ff_vk_exec_pool_free(vkctx, &s->e); | 210 | ff_vk_exec_pool_free(vkctx, &s->e); |
| 212 | ff_vk_shader_free(vkctx, &s->shd); | 211 | ff_vk_shader_free(vkctx, &s->shd); |
| 213 | 212 | ||
| 214 | if (s->sampler) | ||
| 215 | vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler, | ||
| 216 | vkctx->hwctx->alloc); | ||
| 217 | |||
| 218 | ff_vk_uninit(&s->vkctx); | 213 | ff_vk_uninit(&s->vkctx); |
| 219 | 214 | ||
| 220 | s->initialized = 0; | 215 | s->initialized = 0; |