[vulkan] Make vulkan_use_validation easier more useful

Rather than just 0/1, it now acts as flags to control what messages are
printed. In addition to the Vulkan enum names (long and short), none and
all are supported (as well as raw numbers, but they're not checked for
validity). This makes vulkan_use_validation a bit easier to use and less
verbose by default.

Now, if only it was easier to remember the name :P
This commit is contained in:
Bill Currie 2021-11-29 13:44:10 +09:00
parent 901619235b
commit 2334798432
3 changed files with 23 additions and 2 deletions

View file

@ -116,6 +116,7 @@ instance_extension_enabled (qfv_instance_t *inst, const char *ext)
}
static int message_severities =
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
@ -135,6 +136,9 @@ debug_callback (VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
const VkDebugUtilsMessengerCallbackDataEXT* callbackData,
void *data)
{
if (!(messageSeverity & vulkan_use_validation->int_val)) {
return 0;
}
const char *msgSev = "";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) {
msgSev = "verbose: ";

View file

@ -1,6 +1,7 @@
{
search = (
VkAttachmentDescription,
VkDebugUtilsMessageSeverityFlagBitsEXT,
VkSubpassDescription,
VkSubpassDependency,
VkSpecializationInfo,

View file

@ -118,6 +118,21 @@ vulkan_presentation_mode_f (cvar_t *var)
}
}
static void
vulkan_use_validation_f (cvar_t *var)
{
if (!strcmp (var->string, "none")) {
var->int_val = 0;
} else if (!strcmp (var->string, "all")) {
var->int_val = VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT;
} else {
parse_cvar_enum ("VkDebugUtilsMessageSeverityFlagBitsEXT",
"Invalid validation flags, using all",
VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT,
var);
}
}
static void
vulkan_frame_count_f (cvar_t *var)
{
@ -137,8 +152,9 @@ msaaSamples_f (cvar_t *var)
static void
Vulkan_Init_Cvars (void)
{
vulkan_use_validation = Cvar_Get ("vulkan_use_validation", "1", CVAR_NONE,
0,
vulkan_use_validation = Cvar_Get ("vulkan_use_validation",
"error|warning", CVAR_NONE,
vulkan_use_validation_f,
"enable KRONOS Validation Layer if "
"available (requires instance "
"restart).");