From 9feb92df1bc2770a4fe69bcc3d25342a789a226d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 29 Jan 2021 00:14:53 +0100 Subject: [PATCH] More informative Error message on Vulkan driver crash The message might not be the only reason, but at least it might help someone like me, who had no idea what he was looking at. --- rpcs3/Emu/RSX/VK/vkutils/device.cpp | 4 +++- rpcs3/Emu/RSX/VK/vkutils/shared.cpp | 5 +++-- rpcs3/Emu/RSX/VK/vkutils/shared.h | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/vkutils/device.cpp b/rpcs3/Emu/RSX/VK/vkutils/device.cpp index 3c3755e4bba5..d8a0c5a8be00 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/device.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/device.cpp @@ -229,6 +229,7 @@ namespace vk // Render Device - The actual usable device void render_device::create(vk::physical_device& pdev, u32 graphics_queue_idx) { + std::string message_on_error; float queue_priorities[1] = { 0.f }; pgpu = &pdev; @@ -287,6 +288,7 @@ namespace vk // TODO: Slow fallback to emulate this // Just warn and let the driver decide whether to crash or not rsx_log.fatal("Your GPU driver does not support some required MSAA features. Expect problems."); + message_on_error += "Your GPU driver does not support some required MSAA features.\nTry updating your GPU driver or disable Anti-Aliasing in the settings."; } enabled_features.sampleRateShading = VK_TRUE; @@ -356,7 +358,7 @@ namespace vk rsx_log.notice("GPU/driver lacks support for float16 data types. All float16_t arithmetic will be emulated with float32_t."); } - CHECK_RESULT(vkCreateDevice(*pgpu, &device, nullptr, &dev)); + CHECK_RESULT_EX(vkCreateDevice(*pgpu, &device, nullptr, &dev), message_on_error); // Import optional function endpoints if (pgpu->conditional_render_support) diff --git a/rpcs3/Emu/RSX/VK/vkutils/shared.cpp b/rpcs3/Emu/RSX/VK/vkutils/shared.cpp index 2a172253ec27..756a99df52b6 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/shared.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/shared.cpp @@ -3,7 +3,7 @@ namespace vk { - void die_with_error(VkResult error_code, + void die_with_error(VkResult error_code, std::string message, const char* file, const char* func, u32 line, @@ -99,7 +99,8 @@ namespace vk { default: case 0: - fmt::throw_exception("Assertion Failed! Vulkan API call failed with unrecoverable error: %s%s", error_message, src_loc{line, col, file, func}); + if (!message.empty()) message += "\n\n"; + fmt::throw_exception("%sAssertion Failed! Vulkan API call failed with unrecoverable error: %s%s", message, error_message, src_loc{line, col, file, func}); case 1: rsx_log.error("Vulkan API call has failed with an error but will continue: %s%s", error_message, src_loc{line, col, file, func}); break; diff --git a/rpcs3/Emu/RSX/VK/vkutils/shared.h b/rpcs3/Emu/RSX/VK/vkutils/shared.h index dd3a590c2501..1400d10b163a 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/shared.h +++ b/rpcs3/Emu/RSX/VK/vkutils/shared.h @@ -1,12 +1,14 @@ #pragma once #include "../VulkanAPI.h" +#include namespace vk { #define CHECK_RESULT(expr) { VkResult _res = (expr); if (_res != VK_SUCCESS) vk::die_with_error(_res); } +#define CHECK_RESULT_EX(expr, msg) { VkResult _res = (expr); if (_res != VK_SUCCESS) vk::die_with_error(_res, msg); } - void die_with_error(VkResult error_code, + void die_with_error(VkResult error_code, std::string message = {}, const char* file = __builtin_FILE(), const char* func = __builtin_FUNCTION(), u32 line = __builtin_LINE(),