vkQuake2 doxygen  1.0 dev
vk_validation.c File Reference
#include "vk_local.h"

Go to the source code of this file.

Macros

#define VK_FILELOG(msg, ...)
 

Functions

static const char * msgToString (VkDebugUtilsMessageTypeFlagsEXT type)
 
static VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsCallback (VkDebugUtilsMessageSeverityFlagBitsEXT msgSeverity, VkDebugUtilsMessageTypeFlagsEXT msgType, const VkDebugUtilsMessengerCallbackDataEXT *callbackData, void *userData)
 
void QVk_CreateValidationLayers ()
 
void QVk_DestroyValidationLayers ()
 

Variables

static VkDebugUtilsMessengerEXT validationMessenger = VK_NULL_HANDLE
 
FILE * vk_logfp
 

Macro Definition Documentation

◆ VK_FILELOG

#define VK_FILELOG (   msg,
  ... 
)
Value:
if(vk_log->value && vk_logfp) { \
fprintf(vk_logfp, msg, __VA_ARGS__); \
}

Definition at line 26 of file vk_validation.c.

Function Documentation

◆ debugUtilsCallback()

static VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsCallback ( VkDebugUtilsMessageSeverityFlagBitsEXT  msgSeverity,
VkDebugUtilsMessageTypeFlagsEXT  msgType,
const VkDebugUtilsMessengerCallbackDataEXT *  callbackData,
void userData 
)
static

Definition at line 46 of file vk_validation.c.

50 {
51  switch (msgSeverity)
52  {
53  case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT:
54  ri.Con_Printf(PRINT_ALL, "VK_INFO: %s %s\n", callbackData->pMessage, msgToString(msgType));
55  VK_FILELOG("VK_INFO: %s %s\n", callbackData->pMessage, msgToString(msgType));
56  break;
57  case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT:
58  ri.Con_Printf(PRINT_ALL, "VK_VERBOSE: %s %s\n", callbackData->pMessage, msgToString(msgType));
59  VK_FILELOG("VK_VERBOSE: %s %s\n", callbackData->pMessage, msgToString(msgType));
60  break;
61  case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT:
62  ri.Con_Printf(PRINT_ALL, "VK_WARNING: %s %s\n", callbackData->pMessage, msgToString(msgType));
63  VK_FILELOG("VK_WARNING: %s %s\n", callbackData->pMessage, msgToString(msgType));
64  assert(!"Vulkan warning occured!");
65  break;
66  default:
67  ri.Con_Printf(PRINT_ALL, "VK_ERROR: %s %s\n", callbackData->pMessage, msgToString(msgType));
68  VK_FILELOG("VK_ERROR: %s %s\n", callbackData->pMessage, msgToString(msgType));
69  assert(!"Vulkan error occured!");
70  }
71  return VK_FALSE;
72 }

Referenced by QVk_CreateValidationLayers().

◆ msgToString()

static const char* msgToString ( VkDebugUtilsMessageTypeFlagsEXT  type)
static

Definition at line 31 of file vk_validation.c.

32 {
33  int g = (type & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) != 0 ? 1 : 0;
34  int p = (type & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) != 0 ? 1 : 0;
35  int v = (type & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) != 0 ? 1 : 0;
36 
37  if (g) return "";
38  if (p && !v) return "(performance)";
39  if (p && v) return "(performance and validation)";
40  if (v) return "(validation)";
41 
42  return "?";
43 }

Referenced by debugUtilsCallback().

◆ QVk_CreateValidationLayers()

void QVk_CreateValidationLayers ( )

Definition at line 74 of file vk_validation.c.

75 {
76  VkDebugUtilsMessengerCreateInfoEXT callbackInfo = {
77  .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
78  .pNext = NULL,
79  .flags = 0,
80  .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
81  VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
82  .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
83  VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
84  VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
85  .pfnUserCallback = debugUtilsCallback,
86  .pUserData = NULL
87  };
88 
89  if( vk_validation->value > 1 )
90  {
91  callbackInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
92  VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
93  }
94 
96  ri.Con_Printf(PRINT_ALL, "...Vulkan validation layers enabled\n");
97 }

Referenced by QVk_Init().

◆ QVk_DestroyValidationLayers()

void QVk_DestroyValidationLayers ( )

Definition at line 99 of file vk_validation.c.

100 {
101  if( validationMessenger != VK_NULL_HANDLE )
102  {
104  validationMessenger = VK_NULL_HANDLE;
105  }
106 }

Referenced by QVk_Shutdown().

Variable Documentation

◆ validationMessenger

VkDebugUtilsMessengerEXT validationMessenger = VK_NULL_HANDLE
static

Definition at line 23 of file vk_validation.c.

Referenced by QVk_CreateValidationLayers(), and QVk_DestroyValidationLayers().

◆ vk_logfp

FILE* vk_logfp

Definition at line 43 of file vk_common.c.

Referenced by Vkimp_EnableLogging().

vk_instance
VkInstance vk_instance
Definition: vk_common.c:46
ri
refimport_t ri
Definition: r_main.c:25
v
GLdouble v
Definition: qgl_win.c:143
validationMessenger
static VkDebugUtilsMessengerEXT validationMessenger
Definition: vk_validation.c:23
vk_log
cvar_t * vk_log
Definition: vk_rmain.c:93
msgToString
static const char * msgToString(VkDebugUtilsMessageTypeFlagsEXT type)
Definition: vk_validation.c:31
VK_FILELOG
#define VK_FILELOG(msg,...)
Definition: vk_validation.c:26
type
GLenum type
Definition: qgl_win.c:72
vk_logfp
FILE * vk_logfp
Definition: vk_common.c:43
msg
cvar_t * msg
Definition: cl_main.c:83
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
cvar_s::value
float value
Definition: q_shared.h:331
vk_validation
cvar_t * vk_validation
Definition: vk_rmain.c:90
qvkCreateDebugUtilsMessengerEXT
PFN_vkCreateDebugUtilsMessengerEXT qvkCreateDebugUtilsMessengerEXT
Definition: vk_common.c:166
NULL
#define NULL
Definition: q_shared.h:67
VK_VERIFY
#define VK_VERIFY(x)
Definition: vk_local.h:59
debugUtilsCallback
static VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT msgSeverity, VkDebugUtilsMessageTypeFlagsEXT msgType, const VkDebugUtilsMessengerCallbackDataEXT *callbackData, void *userData)
Definition: vk_validation.c:46
qvkDestroyDebugUtilsMessengerEXT
PFN_vkDestroyDebugUtilsMessengerEXT qvkDestroyDebugUtilsMessengerEXT
Definition: vk_common.c:167