Unified · Split
| @@ -37,7 +37,6 @@ typedef struct NLMeansVulkanContext { · 36 unmodified lines | ||
| 37 | 37 | int initialized; |
| 38 | 38 | FFVkExecPool e; |
| 39 | 39 | AVVulkanDeviceQueueFamily *qf; |
| 40 | − VkSampler sampler; | |
| 41 | 40 | |
| 42 | 41 | AVBufferPool *integral_buf_pool; |
| 43 | 42 | AVBufferPool *ws_buf_pool; |
| @@ -66,16 +65,16 @@ typedef struct NLMeansVulkanContext { · 22 unmodified lines | ||
| 66 | 65 | |
| 67 | 66 | static void insert_first(FFVulkanShader *shd, int r, const char *off, int horiz, int plane, int comp) |
| 68 | 67 | { |
| 69 | − GLSLF(4, s1 = texture(input_img[%i], pos + ivec2(%i + %s, %i + %s))[%i]; | |
| 68 | + GLSLF(4, s1 = imageLoad(input_img[%i], pos + ivec2(%i + %s, %i + %s))[%i]; | |
| 70 | 69 | ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp); |
| 71 | 70 | |
| 72 | − GLSLF(4, s2[0] = texture(input_img[%i], pos + offs[0] + ivec2(%i + %s, %i + %s))[%i]; | |
| 71 | + GLSLF(4, s2[0] = imageLoad(input_img[%i], pos + offs[0] + ivec2(%i + %s, %i + %s))[%i]; | |
| 73 | 72 | ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp); |
| 74 | − GLSLF(4, s2[1] = texture(input_img[%i], pos + offs[1] + ivec2(%i + %s, %i + %s))[%i]; | |
| 73 | + GLSLF(4, s2[1] = imageLoad(input_img[%i], pos + offs[1] + ivec2(%i + %s, %i + %s))[%i]; | |
| 75 | 74 | ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp); |
| 76 | − GLSLF(4, s2[2] = texture(input_img[%i], pos + offs[2] + ivec2(%i + %s, %i + %s))[%i]; | |
| 75 | + GLSLF(4, s2[2] = imageLoad(input_img[%i], pos + offs[2] + ivec2(%i + %s, %i + %s))[%i]; | |
| 77 | 76 | ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp); |
| 78 | − GLSLF(4, s2[3] = texture(input_img[%i], pos + offs[3] + ivec2(%i + %s, %i + %s))[%i]; | |
| 77 | + GLSLF(4, s2[3] = imageLoad(input_img[%i], pos + offs[3] + ivec2(%i + %s, %i + %s))[%i]; | |
| 79 | 78 | ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp); |
| 80 | 79 | |
| 81 | 80 | GLSLC(4, s2 = (s1 - s2) * (s1 - s2); ); |
| @@ -164,10 +163,10 @@ static void insert_weights_pass(FFVulkanShader *shd, int nb_rows, int vert, · 82 unmodified lines | ||
| 164 | 163 | GLSLC(0, ); |
| 165 | 164 | GLSLC(3, lt = ((pos.x - p) < 0) || ((pos.y - p) < 0); ); |
| 166 | 165 | GLSLC(0, ); |
| 167 | − GLSLF(3, src[0] = texture(input_img[%i], pos + offs[0])[%i]; ,plane, comp); | |
| 168 | − GLSLF(3, src[1] = texture(input_img[%i], pos + offs[1])[%i]; ,plane, comp); | |
| 169 | − GLSLF(3, src[2] = texture(input_img[%i], pos + offs[2])[%i]; ,plane, comp); | |
| 170 | − GLSLF(3, src[3] = texture(input_img[%i], pos + offs[3])[%i]; ,plane, comp); | |
| 166 | + GLSLF(3, src[0] = imageLoad(input_img[%i], pos + offs[0])[%i]; ,plane, comp); | |
| 167 | + GLSLF(3, src[1] = imageLoad(input_img[%i], pos + offs[1])[%i]; ,plane, comp); | |
| 168 | + GLSLF(3, src[2] = imageLoad(input_img[%i], pos + offs[2])[%i]; ,plane, comp); | |
| 169 | + GLSLF(3, src[3] = imageLoad(input_img[%i], pos + offs[3])[%i]; ,plane, comp); | |
| 171 | 170 | GLSLC(0, ); |
| 172 | 171 | GLSLC(3, if (lt == false) { ); |
| 173 | 172 | GLSLC(3, offset = int_stride * uint64_t(pos.y - p); ); |
| @@ -210,7 +209,7 @@ typedef struct HorizontalPushData { · 36 unmodified lines | ||
| 210 | 209 | |
| 211 | 210 | static av_cold int init_weights_pipeline(FFVulkanContext *vkctx, FFVkExecPool *exec, |
| 212 | 211 | FFVulkanShader *shd, |
| 213 | − VkSampler sampler, FFVkSPIRVCompiler *spv, | |
| 212 | + FFVkSPIRVCompiler *spv, | |
| 214 | 213 | int width, int height, int t, |
| 215 | 214 | const AVPixFmtDescriptor *desc, |
| 216 | 215 | int planes, int *nb_rows) |
| @@ -275,11 +274,12 @@ static av_cold int init_weights_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e · 58 unmodified lines | ||
| 275 | 274 | desc_set = (FFVulkanDescriptorSetBinding []) { |
| 276 | 275 | { |
| 277 | 276 | .name = "input_img", |
| 278 | − .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, | |
| 277 | + .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, | |
| 278 | + .mem_layout = ff_vk_shader_rep_fmt(vkctx->input_format, FF_VK_REP_FLOAT), | |
| 279 | + .mem_quali = "readonly", | |
| 279 | 280 | .dimensions = 2, |
| 280 | 281 | .elems = planes, |
| 281 | 282 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, |
| 282 | − .samplers = DUP_SAMPLER(sampler), | |
| 283 | 283 | }, |
| 284 | 284 | { |
| 285 | 285 | .name = "weights_buffer_0", |
| @@ -418,8 +418,7 @@ typedef struct DenoisePushData { · 132 unmodified lines | ||
| 418 | 418 | } DenoisePushData; |
| 419 | 419 | |
| 420 | 420 | static av_cold int init_denoise_pipeline(FFVulkanContext *vkctx, FFVkExecPool *exec, |
| 421 | − FFVulkanShader *shd, | |
| 422 | − VkSampler sampler, FFVkSPIRVCompiler *spv, | |
| 421 | + FFVulkanShader *shd, FFVkSPIRVCompiler *spv, | |
| 423 | 422 | const AVPixFmtDescriptor *desc, int planes) |
| 424 | 423 | { |
| 425 | 424 | int err; |
| @@ -445,11 +444,12 @@ static av_cold int init_denoise_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e · 19 unmodified lines | ||
| 445 | 444 | desc_set = (FFVulkanDescriptorSetBinding []) { |
| 446 | 445 | { |
| 447 | 446 | .name = "input_img", |
| 448 | − .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, | |
| 447 | + .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, | |
| 448 | + .mem_layout = ff_vk_shader_rep_fmt(vkctx->input_format, FF_VK_REP_FLOAT), | |
| 449 | + .mem_quali = "readonly", | |
| 449 | 450 | .dimensions = 2, |
| 450 | 451 | .elems = planes, |
| 451 | 452 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, |
| 452 | − .samplers = DUP_SAMPLER(sampler), | |
| 453 | 453 | }, |
| 454 | 454 | { |
| 455 | 455 | .name = "output_img", |
| @@ -539,7 +539,7 @@ static av_cold int init_denoise_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e · 83 unmodified lines | ||
| 539 | 539 | GLSLC(1, if (!IS_WITHIN(pos, size)) ); |
| 540 | 540 | GLSLC(2, return; ); |
| 541 | 541 | GLSLC(0, ); |
| 542 | − GLSLC(1, src = texture(input_img[plane], pos); ); | |
| 542 | + GLSLC(1, src = imageLoad(input_img[plane], pos); ); | |
| 543 | 543 | GLSLC(0, ); |
| 544 | 544 | for (int c = 0; c < desc->nb_components; c++) { |
| 545 | 545 | int off = desc->comp[c].offset / (FFALIGN(desc->comp[c].depth, 8)/8); |
| @@ -660,13 +660,12 @@ static av_cold int init_filter(AVFilterContext *ctx) · 114 unmodified lines | ||
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, 1, 0, 0, 0, NULL)); |
| 663 | − RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST)); | |
| 664 | 663 | |
| 665 | − RET(init_weights_pipeline(vkctx, &s->e, &s->shd_weights, s->sampler, | |
| 664 | + RET(init_weights_pipeline(vkctx, &s->e, &s->shd_weights, | |
| 666 | 665 | spv, s->vkctx.output_width, s->vkctx.output_height, |
| 667 | 666 | s->opts.t, desc, planes, &s->pl_weights_rows)); |
| 668 | 667 | |
| 669 | − RET(init_denoise_pipeline(vkctx, &s->e, &s->shd_denoise, s->sampler, | |
| 668 | + RET(init_denoise_pipeline(vkctx, &s->e, &s->shd_denoise, | |
| 670 | 669 | spv, desc, planes)); |
| 671 | 670 | |
| 672 | 671 | RET(ff_vk_shader_update_desc_buffer(vkctx, &s->e.contexts[0], &s->shd_weights, |
| @@ -865,7 +864,7 @@ static int nlmeans_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) · 192 unmodified lines | ||
| 865 | 864 | VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, |
| 866 | 865 | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT, |
| 867 | 866 | VK_ACCESS_SHADER_READ_BIT, |
| 868 | − VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, | |
| 867 | + VK_IMAGE_LAYOUT_GENERAL, | |
| 869 | 868 | VK_QUEUE_FAMILY_IGNORED); |
| 870 | 869 | |
| 871 | 870 | /* Output frame prep */ |
| @@ -944,8 +943,7 @@ static int nlmeans_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) · 72 unmodified lines | ||
| 944 | 943 | |
| 945 | 944 | /* Update weights descriptors */ |
| 946 | 945 | ff_vk_shader_update_img_array(vkctx, exec, &s->shd_weights, in, in_views, 0, 0, |
| 947 | − VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, | |
| 948 | − s->sampler); | |
| 946 | + VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE); | |
| 949 | 947 | for (int i = 0; i < desc->nb_components; i++) { |
| 950 | 948 | RET(ff_vk_shader_update_desc_buffer(&s->vkctx, exec, &s->shd_weights, 0, 1 + i*2 + 0, 0, |
| 951 | 949 | ws_vk, weights_offs[i], ws_size[i], |
| @@ -957,10 +955,9 @@ static int nlmeans_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) · 5 unmodified lines | ||
| 957 | 955 | |
| 958 | 956 | /* Update denoise descriptors */ |
| 959 | 957 | ff_vk_shader_update_img_array(vkctx, exec, &s->shd_denoise, in, in_views, 0, 0, |
| 960 | − VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, | |
| 961 | − s->sampler); | |
| 958 | + VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE); | |
| 962 | 959 | ff_vk_shader_update_img_array(vkctx, exec, &s->shd_denoise, out, out_views, 0, 1, |
| 963 | − VK_IMAGE_LAYOUT_GENERAL, s->sampler); | |
| 960 | + VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE); | |
| 964 | 961 | for (int i = 0; i < desc->nb_components; i++) { |
| 965 | 962 | RET(ff_vk_shader_update_desc_buffer(&s->vkctx, exec, &s->shd_denoise, 1, i*2 + 0, 0, |
| 966 | 963 | ws_vk, weights_offs[i], ws_size[i], |
| @@ -1052,7 +1049,6 @@ static void nlmeans_vulkan_uninit(AVFilterContext *avctx) · 85 unmodified lines | ||
| 1052 | 1049 | { |
| 1053 | 1050 | NLMeansVulkanContext *s = avctx->priv; |
| 1054 | 1051 | FFVulkanContext *vkctx = &s->vkctx; |
| 1055 | − FFVulkanFunctions *vk = &vkctx->vkfn; | |
| 1056 | 1052 | |
| 1057 | 1053 | ff_vk_exec_pool_free(vkctx, &s->e); |
| 1058 | 1054 | ff_vk_shader_free(vkctx, &s->shd_weights); |
| @@ -1061,10 +1057,6 @@ static void nlmeans_vulkan_uninit(AVFilterContext *avctx) · 2 unmodified lines | ||
| 1061 | 1057 | av_buffer_pool_uninit(&s->integral_buf_pool); |
| 1062 | 1058 | av_buffer_pool_uninit(&s->ws_buf_pool); |
| 1063 | 1059 | |
| 1064 | − if (s->sampler) | |
| 1065 | − vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler, | |
| 1066 | − vkctx->hwctx->alloc); | |
| 1067 | − | |
| 1068 | 1060 | ff_vk_uninit(&s->vkctx); |
| 1069 | 1061 | |
| 1070 | 1062 | av_freep(&s->xoffsets); |