mirror of
https://github.com/yquake2/ref_vk.git
synced 2024-12-02 08:21:59 +00:00
Using VK_debug_report extension if available.
This commit is contained in:
parent
495a40dffd
commit
0f6d05ed9b
3 changed files with 59 additions and 0 deletions
|
@ -275,6 +275,8 @@ extern PFN_vkSetDebugUtilsObjectTagEXT qvkSetDebugUtilsObjectTagEXT;
|
|||
extern PFN_vkCmdBeginDebugUtilsLabelEXT qvkCmdBeginDebugUtilsLabelEXT;
|
||||
extern PFN_vkCmdEndDebugUtilsLabelEXT qvkCmdEndDebugUtilsLabelEXT;
|
||||
extern PFN_vkCmdInsertDebugUtilsLabelEXT qvkInsertDebugUtilsLabelEXT;
|
||||
extern PFN_vkCreateDebugReportCallbackEXT qvkCreateDebugReportCallbackEXT;
|
||||
extern PFN_vkDestroyDebugReportCallbackEXT qvkDestroyDebugReportCallbackEXT;
|
||||
#if defined(__APPLE__)
|
||||
extern PFN_vkGetPhysicalDeviceMetalFeaturesMVK qvkGetPhysicalDeviceMetalFeaturesMVK;
|
||||
extern PFN_vkGetMoltenVKConfigurationMVK qvkGetMoltenVKConfigurationMVK;
|
||||
|
|
|
@ -165,6 +165,8 @@ PFN_vkSetDebugUtilsObjectTagEXT qvkSetDebugUtilsObjectTagEXT;
|
|||
PFN_vkCmdBeginDebugUtilsLabelEXT qvkCmdBeginDebugUtilsLabelEXT;
|
||||
PFN_vkCmdEndDebugUtilsLabelEXT qvkCmdEndDebugUtilsLabelEXT;
|
||||
PFN_vkCmdInsertDebugUtilsLabelEXT qvkInsertDebugUtilsLabelEXT;
|
||||
PFN_vkCreateDebugReportCallbackEXT qvkCreateDebugReportCallbackEXT;
|
||||
PFN_vkDestroyDebugReportCallbackEXT qvkDestroyDebugReportCallbackEXT;
|
||||
|
||||
#define VK_INPUTBIND_DESC(s) { \
|
||||
.binding = 0, \
|
||||
|
@ -1899,6 +1901,8 @@ qboolean QVk_Init(void)
|
|||
qvkCmdBeginDebugUtilsLabelEXT = (PFN_vkCmdBeginDebugUtilsLabelEXT)vkGetInstanceProcAddr(vk_instance, "vkCmdBeginDebugUtilsLabelEXT");
|
||||
qvkCmdEndDebugUtilsLabelEXT = (PFN_vkCmdEndDebugUtilsLabelEXT)vkGetInstanceProcAddr(vk_instance, "vkCmdEndDebugUtilsLabelEXT");
|
||||
qvkInsertDebugUtilsLabelEXT = (PFN_vkCmdInsertDebugUtilsLabelEXT)vkGetInstanceProcAddr(vk_instance, "vkCmdInsertDebugUtilsLabelEXT");
|
||||
qvkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(vk_instance, "vkCreateDebugReportCallbackEXT");
|
||||
qvkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(vk_instance, "vkDestroyDebugReportCallbackEXT");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1909,6 +1913,8 @@ qboolean QVk_Init(void)
|
|||
qvkCmdBeginDebugUtilsLabelEXT = NULL;
|
||||
qvkCmdEndDebugUtilsLabelEXT = NULL;
|
||||
qvkInsertDebugUtilsLabelEXT = NULL;
|
||||
qvkCreateDebugReportCallbackEXT = NULL;
|
||||
qvkDestroyDebugReportCallbackEXT = NULL;
|
||||
}
|
||||
|
||||
if (r_validation->value > 0)
|
||||
|
|
|
@ -61,6 +61,36 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsCallback(VkDebugUtilsMessageSeve
|
|||
return VK_FALSE;
|
||||
}
|
||||
|
||||
static VkDebugReportCallbackEXT validationLayerCallback = VK_NULL_HANDLE;
|
||||
|
||||
// validation layer callback function (VK_EXT_debug_report)
|
||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallbackReport(VkDebugReportFlagsEXT flags,
|
||||
VkDebugReportObjectTypeEXT objType,
|
||||
uint64_t obj, size_t location, int32_t code,
|
||||
const char *layerPrefix, const char *msg,
|
||||
void* userData)
|
||||
{
|
||||
switch (flags)
|
||||
{
|
||||
case VK_DEBUG_REPORT_INFORMATION_BIT_EXT:
|
||||
R_Printf(PRINT_ALL, "VK_INFO: %s %s\n", layerPrefix, msg);
|
||||
break;
|
||||
case VK_DEBUG_REPORT_DEBUG_BIT_EXT:
|
||||
R_Printf(PRINT_ALL, "VK_DEBUG: %s %s\n", layerPrefix, msg);
|
||||
break;
|
||||
case VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT:
|
||||
R_Printf(PRINT_ALL, "VK_PERFORMANCE: %s %s\n", layerPrefix, msg);
|
||||
break;
|
||||
case VK_DEBUG_REPORT_WARNING_BIT_EXT:
|
||||
R_Printf(PRINT_ALL, "VK_WARNING: %s %s\n", layerPrefix, msg);
|
||||
break;
|
||||
default:
|
||||
R_Printf(PRINT_ALL, "VK_ERROR: %s %s\n", layerPrefix, msg);
|
||||
break;
|
||||
}
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
void QVk_CreateValidationLayers()
|
||||
{
|
||||
VkDebugUtilsMessengerCreateInfoEXT callbackInfo = {
|
||||
|
@ -76,6 +106,16 @@ void QVk_CreateValidationLayers()
|
|||
.pUserData = NULL
|
||||
};
|
||||
|
||||
VkDebugReportCallbackCreateInfoEXT callbackReport = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
|
||||
.pNext = NULL,
|
||||
.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT |
|
||||
VK_DEBUG_REPORT_DEBUG_BIT_EXT | VK_DEBUG_REPORT_INFORMATION_BIT_EXT |
|
||||
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
|
||||
.pfnCallback = debugCallbackReport,
|
||||
.pUserData = NULL
|
||||
};
|
||||
|
||||
if (r_validation->value > 1)
|
||||
{
|
||||
callbackInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
|
||||
|
@ -85,6 +125,11 @@ void QVk_CreateValidationLayers()
|
|||
if (qvkCreateDebugUtilsMessengerEXT)
|
||||
{
|
||||
VK_VERIFY(qvkCreateDebugUtilsMessengerEXT(vk_instance, &callbackInfo, NULL, &validationMessenger));
|
||||
}
|
||||
|
||||
if (qvkCreateDebugReportCallbackEXT)
|
||||
{
|
||||
VK_VERIFY(qvkCreateDebugReportCallbackEXT(vk_instance, &callbackReport, NULL, &validationLayerCallback));
|
||||
R_Printf(PRINT_ALL, "...Vulkan validation layers enabled\n");
|
||||
}
|
||||
}
|
||||
|
@ -96,4 +141,10 @@ void QVk_DestroyValidationLayers()
|
|||
qvkDestroyDebugUtilsMessengerEXT( vk_instance, validationMessenger, NULL );
|
||||
validationMessenger = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if ( validationLayerCallback != VK_NULL_HANDLE && qvkDestroyDebugReportCallbackEXT)
|
||||
{
|
||||
qvkDestroyDebugReportCallbackEXT( vk_instance, validationLayerCallback, NULL );
|
||||
validationLayerCallback = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue