From 481a319ad2df61fed7e2728d70eb9b945894303e Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 12 Mar 2024 10:22:24 -0400 Subject: [PATCH 9/9] zink: don't print error messages when failing an implicit driver load --- src/gallium/drivers/zink/zink_device_info.py | 6 +- src/gallium/drivers/zink/zink_instance.py | 15 ++-- src/gallium/drivers/zink/zink_screen.c | 76 +++++++++++++------- src/gallium/drivers/zink/zink_types.h | 1 + 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/src/gallium/drivers/zink/zink_device_info.py b/src/gallium/drivers/zink/zink_device_info.py index 17222001180d5..b0bc38218922c 100644 --- a/src/gallium/drivers/zink/zink_device_info.py +++ b/src/gallium/drivers/zink/zink_device_info.py @@ -470,14 +470,16 @@ zink_get_physical_device_info(struct zink_screen *screen) // enumerate device supported extensions VkResult result = screen->vk.EnumerateDeviceExtensionProperties(screen->pdev, NULL, &num_extensions, NULL); if (result != VK_SUCCESS) { - mesa_loge("ZINK: vkEnumerateDeviceExtensionProperties failed (%s)", vk_Result_to_str(result)); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumerateDeviceExtensionProperties failed (%s)", vk_Result_to_str(result)); } else { if (num_extensions > 0) { VkExtensionProperties *extensions = MALLOC(sizeof(VkExtensionProperties) * num_extensions); if (!extensions) goto fail; result = screen->vk.EnumerateDeviceExtensionProperties(screen->pdev, NULL, &num_extensions, extensions); if (result != VK_SUCCESS) { - mesa_loge("ZINK: vkEnumerateDeviceExtensionProperties failed (%s)", vk_Result_to_str(result)); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumerateDeviceExtensionProperties failed (%s)", vk_Result_to_str(result)); } for (uint32_t i = 0; i < num_extensions; ++i) { diff --git a/src/gallium/drivers/zink/zink_instance.py b/src/gallium/drivers/zink/zink_instance.py index 0fbd14e5a5826..fec0844593b78 100644 --- a/src/gallium/drivers/zink/zink_instance.py +++ b/src/gallium/drivers/zink/zink_instance.py @@ -156,12 +156,14 @@ zink_create_instance(struct zink_screen *screen, bool display_dev) // Build up the extensions from the reported ones but only for the unnamed layer uint32_t extension_count = 0; if (vk_EnumerateInstanceExtensionProperties(NULL, &extension_count, NULL) != VK_SUCCESS) { - mesa_loge("ZINK: vkEnumerateInstanceExtensionProperties failed"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumerateInstanceExtensionProperties failed"); } else { VkExtensionProperties *extension_props = malloc(extension_count * sizeof(VkExtensionProperties)); if (extension_props) { if (vk_EnumerateInstanceExtensionProperties(NULL, &extension_count, extension_props) != VK_SUCCESS) { - mesa_loge("ZINK: vkEnumerateInstanceExtensionProperties failed"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumerateInstanceExtensionProperties failed"); } else { for (uint32_t i = 0; i < extension_count; i++) { %for ext in extensions: @@ -179,12 +181,14 @@ zink_create_instance(struct zink_screen *screen, bool display_dev) uint32_t layer_count = 0; if (vk_EnumerateInstanceLayerProperties(&layer_count, NULL) != VK_SUCCESS) { - mesa_loge("ZINK: vkEnumerateInstanceLayerProperties failed"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumerateInstanceLayerProperties failed"); } else { VkLayerProperties *layer_props = malloc(layer_count * sizeof(VkLayerProperties)); if (layer_props) { if (vk_EnumerateInstanceLayerProperties(&layer_count, layer_props) != VK_SUCCESS) { - mesa_loge("ZINK: vkEnumerateInstanceLayerProperties failed"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumerateInstanceLayerProperties failed"); } else { for (uint32_t i = 0; i < layer_count; i++) { %for layer in layers: @@ -256,7 +260,8 @@ zink_create_instance(struct zink_screen *screen, bool display_dev) VkResult err = vk_CreateInstance(&ici, NULL, &screen->instance); if (err != VK_SUCCESS) { - mesa_loge("ZINK: vkCreateInstance failed (%s)", vk_Result_to_str(err)); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkCreateInstance failed (%s)", vk_Result_to_str(err)); return false; } diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 9d4952eb4ef1b..39194c7a89bf2 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -1695,7 +1695,8 @@ choose_pdev(struct zink_screen *screen, int64_t dev_major, int64_t dev_minor) VkPhysicalDevice *pdevs; VkResult result = VKSCR(EnumeratePhysicalDevices)(screen->instance, &pdev_count, NULL); if (result != VK_SUCCESS) { - mesa_loge("ZINK: vkEnumeratePhysicalDevices failed (%s)", vk_Result_to_str(result)); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumeratePhysicalDevices failed (%s)", vk_Result_to_str(result)); return; } @@ -1703,7 +1704,8 @@ choose_pdev(struct zink_screen *screen, int64_t dev_major, int64_t dev_minor) pdevs = malloc(sizeof(*pdevs) * pdev_count); if (!pdevs) { - mesa_loge("ZINK: failed to allocate pdevs!"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to allocate pdevs!"); return; } result = VKSCR(EnumeratePhysicalDevices)(screen->instance, &pdev_count, pdevs); @@ -1730,7 +1732,8 @@ choose_pdev(struct zink_screen *screen, int64_t dev_major, int64_t dev_minor) unsigned pdev_count = 1; VkResult result = VKSCR(EnumeratePhysicalDevices)(screen->instance, &pdev_count, &pdev); if (result != VK_SUCCESS && result != VK_INCOMPLETE) { - mesa_loge("ZINK: vkEnumeratePhysicalDevices failed (%s)", vk_Result_to_str(result)); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: vkEnumeratePhysicalDevices failed (%s)", vk_Result_to_str(result)); return; } screen->pdev = pdev; @@ -3238,10 +3241,12 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev struct zink_screen *screen = rzalloc(NULL, struct zink_screen); if (!screen) { - mesa_loge("ZINK: failed to allocate screen"); + if (!config->implicit_driver_load) + mesa_loge("ZINK: failed to allocate screen"); return NULL; } + screen->implicitly_loaded = config->implicit_driver_load; screen->drm_fd = -1; glsl_type_singleton_init_or_ref(); @@ -3261,7 +3266,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev screen->loader_lib = util_dl_open(VK_LIBNAME); if (!screen->loader_lib) { - mesa_loge("ZINK: failed to load "VK_LIBNAME); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to load "VK_LIBNAME); goto fail; } @@ -3269,7 +3275,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev screen->vk_GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)util_dl_get_proc_address(screen->loader_lib, "vkGetDeviceProcAddr"); if (!screen->vk_GetInstanceProcAddr || !screen->vk_GetDeviceProcAddr) { - mesa_loge("ZINK: failed to get proc address"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to get proc address"); goto fail; } @@ -3289,7 +3296,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev if (zink_debug & ZINK_DEBUG_VALIDATION) { if (!screen->instance_info.have_layer_KHRONOS_validation && !screen->instance_info.have_layer_LUNARG_standard_validation) { - mesa_loge("Failed to load validation layer"); + if (!screen->implicitly_loaded) + mesa_loge("Failed to load validation layer"); goto fail; } } @@ -3304,12 +3312,15 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev zink_verify_instance_extensions(screen); if (screen->instance_info.have_EXT_debug_utils && - (zink_debug & ZINK_DEBUG_VALIDATION) && !create_debug(screen)) - debug_printf("ZINK: failed to setup debug utils\n"); + (zink_debug & ZINK_DEBUG_VALIDATION) && !create_debug(screen)) { + if (!screen->implicitly_loaded) + debug_printf("ZINK: failed to setup debug utils\n"); + } choose_pdev(screen, dev_major, dev_minor); if (screen->pdev == VK_NULL_HANDLE) { - mesa_loge("ZINK: failed to choose pdev"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to choose pdev"); goto fail; } screen->is_cpu = screen->info.props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU; @@ -3324,7 +3335,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev VK_FORMAT_D32_SFLOAT_S8_UINT); if (!zink_get_physical_device_info(screen)) { - debug_printf("ZINK: failed to detect features\n"); + if (!screen->implicitly_loaded) + debug_printf("ZINK: failed to detect features\n"); goto fail; } @@ -3367,18 +3379,21 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev setup_renderdoc(screen); if (screen->threaded_submit && !util_queue_init(&screen->flush_queue, "zfq", 8, 1, UTIL_QUEUE_INIT_RESIZE_IF_FULL, screen)) { - mesa_loge("zink: Failed to create flush queue.\n"); + if (!screen->implicitly_loaded) + mesa_loge("zink: Failed to create flush queue.\n"); goto fail; } zink_internal_setup_moltenvk(screen); if (!screen->info.have_KHR_timeline_semaphore && !screen->info.feats12.timelineSemaphore) { - mesa_loge("zink: KHR_timeline_semaphore is required"); + if (!screen->implicitly_loaded) + mesa_loge("zink: KHR_timeline_semaphore is required"); goto fail; } if (zink_debug & ZINK_DEBUG_DGC) { if (!screen->info.have_NV_device_generated_commands) { - mesa_loge("zink: can't use DGC without NV_device_generated_commands"); + if (!screen->implicitly_loaded) + mesa_loge("zink: can't use DGC without NV_device_generated_commands"); goto fail; } } @@ -3497,14 +3512,16 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev if (!zink_screen_resource_init(&screen->base)) goto fail; if (!zink_bo_init(screen)) { - mesa_loge("ZINK: failed to initialize suballocator"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to initialize suballocator"); goto fail; } zink_screen_fence_init(&screen->base); zink_screen_init_compiler(screen); if (!disk_cache_init(screen)) { - mesa_loge("ZINK: failed to initialize disk cache"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to initialize disk cache"); goto fail; } if (!util_queue_init(&screen->cache_get_thread, "zcfq", 8, 4, @@ -3520,12 +3537,14 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev screen->total_video_mem = get_video_mem(screen); screen->clamp_video_mem = screen->total_video_mem * 0.8; if (!os_get_total_physical_memory(&screen->total_mem)) { - mesa_loge("ZINK: failed to get total physical memory"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to get total physical memory"); goto fail; } if (!zink_screen_init_semaphore(screen)) { - mesa_loge("zink: failed to create timeline semaphore"); + if (!screen->implicitly_loaded) + mesa_loge("zink: failed to create timeline semaphore"); goto fail; } @@ -3533,35 +3552,40 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev { if (!screen->info.have_EXT_descriptor_buffer) { if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) { - mesa_loge("Cannot use db descriptor mode without EXT_descriptor_buffer"); + if (!screen->implicitly_loaded) + mesa_loge("Cannot use db descriptor mode without EXT_descriptor_buffer"); goto fail; } can_db = false; } if (!screen->resizable_bar) { if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) { - mesa_loge("Cannot use db descriptor mode without resizable bar"); + if (!screen->implicitly_loaded) + mesa_loge("Cannot use db descriptor mode without resizable bar"); goto fail; } can_db = false; } if (!screen->info.have_EXT_non_seamless_cube_map) { if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) { - mesa_loge("Cannot use db descriptor mode without EXT_non_seamless_cube_map"); + if (!screen->implicitly_loaded) + mesa_loge("Cannot use db descriptor mode without EXT_non_seamless_cube_map"); goto fail; } can_db = false; } if (!screen->info.rb2_feats.nullDescriptor) { if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) { - mesa_loge("Cannot use db descriptor mode without robustness2.nullDescriptor"); + if (!screen->implicitly_loaded) + mesa_loge("Cannot use db descriptor mode without robustness2.nullDescriptor"); goto fail; } can_db = false; } if (ZINK_FBFETCH_DESCRIPTOR_SIZE < screen->info.db_props.inputAttachmentDescriptorSize) { if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) { - mesa_loge("Cannot use db descriptor mode with inputAttachmentDescriptorSize(%u) > %u", (unsigned)screen->info.db_props.inputAttachmentDescriptorSize, ZINK_FBFETCH_DESCRIPTOR_SIZE); + if (!screen->implicitly_loaded) + mesa_loge("Cannot use db descriptor mode with inputAttachmentDescriptorSize(%u) > %u", (unsigned)screen->info.db_props.inputAttachmentDescriptorSize, ZINK_FBFETCH_DESCRIPTOR_SIZE); goto fail; } mesa_logw("zink: bug detected: inputAttachmentDescriptorSize(%u) > %u", (unsigned)screen->info.db_props.inputAttachmentDescriptorSize, ZINK_FBFETCH_DESCRIPTOR_SIZE); @@ -3620,12 +3644,14 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev zink_init_screen_pipeline_libs(screen); if (!init_layouts(screen)) { - mesa_loge("ZINK: failed to initialize layouts"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to initialize layouts"); goto fail; } if (!zink_descriptor_layouts_init(screen)) { - mesa_loge("ZINK: failed to initialize descriptor layouts"); + if (!screen->implicitly_loaded) + mesa_loge("ZINK: failed to initialize descriptor layouts"); goto fail; } diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 739838d0dce14..512c5c571ba84 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1413,6 +1413,7 @@ struct zink_screen { bool is_cpu; bool abort_on_hang; bool frame_marker_emitted; + bool implicitly_loaded; uint64_t curr_batch; //the current batch id uint32_t last_finished; VkSemaphore sem; -- GitLab