- make the vulkan logging a bit more readable

This commit is contained in:
Magnus Norddahl 2019-03-02 17:11:23 +01:00
parent 28f83fc9db
commit 09ea775b40

View file

@ -45,6 +45,7 @@ extern HWND Window;
#include "i_system.h"
#include "version.h"
#include "doomerrors.h"
#include "gamedata/fonts/v_text.h"
EXTERN_CVAR(Bool, vid_vsync);
@ -130,25 +131,52 @@ void VulkanDevice::presentFrame()
vkQueuePresentKHR(presentQueue, &presentInfo);
}
//FString allVulkanOutput;
VkBool32 VulkanDevice::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* callbackData, void* userData)
{
VulkanDevice *device = (VulkanDevice*)userData;
const char *prefix = "";
if (messageSeverity & VK_DEBUG_REPORT_ERROR_BIT_EXT)
{
prefix = "error";
}
else if (messageSeverity & VK_DEBUG_REPORT_WARNING_BIT_EXT)
{
prefix = "warning";
}
static std::mutex mtx;
static std::set<FString> seenMessages;
static int totalMessages;
Printf("Vulkan validation layer %s: %s\n", prefix, callbackData->pMessage);
std::unique_lock<std::mutex> lock(mtx);
//allVulkanOutput.AppendFormat("Vulkan validation layer %s: %s\n", prefix, callbackData->pMessage);
FString msg = callbackData->pMessage;
bool found = seenMessages.find(msg) != seenMessages.end();
if (!found)
{
if (totalMessages < 100)
{
totalMessages++;
seenMessages.insert(msg);
const char *typestr;
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
{
typestr = "vulkan error";
}
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
{
typestr = "vulkan warning";
}
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
{
typestr = "vulkan info";
}
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT)
{
typestr = "vulkan verbose";
}
else
{
typestr = "vulkan";
}
Printf("\n");
Printf(TEXTCOLOR_RED "[%s] ", typestr);
Printf(TEXTCOLOR_WHITE "%s\n", callbackData->pMessage);
}
}
return VK_FALSE;
}