debug_report: Add DebugReportMessage function

This commit is contained in:
Courtney Goeltzenleuchter 2015-11-30 15:28:25 -07:00 committed by Jon Ashburn
parent 63ca54aadc
commit 20af4c924b
6 changed files with 108 additions and 0 deletions

View File

@ -92,6 +92,39 @@ static VKAPI_ATTR VkResult VKAPI_CALL debug_report_CreateDebugReportCallback(
return result;
}
// Utility function to handle reporting
static inline VkBool32 debug_report_log_msg(
VkInstance instance,
VkFlags msgFlags,
VkDebugReportObjectTypeLUNARG objectType,
uint64_t srcObject,
size_t location,
int32_t msgCode,
const char* pLayerPrefix,
const char* pMsg)
{
struct loader_instance *inst = loader_get_instance(instance);
VkBool32 bail = false;
VkLayerDbgFunctionNode *pTrav = inst->DbgFunctionHead;
while (pTrav) {
if (pTrav->msgFlags & msgFlags) {
if (pTrav->pfnMsgCallback(msgFlags,
objectType, srcObject,
location,
msgCode,
pLayerPrefix,
pMsg,
(void *) pTrav->pUserData)) {
bail = true;
}
}
pTrav = pTrav->pNext;
}
return bail;
}
static VKAPI_ATTR void VKAPI_CALL debug_report_DestroyDebugReportCallback(
VkInstance instance,
VkDebugReportCallbackLUNARG callback,
@ -119,6 +152,21 @@ static VKAPI_ATTR void VKAPI_CALL debug_report_DestroyDebugReportCallback(
loader_platform_thread_unlock_mutex(&loader_lock);
}
static VKAPI_ATTR void VKAPI_CALL debug_report_DebugReportMessage(
VkInstance instance,
VkDebugReportFlagsLUNARG flags,
VkDebugReportObjectTypeLUNARG objType,
uint64_t object,
size_t location,
int32_t msgCode,
const char* pLayerPrefix,
const char* pMsg)
{
struct loader_instance *inst = loader_get_instance(instance);
inst->disp->DebugReportMessageLUNARG(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg);
}
/*
* This is the instance chain terminator function
@ -216,6 +264,37 @@ VKAPI_ATTR void loader_DestroyDebugReportCallback(VkInstance instance,
}
}
/*
* This is the instance chain terminator function
* for DebugReportMessage
*/
VKAPI_ATTR void VKAPI_CALL loader_DebugReportMessage(
VkInstance instance,
VkDebugReportFlagsLUNARG flags,
VkDebugReportObjectTypeLUNARG objType,
uint64_t object,
size_t location,
int32_t msgCode,
const char* pLayerPrefix,
const char* pMsg)
{
const struct loader_icd *icd;
struct loader_instance *inst = loader_get_instance(instance);
for (icd = inst->icds; icd; icd = icd->next) {
if (icd->DebugReportMessageLUNARG != NULL) {
icd->DebugReportMessageLUNARG(icd->instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg);
}
}
/*
* Now that all ICDs have seen the message, call the necessary callbacks.
* Ignoring "bail" return value as there is nothing to bail from at this point.
*/
debug_report_log_msg(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg);
}
bool debug_report_instance_gpa(
struct loader_instance *ptr_instance,
const char* name,
@ -233,5 +312,9 @@ bool debug_report_instance_gpa(
*addr = ptr_instance->debug_report_enabled ? (void *) debug_report_DestroyDebugReportCallback : NULL;
return true;
}
if (!strcmp("vkDebugReportMessageLUNARG", name)) {
*addr = ptr_instance->debug_report_enabled ? (void *) debug_report_DebugReportMessage : NULL;
return true;
}
return false;
}

View File

@ -112,3 +112,13 @@ VKAPI_ATTR void VKAPI_CALL loader_DestroyDebugReportCallback(
VkInstance instance,
VkDebugReportCallbackLUNARG callback,
const VkAllocationCallbacks *pAllocator);
VKAPI_ATTR void VKAPI_CALL loader_DebugReportMessage(
VkInstance instance,
VkDebugReportFlagsLUNARG flags,
VkDebugReportObjectTypeLUNARG objType,
uint64_t object,
size_t location,
int32_t msgCode,
const char* pLayerPrefix,
const char* pMsg);

View File

@ -116,6 +116,7 @@ const VkLayerInstanceDispatchTable instance_disp = {
.GetPhysicalDeviceSurfacePresentModesKHR = loader_GetPhysicalDeviceSurfacePresentModesKHR,
.CreateDebugReportCallbackLUNARG = loader_CreateDebugReportCallback,
.DestroyDebugReportCallbackLUNARG = loader_DestroyDebugReportCallback,
.DebugReportMessageLUNARG = loader_DebugReportMessage,
#ifdef VK_USE_PLATFORM_MIR_KHR
.CreateMirSurfaceKHR = loader_CreateMirSurfaceKHR,
.GetPhysicalDeviceMirPresentationSupportKHR = loader_GetPhysicalDeviceMirPresentationSupportKHR,

View File

@ -190,6 +190,7 @@ struct loader_icd {
PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
PFN_vkCreateDebugReportCallbackLUNARG CreateDebugReportCallbackLUNARG;
PFN_vkDestroyDebugReportCallbackLUNARG DestroyDebugReportCallbackLUNARG;
PFN_vkDebugReportMessageLUNARG DebugReportMessageLUNARG;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;

View File

@ -471,6 +471,7 @@ static inline void loader_init_instance_extension_dispatch_table(
table->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) gpa(inst, "vkDestroySurfaceKHR");
table->CreateDebugReportCallbackLUNARG = (PFN_vkCreateDebugReportCallbackLUNARG) gpa(inst, "vkCreateDebugReportCallbackLUNARG");
table->DestroyDebugReportCallbackLUNARG = (PFN_vkDestroyDebugReportCallbackLUNARG) gpa(inst, "vkDestroyDebugReportCallbackLUNARG");
table->DebugReportMessageLUNARG = (PFN_vkDebugReportMessageLUNARG) gpa(inst, "vkDebugReportMessageLUNARG");
table->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(inst, "vkGetPhysicalDeviceSurfaceSupportKHR");
table->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(inst, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
table->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(inst, "vkGetPhysicalDeviceSurfaceFormatsKHR");
@ -575,6 +576,8 @@ static inline void *loader_lookup_instance_dispatch_table(
return (void *) table->CreateDebugReportCallbackLUNARG;
if (!strcmp(name, "DestroyDebugReportCallbackLUNARG"))
return (void *) table->DestroyDebugReportCallbackLUNARG;
if (!strcmp(name, "DebugReportMessageLUNARG"))
return (void *) table->DebugReportMessageLUNARG;
return NULL;
}

View File

@ -1134,6 +1134,16 @@ lunarg_debug_report = Extension(
[Param("VkInstance", "instance"),
Param("VkDebugReportCallbackLUNARG", "callback"),
Param("const VkAllocationCallbacks*", "pAllocator")]),
Proto("void", "DebugReportMessageLUNARG",
[Param("VkInstance", "instance"),
Param("VkDebugReportFlagsLUNARG", "flags"),
Param("VkDebugReportObjectTypeLUNARG", "objType"),
Param("uint64_t", "object"),
Param("size_t", "location"),
Param("int32_t", "msgCode"),
Param("const char *", "pLayerPrefix"),
Param("const char *", "pMsg")]),
],
)
lunarg_debug_marker = Extension(