From 9bac7ed30ed82aa06ea810223e5e3f0d49238945 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 25 Aug 2023 18:19:29 +0100 Subject: [PATCH] c/main: Print creation info for direct mode objects --- .../compositor/main/comp_target_swapchain.c | 21 ++++++++++--------- .../compositor/main/comp_target_swapchain.h | 6 ++++++ src/xrt/compositor/main/comp_window_direct.c | 8 +++---- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/xrt/compositor/main/comp_target_swapchain.c b/src/xrt/compositor/main/comp_target_swapchain.c index e14661752..643a30674 100644 --- a/src/xrt/compositor/main/comp_target_swapchain.c +++ b/src/xrt/compositor/main/comp_target_swapchain.c @@ -679,16 +679,15 @@ comp_target_swapchain_create_images(struct comp_target *ct, } // Always print the first one. - { - static bool first = true; - if (first) { - vk_print_surface_info(vk, &info, U_LOGGING_INFO); - first = false; - } else { - vk_print_surface_info(vk, &info, U_LOGGING_DEBUG); - } + enum u_logging_level print_log_level = U_LOGGING_DEBUG; + if (!cts->has_logged_info) { + print_log_level = U_LOGGING_INFO; + cts->has_logged_info = true; } + // Print info about the surface. + vk_print_surface_info(vk, &info, print_log_level); + if (!check_surface_present_mode(cts, &info, cts->present_mode)) { // Free old. destroy_old(cts, old_swapchain_handle); @@ -746,8 +745,6 @@ comp_target_swapchain_create_images(struct comp_target *ct, * Do the creation. */ - COMP_DEBUG(ct->c, "Creating compositor swapchain with %d images", image_count); - // Create the swapchain now. VkSwapchainCreateInfoKHR swapchain_info = { .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, @@ -771,6 +768,10 @@ comp_target_swapchain_create_images(struct comp_target *ct, .oldSwapchain = old_swapchain_handle, }; + // Print what we are creating. + vk_print_swapchain_create_info(vk, &swapchain_info, print_log_level); + + // Everything decided and logged, do the creation. ret = vk->vkCreateSwapchainKHR(vk->device, &swapchain_info, NULL, &cts->swapchain.handle); // Always destroy the old. diff --git a/src/xrt/compositor/main/comp_target_swapchain.h b/src/xrt/compositor/main/comp_target_swapchain.h index 1b6d9d77f..7098fcab4 100644 --- a/src/xrt/compositor/main/comp_target_swapchain.h +++ b/src/xrt/compositor/main/comp_target_swapchain.h @@ -87,6 +87,12 @@ struct comp_target_swapchain //! Thread waiting on vblank_event_fence (first pixel out). struct os_thread_helper event_thread; } vblank; + + /*! + * We print swapchain info as INFO the first time we create a + * VkSWapchain, this keeps track if we have done it. + */ + bool has_logged_info; }; diff --git a/src/xrt/compositor/main/comp_window_direct.c b/src/xrt/compositor/main/comp_window_direct.c index 56f91cb94..7b2a7e8dc 100644 --- a/src/xrt/compositor/main/comp_window_direct.c +++ b/src/xrt/compositor/main/comp_window_direct.c @@ -211,11 +211,11 @@ comp_window_direct_create_surface(struct comp_target_swapchain *cts, }, }; - VkResult result = vk->vkCreateDisplayPlaneSurfaceKHR(vk->instance, &surface_info, NULL, &cts->surface.handle); + // This function is called seldom so ok to always print. + vk_print_display_surface_create_info(vk, &surface_info, U_LOGGING_INFO); - free(plane_properties); - - return result; + // Everything decided and logged, do the creation. + return vk->vkCreateDisplayPlaneSurfaceKHR(vk->instance, &surface_info, NULL, &cts->surface.handle); } #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT