History

hwcontext_vulkan: forward debug_mode to check_extensions() for devices

This allows disabling of certain extensions when debug mode is turned on.

Lynne committed 2 years ago

Commit 2942ca81 parent b5184c51 file · +13 −12Browse files

Unified · Split

libavutil/hwcontext_vulkan.c+13−12
@@ -798,11 +798,11 @@ end: · 797 unmodified lines
798}798}
799 799
800/* Creates a VkInstance */800/* Creates a VkInstance */
801static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts)801static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts,
802 enum FFVulkanDebugMode *debug_mode)
802{803{
803 int err = 0;804 int err = 0;
804 VkResult ret;805 VkResult ret;
805 enum FFVulkanDebugMode debug_mode;
806 VulkanDevicePriv *p = ctx->hwctx;806 VulkanDevicePriv *p = ctx->hwctx;
807 AVVulkanDeviceContext *hwctx = &p->p;807 AVVulkanDeviceContext *hwctx = &p->p;
808 FFVulkanFunctions *vk = &p->vkctx.vkfn;808 FFVulkanFunctions *vk = &p->vkctx.vkfn;
@@ -839,20 +839,20 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) · 30 unmodified lines
839 }839 }
840 840
841 err = check_layers(ctx, opts, &inst_props.ppEnabledLayerNames,841 err = check_layers(ctx, opts, &inst_props.ppEnabledLayerNames,
842 &inst_props.enabledLayerCount, &debug_mode);842 &inst_props.enabledLayerCount, debug_mode);
843 if (err)843 if (err)
844 goto fail;844 goto fail;
845 845
846 /* Check for present/missing extensions */846 /* Check for present/missing extensions */
847 err = check_extensions(ctx, 0, opts, &inst_props.ppEnabledExtensionNames,847 err = check_extensions(ctx, 0, opts, &inst_props.ppEnabledExtensionNames,
848 &inst_props.enabledExtensionCount, debug_mode);848 &inst_props.enabledExtensionCount, *debug_mode);
849 hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames;849 hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames;
850 hwctx->nb_enabled_inst_extensions = inst_props.enabledExtensionCount;850 hwctx->nb_enabled_inst_extensions = inst_props.enabledExtensionCount;
851 if (err < 0)851 if (err < 0)
852 goto fail;852 goto fail;
853 853
854 /* Enable debug features if needed */854 /* Enable debug features if needed */
855 if (debug_mode == FF_VULKAN_DEBUG_VALIDATE) {855 if (*debug_mode == FF_VULKAN_DEBUG_VALIDATE) {
856 static const VkValidationFeatureEnableEXT feat_list_validate[] = {856 static const VkValidationFeatureEnableEXT feat_list_validate[] = {
857 VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,857 VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,
858 VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,858 VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,
@@ -861,7 +861,7 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) · 2 unmodified lines
861 validation_features.pEnabledValidationFeatures = feat_list_validate;861 validation_features.pEnabledValidationFeatures = feat_list_validate;
862 validation_features.enabledValidationFeatureCount = FF_ARRAY_ELEMS(feat_list_validate);862 validation_features.enabledValidationFeatureCount = FF_ARRAY_ELEMS(feat_list_validate);
863 inst_props.pNext = &validation_features;863 inst_props.pNext = &validation_features;
864 } else if (debug_mode == FF_VULKAN_DEBUG_PRINTF) {864 } else if (*debug_mode == FF_VULKAN_DEBUG_PRINTF) {
865 static const VkValidationFeatureEnableEXT feat_list_debug[] = {865 static const VkValidationFeatureEnableEXT feat_list_debug[] = {
866 VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,866 VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,
867 VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,867 VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,
@@ -870,7 +870,7 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) · 2 unmodified lines
870 validation_features.pEnabledValidationFeatures = feat_list_debug;870 validation_features.pEnabledValidationFeatures = feat_list_debug;
871 validation_features.enabledValidationFeatureCount = FF_ARRAY_ELEMS(feat_list_debug);871 validation_features.enabledValidationFeatureCount = FF_ARRAY_ELEMS(feat_list_debug);
872 inst_props.pNext = &validation_features;872 inst_props.pNext = &validation_features;
873 } else if (debug_mode == FF_VULKAN_DEBUG_PRACTICES) {873 } else if (*debug_mode == FF_VULKAN_DEBUG_PRACTICES) {
874 static const VkValidationFeatureEnableEXT feat_list_practices[] = {874 static const VkValidationFeatureEnableEXT feat_list_practices[] = {
875 VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,875 VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,
876 VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT,876 VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT,
@@ -908,9 +908,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) · 31 unmodified lines
908 }908 }
909 909
910 /* Setup debugging callback if needed */910 /* Setup debugging callback if needed */
911 if ((debug_mode == FF_VULKAN_DEBUG_VALIDATE) ||911 if ((*debug_mode == FF_VULKAN_DEBUG_VALIDATE) ||
912 (debug_mode == FF_VULKAN_DEBUG_PRINTF) ||912 (*debug_mode == FF_VULKAN_DEBUG_PRINTF) ||
913 (debug_mode == FF_VULKAN_DEBUG_PRACTICES)) {913 (*debug_mode == FF_VULKAN_DEBUG_PRACTICES)) {
914 VkDebugUtilsMessengerCreateInfoEXT dbg = {914 VkDebugUtilsMessengerCreateInfoEXT dbg = {
915 .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,915 .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
916 .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |916 .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
@@ -1403,6 +1403,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 486 unmodified lines
1403 VulkanDevicePriv *p = ctx->hwctx;1403 VulkanDevicePriv *p = ctx->hwctx;
1404 AVVulkanDeviceContext *hwctx = &p->p;1404 AVVulkanDeviceContext *hwctx = &p->p;
1405 FFVulkanFunctions *vk = &p->vkctx.vkfn;1405 FFVulkanFunctions *vk = &p->vkctx.vkfn;
1406 enum FFVulkanDebugMode debug_mode = FF_VULKAN_DEBUG_NONE;
1406 1407
1407 /*1408 /*
1408 * VkPhysicalDeviceVulkan12Features has a timelineSemaphore field, but1409 * VkPhysicalDeviceVulkan12Features has a timelineSemaphore field, but
@@ -1460,7 +1461,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 51 unmodified lines
1460 ctx->free = vulkan_device_free;1461 ctx->free = vulkan_device_free;
1461 1462
1462 /* Create an instance if not given one */1463 /* Create an instance if not given one */
1463 if ((err = create_instance(ctx, opts)))1464 if ((err = create_instance(ctx, opts, &debug_mode)))
1464 goto end;1465 goto end;
1465 1466
1466 /* Find a device (if not given one) */1467 /* Find a device (if not given one) */
@@ -1529,7 +1530,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 62 unmodified lines
1529 1530
1530 /* Find and enable extensions */1531 /* Find and enable extensions */
1531 if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames,1532 if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames,
1532 &dev_info.enabledExtensionCount, 0))) {1533 &dev_info.enabledExtensionCount, debug_mode))) {
1533 for (int i = 0; i < dev_info.queueCreateInfoCount; i++)1534 for (int i = 0; i < dev_info.queueCreateInfoCount; i++)
1534 av_free((void *)dev_info.pQueueCreateInfos[i].pQueuePriorities);1535 av_free((void *)dev_info.pQueueCreateInfos[i].pQueuePriorities);
1535 av_free((void *)dev_info.pQueueCreateInfos);1536 av_free((void *)dev_info.pQueueCreateInfos);

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