Vulkan: Add ghost.vulkan logging
GHOST backend didn't use logging. This PR adds an initial ghost.vulkan logging and improves the reporting of logging in vulkan. logging can be enabled by `blender --log "gpu.vulkan,ghost.vulkan" --log-level 2` it shows the optional extensions that are enabled and information about swap chain events. Pull Request: https://projects.blender.org/blender/blender/pulls/139437
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "vulkan/vk_ghost_api.hh"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <cassert>
|
||||
@@ -37,6 +39,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
static CLG_LogRef LOG = {"ghost.vulkan"};
|
||||
|
||||
static const char *vulkan_error_as_string(VkResult result)
|
||||
{
|
||||
#define FORMAT_ERROR(X) \
|
||||
@@ -92,21 +96,12 @@ static const char *vulkan_error_as_string(VkResult result)
|
||||
do { \
|
||||
VkResult r = (__expression); \
|
||||
if (r != VK_SUCCESS) { \
|
||||
fprintf(stderr, \
|
||||
"Vulkan Error : %s:%d : %s failed with %s\n", \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
__STR(__expression), \
|
||||
vulkan_error_as_string(r)); \
|
||||
CLOG_ERROR( \
|
||||
&LOG, "%s resulted in code %s.", __STR(__expression), vulkan_error_as_string(r)); \
|
||||
return GHOST_kFailure; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_PRINTF(...) \
|
||||
if (m_debug) { \
|
||||
printf(__VA_ARGS__); \
|
||||
}
|
||||
|
||||
/* Check if the given extension name is in the extension_list.
|
||||
*/
|
||||
static bool contains_extension(const vector<VkExtensionProperties> &extension_list,
|
||||
@@ -211,9 +206,14 @@ class GHOST_DeviceVK {
|
||||
vector<VkDeviceQueueCreateInfo> queue_create_infos;
|
||||
vector<const char *> device_extensions(required_extensions);
|
||||
for (const char *optional_extension : optional_extensions) {
|
||||
if (has_extensions({optional_extension})) {
|
||||
const bool extension_found = has_extensions({optional_extension});
|
||||
if (extension_found) {
|
||||
CLOG_INFO(&LOG, 2, "enable optional extension: `%s`", optional_extension);
|
||||
device_extensions.push_back(optional_extension);
|
||||
}
|
||||
else {
|
||||
CLOG_INFO(&LOG, 2, "optional extension not found: `%s`", optional_extension);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the given extension name will be enabled. */
|
||||
@@ -369,8 +369,6 @@ class GHOST_DeviceVK {
|
||||
}
|
||||
generic_queue_family++;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Couldn't find any Graphic queue family on selected device\n");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -474,7 +472,7 @@ static GHOST_TSuccess ensure_vulkan_device(VkInstance vk_instance,
|
||||
}
|
||||
|
||||
if (best_physical_device == VK_NULL_HANDLE) {
|
||||
fprintf(stderr, "Error: No suitable Vulkan Device found!\n");
|
||||
CLOG_ERROR(&LOG, "Error: No suitable Vulkan Device found!");
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
@@ -614,6 +612,7 @@ GHOST_TSuccess GHOST_ContextVK::swapBuffers()
|
||||
recreateSwapchain();
|
||||
}
|
||||
}
|
||||
CLOG_INFO(&LOG, 3, "render_frame=%lu, image_index=%u", m_render_frame, image_index);
|
||||
|
||||
GHOST_VulkanSwapChainData swap_chain_data;
|
||||
swap_chain_data.image = m_swapchain_images[image_index];
|
||||
@@ -651,9 +650,8 @@ GHOST_TSuccess GHOST_ContextVK::swapBuffers()
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
if (present_result != VK_SUCCESS) {
|
||||
fprintf(stderr,
|
||||
"Error: Failed to present swap chain image : %s\n",
|
||||
vulkan_error_as_string(acquire_result));
|
||||
CLOG_ERROR(
|
||||
&LOG, "failed to present swap chain image : %s", vulkan_error_as_string(acquire_result));
|
||||
}
|
||||
|
||||
if (swap_buffers_post_callback_) {
|
||||
@@ -753,7 +751,7 @@ static void requireExtension(const vector<VkExtensionProperties> &extensions_ava
|
||||
extensions_enabled.push_back(extension_name);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Error: %s not found.\n", extension_name);
|
||||
CLOG_ERROR(&LOG, "required extension not found: %s", extension_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -977,6 +975,16 @@ GHOST_TSuccess GHOST_ContextVK::recreateSwapchain()
|
||||
VK_PRESENT_GRAVITY_MAX_BIT_EXT,
|
||||
};
|
||||
|
||||
CLOG_INFO(&LOG,
|
||||
2,
|
||||
"recreating swapchain: width=%u, height=%u, format=%d, colorSpace=%d, "
|
||||
"present_mode=%d, old_swapchain=%lu",
|
||||
m_render_extent.width,
|
||||
m_render_extent.height,
|
||||
m_surface_format.format,
|
||||
m_surface_format.colorSpace,
|
||||
present_mode,
|
||||
uint64_t(old_swapchain));
|
||||
VkSwapchainCreateInfoKHR create_info = {};
|
||||
create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||
if (vulkan_device->use_vk_ext_swapchain_maintenance_1) {
|
||||
@@ -1139,6 +1147,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
|
||||
|
||||
VkInstance instance = VK_NULL_HANDLE;
|
||||
if (!vulkan_device.has_value()) {
|
||||
|
||||
VkApplicationInfo app_info = {};
|
||||
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
app_info.pApplicationName = "Blender";
|
||||
|
||||
@@ -159,7 +159,6 @@ messenger_callback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT *callback_data,
|
||||
void *user_data)
|
||||
{
|
||||
|
||||
CLG_Severity severity = CLG_SEVERITY_INFO;
|
||||
if (message_severity & (VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT))
|
||||
@@ -173,21 +172,18 @@ messenger_callback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
|
||||
severity = CLG_SEVERITY_ERROR;
|
||||
}
|
||||
|
||||
if ((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level <= severity)) {
|
||||
const char *format = "{0x%x}% s\n %s ";
|
||||
CLG_logf(LOG.type,
|
||||
severity,
|
||||
"",
|
||||
"",
|
||||
format,
|
||||
callback_data->messageIdNumber,
|
||||
callback_data->pMessageIdName,
|
||||
callback_data->pMessage);
|
||||
}
|
||||
|
||||
const char *format = "{0x%x}% s\n %s ";
|
||||
CLOG_AT_SEVERITY(&LOG,
|
||||
severity,
|
||||
0,
|
||||
format,
|
||||
callback_data->messageIdNumber,
|
||||
callback_data->pMessageIdName,
|
||||
callback_data->pMessage);
|
||||
const bool do_labels = (callback_data->objectCount + callback_data->cmdBufLabelCount +
|
||||
callback_data->queueLabelCount) > 0;
|
||||
if (do_labels) {
|
||||
const bool log_active = bool(LOG.type->flag & CLG_FLAG_USE) || severity >= CLG_SEVERITY_WARN;
|
||||
if (do_labels && log_active) {
|
||||
VKDebuggingTools &debugging_tools = *reinterpret_cast<VKDebuggingTools *>(user_data);
|
||||
debugging_tools.print_labels(callback_data);
|
||||
}
|
||||
|
||||
@@ -42,14 +42,16 @@ void VKExtensions::log() const
|
||||
" - [%c] dynamic rendering\n"
|
||||
" - [%c] dynamic rendering local read\n"
|
||||
" - [%c] dynamic rendering unused attachments\n"
|
||||
" - [%c] external memory",
|
||||
" - [%c] external memory\n"
|
||||
" - [%c] shader stencil export",
|
||||
shader_output_viewport_index ? 'X' : ' ',
|
||||
shader_output_layer ? 'X' : ' ',
|
||||
fragment_shader_barycentric ? 'X' : ' ',
|
||||
dynamic_rendering ? 'X' : ' ',
|
||||
dynamic_rendering_local_read ? 'X' : ' ',
|
||||
dynamic_rendering_unused_attachments ? 'X' : ' ',
|
||||
external_memory ? 'X' : ' ');
|
||||
external_memory ? 'X' : ' ',
|
||||
GPU_stencil_export_support() ? 'X' : ' ');
|
||||
}
|
||||
|
||||
void VKDevice::reinit()
|
||||
|
||||
Reference in New Issue
Block a user