diff options
| author | Léo Lam <leo@leolam.fr> | 2020-11-12 14:51:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-12 14:51:28 +0100 |
| commit | 8a621c2d5e7722de5148a0a40d4072445cffb361 (patch) | |
| tree | 99878aba6ea4a45ff473092a7f9b8d1db7892ced /Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | |
| parent | ec5313fe24fe0b301603466c12f402fc08605813 (diff) | |
| parent | 21dd7a8ebb23ab05373ab65558a7a47927f402f1 (diff) | |
Merge pull request #9236 from lioncash/log-backend
VideoBackends: Migrate logging over to fmt
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/VulkanContext.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index 5ac43e3250..e9e1f41328 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -156,7 +156,7 @@ bool VulkanContext::SelectInstanceExtensions(std::vector<const char*>* extension 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; } @@ -166,7 +166,7 @@ bool VulkanContext::SelectInstanceExtensions(std::vector<const char*>* extension ASSERT(res == VK_SUCCESS); 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) { 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); }) != available_extension_list.end()) { - INFO_LOG(VIDEO, "Enabling extension: %s", name); + INFO_LOG_FMT(VIDEO, "Enabling extension: {}", name); extension_list->push_back(name); return true; } if (required) - ERROR_LOG(VIDEO, "Vulkan: Missing required extension %s.", name); + ERROR_LOG_FMT(VIDEO, "Vulkan: Missing required extension {}.", name); return false; }; @@ -220,7 +220,7 @@ bool VulkanContext::SelectInstanceExtensions(std::vector<const char*>* extension // VK_EXT_debug_report 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_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false); @@ -437,7 +437,7 @@ bool VulkanContext::SelectDeviceExtensions(bool enable_surface) 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; } @@ -447,7 +447,7 @@ bool VulkanContext::SelectDeviceExtensions(bool enable_surface) ASSERT(res == VK_SUCCESS); 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) { 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); }) != available_extension_list.end()) { - INFO_LOG(VIDEO, "Enabling extension: %s", name); + INFO_LOG_FMT(VIDEO, "Enabling extension: {}", name); m_device_extensions.push_back(name); return true; } if (required) - ERROR_LOG(VIDEO, "Vulkan: Missing required extension %s.", name); + ERROR_LOG_FMT(VIDEO, "Vulkan: Missing required extension {}.", name); return false; }; @@ -472,7 +472,7 @@ bool VulkanContext::SelectDeviceExtensions(bool enable_surface) #ifdef SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN // VK_EXT_full_screen_exclusive 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 return true; @@ -488,12 +488,14 @@ bool VulkanContext::SelectDeviceFeatures() // Not having geometry shaders or wide lines will cause issues with rendering. 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) - 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) - 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. m_device_features.dualSrcBlend = available_features.dualSrcBlend; 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); 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; } std::vector<VkQueueFamilyProperties> queue_family_properties(queue_family_count); vkGetPhysicalDeviceQueueFamilyProperties(m_physical_device, &queue_family_count, 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. 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) { - 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; } 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; } @@ -666,16 +668,16 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT const char* pLayerPrefix, const char* pMessage, void* pUserData) { - std::string log_message = - StringFromFormat("Vulkan debug report: (%s) %s", pLayerPrefix ? pLayerPrefix : "", pMessage); + const std::string log_message = + fmt::format("Vulkan debug report: ({}) {}", pLayerPrefix ? pLayerPrefix : "", pMessage); 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)) - 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) - 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 - 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; } @@ -763,13 +765,13 @@ u32 VulkanContext::GetUploadMemoryType(u32 bits, bool* is_coherent) type_index = GetMemoryType(bits, COHERENT_FLAGS, false, is_coherent); if (type_index) { - WARN_LOG(VIDEO, - "Strict check for upload memory properties failed, this may affect performance"); + WARN_LOG_FMT(VIDEO, + "Strict check for upload memory properties failed, this may affect performance"); return type_index.value(); } // Fall back to non-coherent memory. - WARN_LOG( + WARN_LOG_FMT( VIDEO, "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); @@ -811,8 +813,8 @@ u32 VulkanContext::GetReadbackMemoryType(u32 bits, bool* is_coherent) if (type_index) return type_index.value(); - WARN_LOG(VIDEO, "Vulkan: Failed to find a cached memory type for readbacks, this will affect " - "performance."); + WARN_LOG_FMT(VIDEO, "Vulkan: Failed to find a cached memory type for readbacks, this will affect " + "performance."); type_index = GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, false, is_coherent); *is_coherent = false; if (type_index) @@ -896,8 +898,8 @@ void VulkanContext::InitDriverDetails() } else { - WARN_LOG(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, "Unknown Vulkan driver vendor, please report it to us."); + WARN_LOG_FMT(VIDEO, "Vendor ID: {:#X}, Device Name: {}", vendor_id, device_name); vendor = DriverDetails::VENDOR_UNKNOWN; driver = DriverDetails::DRIVER_UNKNOWN; } |
