Skip to content

Commit

Permalink
More informative Error message on Vulkan driver crash
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Megamouse committed Jan 31, 2021
1 parent be26810 commit 9feb92d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion rpcs3/Emu/RSX/VK/vkutils/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions rpcs3/Emu/RSX/VK/vkutils/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion rpcs3/Emu/RSX/VK/vkutils/shared.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once

#include "../VulkanAPI.h"
#include <string>

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(),
Expand Down

0 comments on commit 9feb92d

Please sign in to comment.