| @@ -445,15 +445,13 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) · 444 unmodified lines |
| 445 | 445 | /* Try to create the instance */ |
| 446 | 446 | ret = vkCreateInstance(&inst_props, hwctx->alloc, &hwctx->inst); |
| 447 | 447 | |
| 448 | | − /* Free used memory */ |
| 449 | | − for (int i = 0; i < inst_props.enabledExtensionCount; i++) |
| 450 | | − av_free((void *)inst_props.ppEnabledExtensionNames[i]); |
| 451 | | − av_free((void *)inst_props.ppEnabledExtensionNames); |
| 452 | | − |
| 453 | 448 | /* Check for errors */ |
| 454 | 449 | if (ret != VK_SUCCESS) { |
| 455 | 450 | av_log(ctx, AV_LOG_ERROR, "Instance creation failure: %s\n", |
| 456 | 451 | vk_ret2str(ret)); |
| 452 | + for (int i = 0; i < inst_props.enabledExtensionCount; i++) |
| 453 | + av_free((void *)inst_props.ppEnabledExtensionNames[i]); |
| 454 | + av_free((void *)inst_props.ppEnabledExtensionNames); |
| 457 | 455 | return AVERROR_EXTERNAL; |
| 458 | 456 | } |
| 459 | 457 | |
| @@ -476,6 +474,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) · 16 unmodified lines |
| 476 | 474 | hwctx->alloc, &p->debug_ctx); |
| 477 | 475 | } |
| 478 | 476 | |
| 477 | + hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames; |
| 478 | + hwctx->nb_enabled_inst_extensions = inst_props.enabledExtensionCount; |
| 479 | + |
| 479 | 480 | return 0; |
| 480 | 481 | } |
| 481 | 482 | |
| @@ -781,6 +782,14 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) · 299 unmodified lines |
| 781 | 782 | } |
| 782 | 783 | |
| 783 | 784 | vkDestroyInstance(hwctx->inst, hwctx->alloc); |
| 785 | + |
| 786 | + for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++) |
| 787 | + av_free((void *)hwctx->enabled_inst_extensions[i]); |
| 788 | + av_free((void *)hwctx->enabled_inst_extensions); |
| 789 | + |
| 790 | + for (int i = 0; i < hwctx->nb_enabled_dev_extensions; i++) |
| 791 | + av_free((void *)hwctx->enabled_dev_extensions[i]); |
| 792 | + av_free((void *)hwctx->enabled_dev_extensions); |
| 784 | 793 | } |
| 785 | 794 | |
| 786 | 795 | static int vulkan_device_create_internal(AVHWDeviceContext *ctx, |
| @@ -841,13 +850,12 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 54 unmodified lines |
| 841 | 850 | ret = vkCreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc, |
| 842 | 851 | &hwctx->act_dev); |
| 843 | 852 | |
| 844 | | − for (int i = 0; i < dev_info.enabledExtensionCount; i++) |
| 845 | | − av_free((void *)dev_info.ppEnabledExtensionNames[i]); |
| 846 | | − av_free((void *)dev_info.ppEnabledExtensionNames); |
| 847 | | − |
| 848 | 853 | if (ret != VK_SUCCESS) { |
| 849 | 854 | av_log(ctx, AV_LOG_ERROR, "Device creation failure: %s\n", |
| 850 | 855 | vk_ret2str(ret)); |
| 856 | + for (int i = 0; i < dev_info.enabledExtensionCount; i++) |
| 857 | + av_free((void *)dev_info.ppEnabledExtensionNames[i]); |
| 858 | + av_free((void *)dev_info.ppEnabledExtensionNames); |
| 851 | 859 | err = AVERROR_EXTERNAL; |
| 852 | 860 | goto end; |
| 853 | 861 | } |
| @@ -857,6 +865,9 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 3 unmodified lines |
| 857 | 865 | if (opt_d) |
| 858 | 866 | p->use_linear_images = strtol(opt_d->value, NULL, 10); |
| 859 | 867 | |
| 868 | + hwctx->enabled_dev_extensions = dev_info.ppEnabledExtensionNames; |
| 869 | + hwctx->nb_enabled_dev_extensions = dev_info.enabledExtensionCount; |
| 870 | + |
| 860 | 871 | end: |
| 861 | 872 | return err; |
| 862 | 873 | } |
| @@ -868,6 +879,17 @@ static int vulkan_device_init(AVHWDeviceContext *ctx) · 5 unmodified lines |
| 868 | 879 | AVVulkanDeviceContext *hwctx = ctx->hwctx; |
| 869 | 880 | VulkanDevicePriv *p = ctx->internal->priv; |
| 870 | 881 | |
| 882 | + /* Set device extension flags */ |
| 883 | + for (int i = 0; i < hwctx->nb_enabled_dev_extensions; i++) { |
| 884 | + for (int j = 0; j < FF_ARRAY_ELEMS(optional_device_exts); j++) { |
| 885 | + if (!strcmp(hwctx->enabled_dev_extensions[i], |
| 886 | + optional_device_exts[j].name)) { |
| 887 | + p->extensions |= optional_device_exts[j].flag; |
| 888 | + break; |
| 889 | + } |
| 890 | + } |
| 891 | + } |
| 892 | + |
| 871 | 893 | vkGetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &queue_num, NULL); |
| 872 | 894 | if (!queue_num) { |
| 873 | 895 | av_log(ctx, AV_LOG_ERROR, "Failed to get queues!\n"); |