Vulkan: Migrate logging over to fmt

Migrates the vulkan backend over to the fmt-capable logger.
This commit is contained in:
Lioncash 2020-11-09 03:26:14 -05:00
parent 23a8baa605
commit 21dd7a8ebb
11 changed files with 81 additions and 79 deletions

View File

@ -34,7 +34,7 @@ bool BoundingBox::Initialize()
{ {
if (!g_ActiveConfig.backend_info.bSupportsBBox) if (!g_ActiveConfig.backend_info.bSupportsBBox)
{ {
WARN_LOG(VIDEO, "Vulkan: Bounding box is unsupported by your device."); WARN_LOG_FMT(VIDEO, "Vulkan: Bounding box is unsupported by your device.");
return true; return true;
} }

View File

@ -543,7 +543,7 @@ bool ObjectCache::ValidatePipelineCache(const u8* data, size_t data_length)
{ {
if (data_length < sizeof(VK_PIPELINE_CACHE_HEADER)) if (data_length < sizeof(VK_PIPELINE_CACHE_HEADER))
{ {
ERROR_LOG(VIDEO, "Pipeline cache failed validation: Invalid header"); ERROR_LOG_FMT(VIDEO, "Pipeline cache failed validation: Invalid header");
return false; return false;
} }
@ -551,36 +551,36 @@ bool ObjectCache::ValidatePipelineCache(const u8* data, size_t data_length)
std::memcpy(&header, data, sizeof(header)); std::memcpy(&header, data, sizeof(header));
if (header.header_length < sizeof(VK_PIPELINE_CACHE_HEADER)) if (header.header_length < sizeof(VK_PIPELINE_CACHE_HEADER))
{ {
ERROR_LOG(VIDEO, "Pipeline cache failed validation: Invalid header length"); ERROR_LOG_FMT(VIDEO, "Pipeline cache failed validation: Invalid header length");
return false; return false;
} }
if (header.header_version != VK_PIPELINE_CACHE_HEADER_VERSION_ONE) if (header.header_version != VK_PIPELINE_CACHE_HEADER_VERSION_ONE)
{ {
ERROR_LOG(VIDEO, "Pipeline cache failed validation: Invalid header version"); ERROR_LOG_FMT(VIDEO, "Pipeline cache failed validation: Invalid header version");
return false; return false;
} }
if (header.vendor_id != g_vulkan_context->GetDeviceProperties().vendorID) if (header.vendor_id != g_vulkan_context->GetDeviceProperties().vendorID)
{ {
ERROR_LOG(VIDEO, ERROR_LOG_FMT(
"Pipeline cache failed validation: Incorrect vendor ID (file: 0x%X, device: 0x%X)", VIDEO, "Pipeline cache failed validation: Incorrect vendor ID (file: {:#X}, device: {:#X})",
header.vendor_id, g_vulkan_context->GetDeviceProperties().vendorID); header.vendor_id, g_vulkan_context->GetDeviceProperties().vendorID);
return false; return false;
} }
if (header.device_id != g_vulkan_context->GetDeviceProperties().deviceID) if (header.device_id != g_vulkan_context->GetDeviceProperties().deviceID)
{ {
ERROR_LOG(VIDEO, ERROR_LOG_FMT(
"Pipeline cache failed validation: Incorrect device ID (file: 0x%X, device: 0x%X)", VIDEO, "Pipeline cache failed validation: Incorrect device ID (file: {:#X}, device: {:#X})",
header.device_id, g_vulkan_context->GetDeviceProperties().deviceID); header.device_id, g_vulkan_context->GetDeviceProperties().deviceID);
return false; return false;
} }
if (std::memcmp(header.uuid, g_vulkan_context->GetDeviceProperties().pipelineCacheUUID, if (std::memcmp(header.uuid, g_vulkan_context->GetDeviceProperties().pipelineCacheUUID,
VK_UUID_SIZE) != 0) VK_UUID_SIZE) != 0)
{ {
ERROR_LOG(VIDEO, "Pipeline cache failed validation: Incorrect UUID"); ERROR_LOG_FMT(VIDEO, "Pipeline cache failed validation: Incorrect UUID");
return false; return false;
} }

View File

@ -300,17 +300,17 @@ void Renderer::BindBackbuffer(const ClearColor& clear_color)
if (res == VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT) if (res == VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT)
{ {
// The present keeps returning exclusive mode lost unless we re-create the swap chain. // The present keeps returning exclusive mode lost unless we re-create the swap chain.
INFO_LOG(VIDEO, "Lost exclusive fullscreen."); INFO_LOG_FMT(VIDEO, "Lost exclusive fullscreen.");
m_swap_chain->RecreateSwapChain(); m_swap_chain->RecreateSwapChain();
} }
else if (res == VK_SUBOPTIMAL_KHR || res == VK_ERROR_OUT_OF_DATE_KHR) else if (res == VK_SUBOPTIMAL_KHR || res == VK_ERROR_OUT_OF_DATE_KHR)
{ {
INFO_LOG(VIDEO, "Resizing swap chain due to suboptimal/out-of-date"); INFO_LOG_FMT(VIDEO, "Resizing swap chain due to suboptimal/out-of-date");
m_swap_chain->ResizeSwapChain(); m_swap_chain->ResizeSwapChain();
} }
else else
{ {
ERROR_LOG(VIDEO, "Unknown present error 0x%08X, please report.", res); ERROR_LOG_FMT(VIDEO, "Unknown present error {:#010X}, please report.", res);
m_swap_chain->RecreateSwapChain(); m_swap_chain->RecreateSwapChain();
} }
@ -401,7 +401,7 @@ void Renderer::CheckForSurfaceResize()
// CheckForSurfaceChange should handle this case. // CheckForSurfaceChange should handle this case.
if (!m_swap_chain) if (!m_swap_chain)
{ {
WARN_LOG(VIDEO, "Surface resize event received without active surface, ignoring"); WARN_LOG_FMT(VIDEO, "Surface resize event received without active surface, ignoring");
return; return;
} }
@ -527,7 +527,7 @@ void Renderer::SetTexture(u32 index, const AbstractTexture* texture)
{ {
if (StateTracker::GetInstance()->InRenderPass()) if (StateTracker::GetInstance()->InRenderPass())
{ {
WARN_LOG(VIDEO, "Transitioning image in render pass in Renderer::SetTexture()"); WARN_LOG_FMT(VIDEO, "Transitioning image in render pass in Renderer::SetTexture()");
StateTracker::GetInstance()->EndRenderPass(); StateTracker::GetInstance()->EndRenderPass();
} }
@ -553,7 +553,7 @@ void Renderer::SetSamplerState(u32 index, const SamplerState& state)
VkSampler sampler = g_object_cache->GetSampler(state); VkSampler sampler = g_object_cache->GetSampler(state);
if (sampler == VK_NULL_HANDLE) if (sampler == VK_NULL_HANDLE)
{ {
ERROR_LOG(VIDEO, "Failed to create sampler"); ERROR_LOG_FMT(VIDEO, "Failed to create sampler");
sampler = g_object_cache->GetPointSampler(); sampler = g_object_cache->GetPointSampler();
} }

View File

@ -203,16 +203,16 @@ static std::optional<SPIRVCodeVector> CompileShaderToSPV(EShLanguage stage,
// Temporary: skip if it contains "Warning, version 450 is not yet complete; most version-specific // Temporary: skip if it contains "Warning, version 450 is not yet complete; most version-specific
// features are present, but some are missing." // features are present, but some are missing."
if (strlen(shader->getInfoLog()) > 108) if (strlen(shader->getInfoLog()) > 108)
WARN_LOG(VIDEO, "Shader info log: %s", shader->getInfoLog()); WARN_LOG_FMT(VIDEO, "Shader info log: {}", shader->getInfoLog());
if (strlen(shader->getInfoDebugLog()) > 0) if (strlen(shader->getInfoDebugLog()) > 0)
WARN_LOG(VIDEO, "Shader debug info log: %s", shader->getInfoDebugLog()); WARN_LOG_FMT(VIDEO, "Shader debug info log: {}", shader->getInfoDebugLog());
if (strlen(program->getInfoLog()) > 25) if (strlen(program->getInfoLog()) > 25)
WARN_LOG(VIDEO, "Program info log: %s", program->getInfoLog()); WARN_LOG_FMT(VIDEO, "Program info log: {}", program->getInfoLog());
if (strlen(program->getInfoDebugLog()) > 0) if (strlen(program->getInfoDebugLog()) > 0)
WARN_LOG(VIDEO, "Program debug info log: %s", program->getInfoDebugLog()); WARN_LOG_FMT(VIDEO, "Program debug info log: {}", program->getInfoDebugLog());
std::string spv_messages = logger.getAllMessages(); const std::string spv_messages = logger.getAllMessages();
if (!spv_messages.empty()) if (!spv_messages.empty())
WARN_LOG(VIDEO, "SPIR-V conversion messages: %s", spv_messages.c_str()); WARN_LOG_FMT(VIDEO, "SPIR-V conversion messages: {}", spv_messages);
// Dump source code of shaders out to file if enabled. // Dump source code of shaders out to file if enabled.
if (g_ActiveConfig.iLog & CONF_SAVESHADERS) if (g_ActiveConfig.iLog & CONF_SAVESHADERS)

View File

@ -351,12 +351,12 @@ bool StateTracker::Bind()
if (!UpdateDescriptorSet()) if (!UpdateDescriptorSet())
{ {
// We can fail to allocate descriptors if we exhaust the pool for this command buffer. // We can fail to allocate descriptors if we exhaust the pool for this command buffer.
WARN_LOG(VIDEO, "Failed to get a descriptor set, executing buffer"); WARN_LOG_FMT(VIDEO, "Failed to get a descriptor set, executing buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false, false); Renderer::GetInstance()->ExecuteCommandBuffer(false, false);
if (!UpdateDescriptorSet()) if (!UpdateDescriptorSet())
{ {
// Something strange going on. // Something strange going on.
ERROR_LOG(VIDEO, "Failed to get descriptor set, skipping draw"); ERROR_LOG_FMT(VIDEO, "Failed to get descriptor set, skipping draw");
return false; return false;
} }
} }
@ -405,12 +405,12 @@ bool StateTracker::BindCompute()
if (!UpdateComputeDescriptorSet()) if (!UpdateComputeDescriptorSet())
{ {
WARN_LOG(VIDEO, "Failed to get a compute descriptor set, executing buffer"); WARN_LOG_FMT(VIDEO, "Failed to get a compute descriptor set, executing buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false, false); Renderer::GetInstance()->ExecuteCommandBuffer(false, false);
if (!UpdateComputeDescriptorSet()) if (!UpdateComputeDescriptorSet())
{ {
// Something strange going on. // Something strange going on.
ERROR_LOG(VIDEO, "Failed to get descriptor set, skipping dispatch"); ERROR_LOG_FMT(VIDEO, "Failed to get descriptor set, skipping dispatch");
return false; return false;
} }
} }

View File

@ -283,7 +283,7 @@ bool SwapChain::CreateSwapChain()
VkImageUsageFlags image_usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; VkImageUsageFlags image_usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
if (!(surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)) if (!(surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT))
{ {
ERROR_LOG(VIDEO, "Vulkan: Swap chain does not support usage as color attachment"); ERROR_LOG_FMT(VIDEO, "Vulkan: Swap chain does not support usage as color attachment");
return false; return false;
} }
@ -341,7 +341,7 @@ bool SwapChain::CreateSwapChain()
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
{ {
// Try without exclusive fullscreen. // Try without exclusive fullscreen.
WARN_LOG(VIDEO, "Failed to create exclusive fullscreen swapchain, trying without."); WARN_LOG_FMT(VIDEO, "Failed to create exclusive fullscreen swapchain, trying without.");
swap_chain_info.pNext = nullptr; swap_chain_info.pNext = nullptr;
g_Config.backend_info.bSupportsExclusiveFullscreen = false; g_Config.backend_info.bSupportsExclusiveFullscreen = false;
g_ActiveConfig.backend_info.bSupportsExclusiveFullscreen = false; g_ActiveConfig.backend_info.bSupportsExclusiveFullscreen = false;
@ -514,7 +514,7 @@ bool SwapChain::SetFullscreenState(bool state)
return false; return false;
} }
INFO_LOG(VIDEO, "Exclusive fullscreen acquired."); INFO_LOG_FMT(VIDEO, "Exclusive fullscreen acquired.");
} }
else else
{ {
@ -522,7 +522,7 @@ bool SwapChain::SetFullscreenState(bool state)
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
LOG_VULKAN_ERROR(res, "vkReleaseFullScreenExclusiveModeEXT failed:"); LOG_VULKAN_ERROR(res, "vkReleaseFullScreenExclusiveModeEXT failed:");
INFO_LOG(VIDEO, "Exclusive fullscreen released."); INFO_LOG_FMT(VIDEO, "Exclusive fullscreen released.");
} }
m_current_fullscreen_state = state; m_current_fullscreen_state = state;

View File

@ -369,7 +369,8 @@ void VKTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
if (!stream_buffer->ReserveMemory(upload_size, upload_alignment)) if (!stream_buffer->ReserveMemory(upload_size, upload_alignment))
{ {
// Execute the command buffer first. // Execute the command buffer first.
WARN_LOG(VIDEO, "Executing command list while waiting for space in texture upload buffer"); WARN_LOG_FMT(VIDEO,
"Executing command list while waiting for space in texture upload buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false); Renderer::GetInstance()->ExecuteCommandBuffer(false);
// Try allocating again. This may cause a fence wait. // Try allocating again. This may cause a fence wait.

View File

@ -149,7 +149,7 @@ void VertexManager::ResetBuffer(u32 vertex_stride)
if (!has_vbuffer_allocation || !has_ibuffer_allocation) if (!has_vbuffer_allocation || !has_ibuffer_allocation)
{ {
// Flush any pending commands first, so that we can wait on the fences // Flush any pending commands first, so that we can wait on the fences
WARN_LOG(VIDEO, "Executing command list while waiting for space in vertex/index buffer"); WARN_LOG_FMT(VIDEO, "Executing command list while waiting for space in vertex/index buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false); Renderer::GetInstance()->ExecuteCommandBuffer(false);
// Attempt to allocate again, this may cause a fence wait // Attempt to allocate again, this may cause a fence wait
@ -253,7 +253,7 @@ bool VertexManager::ReserveConstantStorage()
} }
// The only places that call constant updates are safe to have state restored. // The only places that call constant updates are safe to have state restored.
WARN_LOG(VIDEO, "Executing command buffer while waiting for space in uniform buffer"); WARN_LOG_FMT(VIDEO, "Executing command buffer while waiting for space in uniform buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false); Renderer::GetInstance()->ExecuteCommandBuffer(false);
// Since we are on a new command buffer, all constants have been invalidated, and we need // Since we are on a new command buffer, all constants have been invalidated, and we need
@ -319,7 +319,7 @@ void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size)
if (!m_uniform_stream_buffer->ReserveMemory(data_size, if (!m_uniform_stream_buffer->ReserveMemory(data_size,
g_vulkan_context->GetUniformBufferAlignment())) g_vulkan_context->GetUniformBufferAlignment()))
{ {
WARN_LOG(VIDEO, "Executing command buffer while waiting for ext space in uniform buffer"); WARN_LOG_FMT(VIDEO, "Executing command buffer while waiting for ext space in uniform buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false); Renderer::GetInstance()->ExecuteCommandBuffer(false);
} }
@ -340,7 +340,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
if (!m_texel_stream_buffer->ReserveMemory(data_size, elem_size)) if (!m_texel_stream_buffer->ReserveMemory(data_size, elem_size))
{ {
// Try submitting cmdbuffer. // Try submitting cmdbuffer.
WARN_LOG(VIDEO, "Submitting command buffer while waiting for space in texel buffer"); WARN_LOG_FMT(VIDEO, "Submitting command buffer while waiting for space in texel buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false, false); Renderer::GetInstance()->ExecuteCommandBuffer(false, false);
if (!m_texel_stream_buffer->ReserveMemory(data_size, elem_size)) if (!m_texel_stream_buffer->ReserveMemory(data_size, elem_size))
{ {
@ -370,7 +370,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
if (!m_texel_stream_buffer->ReserveMemory(reserve_size, elem_size)) if (!m_texel_stream_buffer->ReserveMemory(reserve_size, elem_size))
{ {
// Try submitting cmdbuffer. // Try submitting cmdbuffer.
WARN_LOG(VIDEO, "Submitting command buffer while waiting for space in texel buffer"); WARN_LOG_FMT(VIDEO, "Submitting command buffer while waiting for space in texel buffer");
Renderer::GetInstance()->ExecuteCommandBuffer(false, false); Renderer::GetInstance()->ExecuteCommandBuffer(false, false);
if (!m_texel_stream_buffer->ReserveMemory(reserve_size, elem_size)) if (!m_texel_stream_buffer->ReserveMemory(reserve_size, elem_size))
{ {

View File

@ -156,7 +156,7 @@ bool VulkanContext::SelectInstanceExtensions(std::vector<const char*>* extension
if (extension_count == 0) if (extension_count == 0)
{ {
ERROR_LOG(VIDEO, "Vulkan: No extensions supported by instance."); ERROR_LOG_FMT(VIDEO, "Vulkan: No extensions supported by instance.");
return false; return false;
} }
@ -166,7 +166,7 @@ bool VulkanContext::SelectInstanceExtensions(std::vector<const char*>* extension
ASSERT(res == VK_SUCCESS); ASSERT(res == VK_SUCCESS);
for (const auto& extension_properties : available_extension_list) for (const auto& extension_properties : available_extension_list)
INFO_LOG(VIDEO, "Available extension: %s", extension_properties.extensionName); INFO_LOG_FMT(VIDEO, "Available extension: {}", extension_properties.extensionName);
auto AddExtension = [&](const char* name, bool required) { auto AddExtension = [&](const char* name, bool required) {
if (std::find_if(available_extension_list.begin(), available_extension_list.end(), if (std::find_if(available_extension_list.begin(), available_extension_list.end(),
@ -174,13 +174,13 @@ bool VulkanContext::SelectInstanceExtensions(std::vector<const char*>* extension
return !strcmp(name, properties.extensionName); return !strcmp(name, properties.extensionName);
}) != available_extension_list.end()) }) != available_extension_list.end())
{ {
INFO_LOG(VIDEO, "Enabling extension: %s", name); INFO_LOG_FMT(VIDEO, "Enabling extension: {}", name);
extension_list->push_back(name); extension_list->push_back(name);
return true; return true;
} }
if (required) if (required)
ERROR_LOG(VIDEO, "Vulkan: Missing required extension %s.", name); ERROR_LOG_FMT(VIDEO, "Vulkan: Missing required extension {}.", name);
return false; return false;
}; };
@ -220,7 +220,7 @@ bool VulkanContext::SelectInstanceExtensions(std::vector<const char*>* extension
// VK_EXT_debug_report // VK_EXT_debug_report
if (enable_debug_report && !AddExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, false)) if (enable_debug_report && !AddExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, false))
WARN_LOG(VIDEO, "Vulkan: Debug report requested, but extension is not available."); WARN_LOG_FMT(VIDEO, "Vulkan: Debug report requested, but extension is not available.");
AddExtension(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, false); AddExtension(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, false);
AddExtension(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false); AddExtension(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false);
@ -437,7 +437,7 @@ bool VulkanContext::SelectDeviceExtensions(bool enable_surface)
if (extension_count == 0) if (extension_count == 0)
{ {
ERROR_LOG(VIDEO, "Vulkan: No extensions supported by device."); ERROR_LOG_FMT(VIDEO, "Vulkan: No extensions supported by device.");
return false; return false;
} }
@ -447,7 +447,7 @@ bool VulkanContext::SelectDeviceExtensions(bool enable_surface)
ASSERT(res == VK_SUCCESS); ASSERT(res == VK_SUCCESS);
for (const auto& extension_properties : available_extension_list) for (const auto& extension_properties : available_extension_list)
INFO_LOG(VIDEO, "Available extension: %s", extension_properties.extensionName); INFO_LOG_FMT(VIDEO, "Available extension: {}", extension_properties.extensionName);
auto AddExtension = [&](const char* name, bool required) { auto AddExtension = [&](const char* name, bool required) {
if (std::find_if(available_extension_list.begin(), available_extension_list.end(), if (std::find_if(available_extension_list.begin(), available_extension_list.end(),
@ -455,13 +455,13 @@ bool VulkanContext::SelectDeviceExtensions(bool enable_surface)
return !strcmp(name, properties.extensionName); return !strcmp(name, properties.extensionName);
}) != available_extension_list.end()) }) != available_extension_list.end())
{ {
INFO_LOG(VIDEO, "Enabling extension: %s", name); INFO_LOG_FMT(VIDEO, "Enabling extension: {}", name);
m_device_extensions.push_back(name); m_device_extensions.push_back(name);
return true; return true;
} }
if (required) if (required)
ERROR_LOG(VIDEO, "Vulkan: Missing required extension %s.", name); ERROR_LOG_FMT(VIDEO, "Vulkan: Missing required extension {}.", name);
return false; return false;
}; };
@ -472,7 +472,7 @@ bool VulkanContext::SelectDeviceExtensions(bool enable_surface)
#ifdef SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN #ifdef SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN
// VK_EXT_full_screen_exclusive // VK_EXT_full_screen_exclusive
if (AddExtension(VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME, true)) if (AddExtension(VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME, true))
INFO_LOG(VIDEO, "Using VK_EXT_full_screen_exclusive for exclusive fullscreen."); INFO_LOG_FMT(VIDEO, "Using VK_EXT_full_screen_exclusive for exclusive fullscreen.");
#endif #endif
return true; return true;
@ -488,12 +488,14 @@ bool VulkanContext::SelectDeviceFeatures()
// Not having geometry shaders or wide lines will cause issues with rendering. // Not having geometry shaders or wide lines will cause issues with rendering.
if (!available_features.geometryShader && !available_features.wideLines) if (!available_features.geometryShader && !available_features.wideLines)
WARN_LOG(VIDEO, "Vulkan: Missing both geometryShader and wideLines features."); WARN_LOG_FMT(VIDEO, "Vulkan: Missing both geometryShader and wideLines features.");
if (!available_features.largePoints) if (!available_features.largePoints)
WARN_LOG(VIDEO, "Vulkan: Missing large points feature. CPU EFB writes will be slower."); WARN_LOG_FMT(VIDEO, "Vulkan: Missing large points feature. CPU EFB writes will be slower.");
if (!available_features.occlusionQueryPrecise) if (!available_features.occlusionQueryPrecise)
WARN_LOG(VIDEO, "Vulkan: Missing precise occlusion queries. Perf queries will be inaccurate."); {
WARN_LOG_FMT(VIDEO,
"Vulkan: Missing precise occlusion queries. Perf queries will be inaccurate.");
}
// Enable the features we use. // Enable the features we use.
m_device_features.dualSrcBlend = available_features.dualSrcBlend; m_device_features.dualSrcBlend = available_features.dualSrcBlend;
m_device_features.geometryShader = available_features.geometryShader; m_device_features.geometryShader = available_features.geometryShader;
@ -519,14 +521,14 @@ bool VulkanContext::CreateDevice(VkSurfaceKHR surface, bool enable_validation_la
vkGetPhysicalDeviceQueueFamilyProperties(m_physical_device, &queue_family_count, nullptr); vkGetPhysicalDeviceQueueFamilyProperties(m_physical_device, &queue_family_count, nullptr);
if (queue_family_count == 0) if (queue_family_count == 0)
{ {
ERROR_LOG(VIDEO, "No queue families found on specified vulkan physical device."); ERROR_LOG_FMT(VIDEO, "No queue families found on specified vulkan physical device.");
return false; return false;
} }
std::vector<VkQueueFamilyProperties> queue_family_properties(queue_family_count); std::vector<VkQueueFamilyProperties> queue_family_properties(queue_family_count);
vkGetPhysicalDeviceQueueFamilyProperties(m_physical_device, &queue_family_count, vkGetPhysicalDeviceQueueFamilyProperties(m_physical_device, &queue_family_count,
queue_family_properties.data()); queue_family_properties.data());
INFO_LOG(VIDEO, "%u vulkan queue families", queue_family_count); INFO_LOG_FMT(VIDEO, "{} vulkan queue families", queue_family_count);
// Find graphics and present queues. // Find graphics and present queues.
m_graphics_queue_family_index = queue_family_count; m_graphics_queue_family_index = queue_family_count;
@ -569,12 +571,12 @@ bool VulkanContext::CreateDevice(VkSurfaceKHR surface, bool enable_validation_la
} }
if (m_graphics_queue_family_index == queue_family_count) if (m_graphics_queue_family_index == queue_family_count)
{ {
ERROR_LOG(VIDEO, "Vulkan: Failed to find an acceptable graphics queue."); ERROR_LOG_FMT(VIDEO, "Vulkan: Failed to find an acceptable graphics queue.");
return false; return false;
} }
if (surface && m_present_queue_family_index == queue_family_count) if (surface && m_present_queue_family_index == queue_family_count)
{ {
ERROR_LOG(VIDEO, "Vulkan: Failed to find an acceptable present queue."); ERROR_LOG_FMT(VIDEO, "Vulkan: Failed to find an acceptable present queue.");
return false; return false;
} }
@ -666,16 +668,16 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT
const char* pLayerPrefix, const char* pLayerPrefix,
const char* pMessage, void* pUserData) const char* pMessage, void* pUserData)
{ {
std::string log_message = const std::string log_message =
StringFromFormat("Vulkan debug report: (%s) %s", pLayerPrefix ? pLayerPrefix : "", pMessage); fmt::format("Vulkan debug report: ({}) {}", pLayerPrefix ? pLayerPrefix : "", pMessage);
if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT)
GENERIC_LOG(Common::Log::HOST_GPU, Common::Log::LERROR, "%s", log_message.c_str()); GENERIC_LOG_FMT(Common::Log::HOST_GPU, Common::Log::LERROR, "{}", log_message);
else if (flags & (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT)) else if (flags & (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT))
GENERIC_LOG(Common::Log::HOST_GPU, Common::Log::LWARNING, "%s", log_message.c_str()); GENERIC_LOG_FMT(Common::Log::HOST_GPU, Common::Log::LWARNING, "{}", log_message);
else if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) else if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT)
GENERIC_LOG(Common::Log::HOST_GPU, Common::Log::LINFO, "%s", log_message.c_str()); GENERIC_LOG_FMT(Common::Log::HOST_GPU, Common::Log::LINFO, "{}", log_message);
else else
GENERIC_LOG(Common::Log::HOST_GPU, Common::Log::LDEBUG, "%s", log_message.c_str()); GENERIC_LOG_FMT(Common::Log::HOST_GPU, Common::Log::LDEBUG, "{}", log_message);
return VK_FALSE; return VK_FALSE;
} }
@ -763,13 +765,13 @@ u32 VulkanContext::GetUploadMemoryType(u32 bits, bool* is_coherent)
type_index = GetMemoryType(bits, COHERENT_FLAGS, false, is_coherent); type_index = GetMemoryType(bits, COHERENT_FLAGS, false, is_coherent);
if (type_index) if (type_index)
{ {
WARN_LOG(VIDEO, WARN_LOG_FMT(VIDEO,
"Strict check for upload memory properties failed, this may affect performance"); "Strict check for upload memory properties failed, this may affect performance");
return type_index.value(); return type_index.value();
} }
// Fall back to non-coherent memory. // Fall back to non-coherent memory.
WARN_LOG( WARN_LOG_FMT(
VIDEO, VIDEO,
"Vulkan: Failed to find a coherent memory type for uploads, this will affect performance."); "Vulkan: Failed to find a coherent memory type for uploads, this will affect performance.");
type_index = GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, false, is_coherent); type_index = GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, false, is_coherent);
@ -811,8 +813,8 @@ u32 VulkanContext::GetReadbackMemoryType(u32 bits, bool* is_coherent)
if (type_index) if (type_index)
return type_index.value(); return type_index.value();
WARN_LOG(VIDEO, "Vulkan: Failed to find a cached memory type for readbacks, this will affect " WARN_LOG_FMT(VIDEO, "Vulkan: Failed to find a cached memory type for readbacks, this will affect "
"performance."); "performance.");
type_index = GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, false, is_coherent); type_index = GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, false, is_coherent);
*is_coherent = false; *is_coherent = false;
if (type_index) if (type_index)
@ -896,8 +898,8 @@ void VulkanContext::InitDriverDetails()
} }
else else
{ {
WARN_LOG(VIDEO, "Unknown Vulkan driver vendor, please report it to us."); WARN_LOG_FMT(VIDEO, "Unknown Vulkan driver vendor, please report it to us.");
WARN_LOG(VIDEO, "Vendor ID: 0x%X, Device Name: %s", vendor_id, device_name.c_str()); WARN_LOG_FMT(VIDEO, "Vendor ID: {:#X}, Device Name: {}", vendor_id, device_name);
vendor = DriverDetails::VENDOR_UNKNOWN; vendor = DriverDetails::VENDOR_UNKNOWN;
driver = DriverDetails::DRIVER_UNKNOWN; driver = DriverDetails::DRIVER_UNKNOWN;
} }

View File

@ -67,7 +67,7 @@ bool LoadVulkanLibrary()
#define VULKAN_MODULE_ENTRY_POINT(name, required) \ #define VULKAN_MODULE_ENTRY_POINT(name, required) \
if (!s_vulkan_module.GetSymbol(#name, &name) && required) \ if (!s_vulkan_module.GetSymbol(#name, &name) && required) \
{ \ { \
ERROR_LOG(VIDEO, "Vulkan: Failed to load required module function %s", #name); \ ERROR_LOG_FMT(VIDEO, "Vulkan: Failed to load required module function {}", #name); \
ResetVulkanLibraryFunctionPointers(); \ ResetVulkanLibraryFunctionPointers(); \
s_vulkan_module.Close(); \ s_vulkan_module.Close(); \
return false; \ return false; \
@ -92,7 +92,7 @@ bool LoadVulkanInstanceFunctions(VkInstance instance)
*func_ptr = vkGetInstanceProcAddr(instance, name); *func_ptr = vkGetInstanceProcAddr(instance, name);
if (!(*func_ptr) && is_required) if (!(*func_ptr) && is_required)
{ {
ERROR_LOG(VIDEO, "Vulkan: Failed to load required instance function %s", name); ERROR_LOG_FMT(VIDEO, "Vulkan: Failed to load required instance function {}", name);
required_functions_missing = true; required_functions_missing = true;
} }
}; };
@ -112,7 +112,7 @@ bool LoadVulkanDeviceFunctions(VkDevice device)
*func_ptr = vkGetDeviceProcAddr(device, name); *func_ptr = vkGetDeviceProcAddr(device, name);
if (!(*func_ptr) && is_required) if (!(*func_ptr) && is_required)
{ {
ERROR_LOG(VIDEO, "Vulkan: Failed to load required device function %s", name); ERROR_LOG_FMT(VIDEO, "Vulkan: Failed to load required device function {}", name);
required_functions_missing = true; required_functions_missing = true;
} }
}; };
@ -213,11 +213,10 @@ void LogVulkanResult(int level, const char* func_name, VkResult res, const char*
std::string real_msg = StringFromFormatV(msg, ap); std::string real_msg = StringFromFormatV(msg, ap);
va_end(ap); va_end(ap);
real_msg = StringFromFormat("(%s) %s (%d: %s)", func_name, real_msg.c_str(), real_msg = fmt::format("({}) {} ({}: {})", func_name, real_msg, static_cast<int>(res),
static_cast<int>(res), VkResultToString(res)); VkResultToString(res));
GENERIC_LOG(Common::Log::VIDEO, static_cast<Common::Log::LOG_LEVELS>(level), "%s", GENERIC_LOG_FMT(Common::Log::VIDEO, static_cast<Common::Log::LOG_LEVELS>(level), "{}", real_msg);
real_msg.c_str());
} }
} // namespace Vulkan } // namespace Vulkan

View File

@ -106,7 +106,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
bool enable_validation_layer = g_Config.bEnableValidationLayer; bool enable_validation_layer = g_Config.bEnableValidationLayer;
if (enable_validation_layer && !VulkanContext::CheckValidationLayerAvailablility()) if (enable_validation_layer && !VulkanContext::CheckValidationLayerAvailablility())
{ {
WARN_LOG(VIDEO, "Validation layer requested but not available, disabling."); WARN_LOG_FMT(VIDEO, "Validation layer requested but not available, disabling.");
enable_validation_layer = false; enable_validation_layer = false;
} }
@ -166,7 +166,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
size_t selected_adapter_index = static_cast<size_t>(g_Config.iAdapter); size_t selected_adapter_index = static_cast<size_t>(g_Config.iAdapter);
if (selected_adapter_index >= gpu_list.size()) if (selected_adapter_index >= gpu_list.size())
{ {
WARN_LOG(VIDEO, "Vulkan adapter index out of range, selecting first adapter."); WARN_LOG_FMT(VIDEO, "Vulkan adapter index out of range, selecting first adapter.");
selected_adapter_index = 0; selected_adapter_index = 0;
} }
@ -312,7 +312,7 @@ void VideoBackend::PrepareWindow(WindowSystemInfo& wsi)
Class clsCAMetalLayer = objc_getClass("CAMetalLayer"); Class clsCAMetalLayer = objc_getClass("CAMetalLayer");
if (!clsCAMetalLayer) if (!clsCAMetalLayer)
{ {
ERROR_LOG(VIDEO, "Failed to get CAMetalLayer class."); ERROR_LOG_FMT(VIDEO, "Failed to get CAMetalLayer class.");
return; return;
} }
@ -321,7 +321,7 @@ void VideoBackend::PrepareWindow(WindowSystemInfo& wsi)
sel_getUid("layer")); sel_getUid("layer"));
if (!layer) if (!layer)
{ {
ERROR_LOG(VIDEO, "Failed to create Metal layer."); ERROR_LOG_FMT(VIDEO, "Failed to create Metal layer.");
return; return;
} }