Add improved GPU crashes reporting
This commit is contained in:
@@ -180,7 +180,7 @@ void RenderToolsVulkan::SetObjectName(VkDevice device, uint64 objectHandle, VkOb
|
||||
|
||||
String RenderToolsVulkan::GetVkErrorString(VkResult result)
|
||||
{
|
||||
StringBuilder sb(256);
|
||||
StringBuilder sb(64);
|
||||
|
||||
// Switch error code
|
||||
switch (result)
|
||||
@@ -228,33 +228,30 @@ String RenderToolsVulkan::GetVkErrorString(VkResult result)
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
void RenderToolsVulkan::ValidateVkResult(VkResult result, const char* file, uint32 line)
|
||||
void RenderToolsVulkan::LogVkResult(VkResult result, const char* file, uint32 line, bool fatal)
|
||||
{
|
||||
// Ensure result if invalid
|
||||
ASSERT(result != VK_SUCCESS);
|
||||
|
||||
// Get error string
|
||||
const String& errorString = GetVkErrorString(result);
|
||||
// Process error and format message
|
||||
StringBuilder sb;
|
||||
sb.Append(TEXT("Vulkan error: "));
|
||||
sb.Append(GetVkErrorString(result));
|
||||
if (file)
|
||||
sb.Append(TEXT(" at ")).Append(file).Append(':').Append(line);
|
||||
const StringView msg(sb.ToStringView());
|
||||
|
||||
// Send error
|
||||
LOG(Fatal, "Vulkan error: {0} at {1}:{2}", errorString, String(file), line);
|
||||
}
|
||||
|
||||
void RenderToolsVulkan::LogVkResult(VkResult result, const char* file, uint32 line)
|
||||
{
|
||||
// Ensure result if invalid
|
||||
ASSERT(result != VK_SUCCESS);
|
||||
|
||||
// Get error string
|
||||
const String& errorString = GetVkErrorString(result);
|
||||
|
||||
// Send error
|
||||
LOG(Error, "Vulkan error: {0} at {1}:{2}", errorString, String(file), line);
|
||||
}
|
||||
|
||||
void RenderToolsVulkan::LogVkResult(VkResult result)
|
||||
{
|
||||
LogVkResult(result, "", 0);
|
||||
// Handle error
|
||||
FatalErrorType errorType = FatalErrorType::None;
|
||||
if (result == VK_ERROR_OUT_OF_HOST_MEMORY || result == VK_ERROR_OUT_OF_DEVICE_MEMORY || result == VK_ERROR_OUT_OF_POOL_MEMORY)
|
||||
errorType = FatalErrorType::GPUOutOfMemory;
|
||||
else if (result == VK_TIMEOUT)
|
||||
errorType = FatalErrorType::GPUHang;
|
||||
else if (result == VK_ERROR_DEVICE_LOST || result == VK_ERROR_SURFACE_LOST_KHR || result == VK_ERROR_MEMORY_MAP_FAILED)
|
||||
errorType = FatalErrorType::GPUCrash;
|
||||
if (errorType != FatalErrorType::None)
|
||||
Platform::Fatal(msg, nullptr, errorType);
|
||||
else
|
||||
Log::Logger::Write(fatal ? LogType::Fatal : LogType::Error, msg);
|
||||
}
|
||||
|
||||
bool RenderToolsVulkan::HasExtension(const Array<const char*>& extensions, const char* name)
|
||||
|
||||
@@ -11,21 +11,13 @@
|
||||
|
||||
#if GRAPHICS_API_VULKAN
|
||||
|
||||
#if GPU_ENABLE_ASSERTION
|
||||
|
||||
// Vulkan results validation
|
||||
#define VALIDATE_VULKAN_RESULT(x) { VkResult result = x; if (result != VK_SUCCESS) RenderToolsVulkan::ValidateVkResult(result, __FILE__, __LINE__); }
|
||||
#define VALIDATE_VULKAN_RESULT(x) { VkResult result = x; if (result != VK_SUCCESS) RenderToolsVulkan::LogVkResult(result, __FILE__, __LINE__, true); }
|
||||
#define LOG_VULKAN_RESULT(result) if (result != VK_SUCCESS) RenderToolsVulkan::LogVkResult(result, __FILE__, __LINE__)
|
||||
#define LOG_VULKAN_RESULT_WITH_RETURN(result) if (result != VK_SUCCESS) { RenderToolsVulkan::LogVkResult(result, __FILE__, __LINE__); return true; }
|
||||
#if GPU_ENABLE_ASSERTION
|
||||
#define VK_SET_DEBUG_NAME(device, handle, type, name) RenderToolsVulkan::SetObjectName(device->Device, (uint64)handle, type, name)
|
||||
|
||||
#else
|
||||
|
||||
#define VALIDATE_VULKAN_RESULT(x) x
|
||||
#define LOG_VULKAN_RESULT(result) if (result != VK_SUCCESS) RenderToolsVulkan::LogVkResult(result)
|
||||
#define LOG_VULKAN_RESULT_WITH_RETURN(result) if (result != VK_SUCCESS) { RenderToolsVulkan::LogVkResult(result); return true; }
|
||||
#define VK_SET_DEBUG_NAME(device, handle, type, name)
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
@@ -46,9 +38,7 @@ public:
|
||||
#endif
|
||||
|
||||
static String GetVkErrorString(VkResult result);
|
||||
static void ValidateVkResult(VkResult result, const char* file, uint32 line);
|
||||
static void LogVkResult(VkResult result, const char* file, uint32 line);
|
||||
static void LogVkResult(VkResult result);
|
||||
static void LogVkResult(VkResult result, const char* file = nullptr, uint32 line = 0, bool fatal = false);
|
||||
|
||||
static inline VkPipelineStageFlags GetBufferBarrierFlags(VkAccessFlags accessFlags)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user