aux/vk: Refactor out some printing functions

This commit is contained in:
Jakob Bornecrantz 2022-03-30 20:08:50 +01:00
parent 2f73c7569a
commit 4f1dfa7ae4
6 changed files with 111 additions and 44 deletions

View file

@ -263,6 +263,7 @@ if(XRT_HAVE_VULKAN)
vk/vk_image_allocator.h
vk/vk_image_readback_to_xf_pool.c
vk/vk_image_readback_to_xf_pool.h
vk/vk_print.c
vk/vk_state_creators.c
vk/vk_sync_objects.c
)

View file

@ -303,6 +303,7 @@ lib_aux_vk = static_library(
'vk/vk_image_allocator.c',
'vk/vk_image_readback_to_xf_pool.h',
'vk/vk_image_readback_to_xf_pool.c',
'vk/vk_print.c',
'vk/vk_state_creators.c',
'vk/vk_sync_objects.c',
),

View file

@ -274,6 +274,7 @@ fill_in_external_object_properties(struct vk_bundle *vk)
}
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
vk->external.fence_sync_fd = is_fence_bit_supported( //
vk, VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT);
vk->external.fence_opaque_fd = is_fence_bit_supported( //
@ -290,23 +291,6 @@ fill_in_external_object_properties(struct vk_bundle *vk)
vk->external.timeline_semaphore_opaque_fd = is_timeline_semaphore_bit_supported( //
vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT);
VK_DEBUG(vk, "Supported fences:\n\t%s: %s\n\t%s: %s", //
"VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT", //
vk->external.fence_sync_fd ? "true" : "false", //
"VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT", //
vk->external.fence_opaque_fd ? "true" : "false"); //
VK_DEBUG(vk, "Supported semaphores:\n\t%s: %s\n\t%s: %s\n\t%s: %s\n\t%s: %s\n\t%s: %s", //
"features.timeline_semaphore", vk->features.timeline_semaphore ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT(binary)", //
vk->external.binary_semaphore_sync_fd ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT(binary)", //
vk->external.binary_semaphore_opaque_fd ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT(timeline)", //
vk->external.timeline_semaphore_sync_fd ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT(timeline)", //
vk->external.timeline_semaphore_opaque_fd ? "true" : "false"); //
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
vk->external.fence_win32_handle = is_fence_bit_supported( //
vk, VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT);
@ -318,15 +302,6 @@ fill_in_external_object_properties(struct vk_bundle *vk)
vk->external.timeline_semaphore_win32_handle = is_timeline_semaphore_bit_supported( //
vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT);
VK_DEBUG(vk, "Supported fences:\n\t%s: %s", //
"VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT", //
vk->external.fence_win32_handle ? "true" : "false"); //
VK_DEBUG(vk, "Supported semaphores:\n\t%s: %s\n\t%s: %s", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(binary)", //
vk->external.binary_semaphore_win32_handle ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(timeline)", //
vk->external.timeline_semaphore_win32_handle ? "true" : "false"); //
#else
#error "Need port for fence sync handles checkers"
#endif
@ -339,22 +314,6 @@ fill_in_external_object_properties(struct vk_bundle *vk)
*
*/
static void
vk_print_device_info_debug(struct vk_bundle *vk, VkPhysicalDeviceProperties *pdp, uint32_t gpu_index, const char *title)
{
VK_DEBUG(vk,
"%s"
"\tname: %s\n"
"\tvendor: 0x%04x\n"
"\tproduct: 0x%04x\n"
"\tapiVersion: %u.%u.%u\n"
"\tdriverVersion: %u.%u.%u",
title, pdp->deviceName, pdp->vendorID, pdp->deviceID, VK_VERSION_MAJOR(pdp->apiVersion),
VK_VERSION_MINOR(pdp->apiVersion), VK_VERSION_PATCH(pdp->apiVersion),
VK_VERSION_MAJOR(pdp->driverVersion), VK_VERSION_MINOR(pdp->driverVersion),
VK_VERSION_PATCH(pdp->driverVersion));
}
static VkResult
select_physical_device(struct vk_bundle *vk, int forced_index)
{
@ -397,7 +356,7 @@ select_physical_device(struct vk_bundle *vk, int forced_index)
char title[20];
snprintf(title, 20, "GPU index %d\n", i);
vk_print_device_info_debug(vk, &pdp, i, title);
vk_print_device_info(vk, U_LOGGING_DEBUG, &pdp, i, title);
if (pdp.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) {
gpu_index = i;
@ -413,7 +372,7 @@ select_physical_device(struct vk_bundle *vk, int forced_index)
char title[20];
snprintf(title, 20, "Selected GPU: %d\n", gpu_index);
vk_print_device_info_debug(vk, &pdp, gpu_index, title);
vk_print_device_info(vk, U_LOGGING_DEBUG, &pdp, gpu_index, title);
char *tegra_substr = strstr(pdp.deviceName, "Tegra");
if (tegra_substr) {

View file

@ -437,6 +437,33 @@ vk_has_error(VkResult res, const char *fun, const char *file, int line);
} while (0)
/*
*
* Printing helpers, in the vk_print.c file.
*
*/
/*!
* Print device information to the logger at the given logging level,
* if the vk_bundle has that level enabled.
*
* @ingroup aux_vk
*/
void
vk_print_device_info(struct vk_bundle *vk,
enum u_logging_level log_level,
VkPhysicalDeviceProperties *pdp,
uint32_t gpu_index,
const char *title);
/*!
* Print external handle features to the logger at the given logging level,
* if the vk_bundle has that level enabled.
*/
void
vk_print_external_handles_info(struct vk_bundle *vk, enum u_logging_level log_level);
/*
*
* Struct init functions, in the vk_function_loaders.c file.

View file

@ -0,0 +1,76 @@
// Copyright 2019-2022, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Prining helper code.
*
* @author Jakob Bornecrantz <jakob@collabora.com>
* @author Christoph Haag <christoph.haag@collabora.com>
* @ingroup aux_vk
*/
#include "vk/vk_helpers.h"
void
vk_print_device_info(struct vk_bundle *vk,
enum u_logging_level log_level,
VkPhysicalDeviceProperties *pdp,
uint32_t gpu_index,
const char *title)
{
U_LOG_IFL(log_level, vk->log_level,
"%s"
"\tname: %s\n"
"\tvendor: 0x%04x\n"
"\tproduct: 0x%04x\n"
"\tapiVersion: %u.%u.%u\n"
"\tdriverVersion: %u.%u.%u",
title, pdp->deviceName, pdp->vendorID, pdp->deviceID, VK_VERSION_MAJOR(pdp->apiVersion),
VK_VERSION_MINOR(pdp->apiVersion), VK_VERSION_PATCH(pdp->apiVersion),
VK_VERSION_MAJOR(pdp->driverVersion), VK_VERSION_MINOR(pdp->driverVersion),
VK_VERSION_PATCH(pdp->driverVersion));
}
void
vk_print_external_handles_info(struct vk_bundle *vk, enum u_logging_level log_level)
{
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
U_LOG_IFL(log_level, vk->log_level, //
"Supported fences:\n\t%s: %s\n\t%s: %s", //
"VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT", //
vk->external.fence_sync_fd ? "true" : "false", //
"VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT", //
vk->external.fence_opaque_fd ? "true" : "false"); //
U_LOG_IFL(log_level, vk->log_level, //
"Supported semaphores:\n\t%s: %s\n\t%s: %s\n\t%s: %s\n\t%s: %s\n\t%s: %s", //
"features.timeline_semaphore", vk->features.timeline_semaphore ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT(binary)", //
vk->external.binary_semaphore_sync_fd ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT(binary)", //
vk->external.binary_semaphore_opaque_fd ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT(timeline)", //
vk->external.timeline_semaphore_sync_fd ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT(timeline)", //
vk->external.timeline_semaphore_opaque_fd ? "true" : "false"); //
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
U_LOG_IFL(log_level, vk->log_level, //
"Supported fences:\n\t%s: %s", //
"VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT", //
vk->external.fence_win32_handle ? "true" : "false"); //
U_LOG_IFL(log_level, vk->log_level, //
"Supported semaphores:\n\t%s: %s\n\t%s: %s", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(binary)", //
vk->external.binary_semaphore_win32_handle ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(timeline)", //
vk->external.timeline_semaphore_win32_handle ? "true" : "false"); //
#else
#error "Need port for fence sync handles printers"
#endif
}

View file

@ -217,6 +217,9 @@ create_device(struct vk_bundle *vk, const struct comp_vulkan_arguments *vk_args)
return ret;
}
// Now that we are done debug some used external handles.
vk_print_external_handles_info(vk, U_LOGGING_INFO);
return VK_SUCCESS;
}