From 2dafae41b1f79bfb462eb37c1fdf3479879d9485 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Mon, 30 Nov 2015 12:13:14 -0700 Subject: debug_report: rename and update to use CreateInfo --- demos/cube.c | 43 +++++++++-------- demos/tri.c | 30 +++++++----- icd/common/icd-instance.c | 21 ++++----- icd/common/icd-instance.h | 14 +++--- include/vulkan/vk_layer.h | 6 +-- include/vulkan/vk_lunarg_debug_report.h | 36 ++++++++------ layers/device_limits.cpp | 45 +++++++++++------- layers/draw_state.cpp | 47 ++++++++++++------- layers/image.cpp | 44 ++++++++++------- layers/mem_tracker.cpp | 46 +++++++++++------- layers/object_track.h | 8 +++- layers/param_checker.cpp | 42 +++++++++++------ layers/swapchain.cpp | 34 +++++++++----- layers/vk_layer_config.cpp | 4 +- layers/vk_layer_config.h | 2 +- layers/vk_layer_logging.h | 48 ++++++++++--------- layers/vk_layer_settings.txt | 2 +- loader/debug_report.c | 83 ++++++++++++++++----------------- loader/debug_report.h | 18 +++---- loader/loader.c | 8 ++-- loader/loader.h | 4 +- loader/table_ops.h | 12 ++--- vk-layer-generate.py | 62 ++++++++++++++---------- vk_helper.py | 1 + vulkan.py | 18 +++---- 25 files changed, 392 insertions(+), 286 deletions(-) diff --git a/demos/cube.c b/demos/cube.c index 17da2c42..59e4fef7 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -395,9 +395,9 @@ struct demo { int32_t frameCount; bool validate; bool use_break; - PFN_vkDbgCreateMsgCallback dbgCreateMsgCallback; - PFN_vkDbgDestroyMsgCallback dbgDestroyMsgCallback; - PFN_vkDbgMsgCallback dbgBreakCallback; + PFN_vkCreateDebugReportCallbackLUNARG CreateDebugReportCallback; + PFN_vkDestroyDebugReportCallbackLUNARG DestroyDebugReportCallback; + PFN_vkDebugReportCallbackLUNARG dbgBreakCallback; VkDebugReportCallbackLUNARG msg_callback; uint32_t current_buffer; @@ -1785,7 +1785,7 @@ static void demo_cleanup(struct demo *demo) vkDestroyCommandPool(demo->device, demo->cmd_pool, NULL); vkDestroyDevice(demo->device, NULL); if (demo->validate) { - demo->dbgDestroyMsgCallback(demo->inst, demo->msg_callback); + demo->DestroyDebugReportCallback(demo->inst, demo->msg_callback, NULL); } vkDestroySurfaceKHR(demo->inst, demo->surface, NULL); vkDestroyInstance(demo->inst, NULL); @@ -2315,19 +2315,18 @@ static void demo_init_vk(struct demo *demo) } if (demo->validate) { - demo->dbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) vkGetInstanceProcAddr(demo->inst, "vkDbgCreateMsgCallback"); - demo->dbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) vkGetInstanceProcAddr(demo->inst, "vkDbgDestroyMsgCallback"); - if (!demo->dbgCreateMsgCallback) { - ERR_EXIT("GetProcAddr: Unable to find vkDbgCreateMsgCallback\n", + demo->CreateDebugReportCallback = (PFN_vkCreateDebugReportCallbackLUNARG) vkGetInstanceProcAddr(demo->inst, "vkCreateDebugReportCallbackLUNARG"); + demo->DestroyDebugReportCallback = (PFN_vkDestroyDebugReportCallbackLUNARG) vkGetInstanceProcAddr(demo->inst, "vkDestroyDebugReportCallbackLUNARG"); + if (!demo->CreateDebugReportCallback) { + ERR_EXIT("GetProcAddr: Unable to find vkCreateDebugReportCallbackLUNARG\n", "vkGetProcAddr Failure"); } - if (!demo->dbgDestroyMsgCallback) { - ERR_EXIT("GetProcAddr: Unable to find vkDbgDestroyMsgCallback\n", + if (!demo->DestroyDebugReportCallback) { + ERR_EXIT("GetProcAddr: Unable to find vkDestroyDebugReportCallbackLUNARG\n", "vkGetProcAddr Failure"); } - - PFN_vkDbgMsgCallback callback; + PFN_vkDebugReportCallbackLUNARG callback; if (!demo->use_break) { callback = dbgFunc; @@ -2336,21 +2335,27 @@ static void demo_init_vk(struct demo *demo) // TODO add a break callback defined locally since there is no longer // one included in the loader } - err = demo->dbgCreateMsgCallback( + VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo; + dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgCreateInfo.pNext = NULL; + dbgCreateInfo.pfnCallback = callback; + dbgCreateInfo.pUserData = NULL; + dbgCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT | VK_DEBUG_REPORT_WARN_BIT; + err = demo->CreateDebugReportCallback( demo->inst, - VK_DEBUG_REPORT_ERROR_BIT | VK_DEBUG_REPORT_WARN_BIT, - callback, NULL, + &dbgCreateInfo, + NULL, &demo->msg_callback); switch (err) { case VK_SUCCESS: break; case VK_ERROR_OUT_OF_HOST_MEMORY: - ERR_EXIT("dbgCreateMsgCallback: out of host memory\n", - "dbgCreateMsgCallback Failure"); + ERR_EXIT("CreateDebugReportCallback: out of host memory\n", + "CreateDebugReportCallback Failure"); break; default: - ERR_EXIT("dbgCreateMsgCallback: unknown failure\n", - "dbgCreateMsgCallback Failure"); + ERR_EXIT("CreateDebugReportCallback: unknown failure\n", + "CreateDebugReportCallback Failure"); break; } } diff --git a/demos/tri.c b/demos/tri.c index 3b7aec8e..86b43d9f 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -236,8 +236,8 @@ struct demo { VkPhysicalDeviceMemoryProperties memory_properties; bool validate; - PFN_vkDbgCreateMsgCallback dbgCreateMsgCallback; - PFN_vkDbgDestroyMsgCallback dbgDestroyMsgCallback; + PFN_vkCreateDebugReportCallbackLUNARG CreateDebugReportCallback; + PFN_vkDestroyDebugReportCallbackLUNARG DestroyDebugReportCallback; VkDebugReportCallbackLUNARG msg_callback; float depthStencil; @@ -1946,26 +1946,32 @@ static void demo_init_vk(struct demo *demo) }; if (demo->validate) { - demo->dbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) vkGetInstanceProcAddr(demo->inst, "vkDbgCreateMsgCallback"); - if (!demo->dbgCreateMsgCallback) { - ERR_EXIT("GetProcAddr: Unable to find vkDbgCreateMsgCallback\n", + demo->CreateDebugReportCallback = (PFN_vkCreateDebugReportCallbackLUNARG) vkGetInstanceProcAddr(demo->inst, "vkCreateDebugReportCallbackLUNARG"); + if (!demo->CreateDebugReportCallback) { + ERR_EXIT("GetProcAddr: Unable to find vkCreateDebugReportCallbackLUNARG\n", "vkGetProcAddr Failure"); } - err = demo->dbgCreateMsgCallback( + VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo; + dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT | VK_DEBUG_REPORT_WARN_BIT; + dbgCreateInfo.pfnCallback = (const void *) dbgFunc; + dbgCreateInfo.pUserData = NULL; + dbgCreateInfo.pNext = NULL; + err = demo->CreateDebugReportCallback( demo->inst, - VK_DEBUG_REPORT_ERROR_BIT | VK_DEBUG_REPORT_WARN_BIT, - dbgFunc, NULL, + &dbgCreateInfo, + NULL, &demo->msg_callback); switch (err) { case VK_SUCCESS: break; case VK_ERROR_OUT_OF_HOST_MEMORY: - ERR_EXIT("dbgCreateMsgCallback: out of host memory\n", - "dbgCreateMsgCallback Failure"); + ERR_EXIT("CreateDebugReportCallback: out of host memory\n", + "CreateDebugReportCallback Failure"); break; default: - ERR_EXIT("dbgCreateMsgCallback: unknown failure\n", - "dbgCreateMsgCallback Failure"); + ERR_EXIT("CreateDebugReportCallback: unknown failure\n", + "CreateDebugReportCallback Failure"); break; } } diff --git a/icd/common/icd-instance.c b/icd/common/icd-instance.c index a1619e89..6b674a0e 100644 --- a/icd/common/icd-instance.c +++ b/icd/common/icd-instance.c @@ -119,9 +119,8 @@ void icd_instance_destroy(struct icd_instance *instance) VkResult icd_instance_create_logger( struct icd_instance *instance, - VkFlags msg_flags, - PFN_vkDbgMsgCallback func, - void *user_data, + VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackLUNARG *msg_obj) { struct icd_instance_logger *logger; @@ -136,21 +135,22 @@ VkResult icd_instance_create_logger( if (!logger) return VK_ERROR_OUT_OF_HOST_MEMORY; - logger->func = func; - logger->flags = msg_flags; + logger->func = pCreateInfo->pfnCallback; + logger->flags = pCreateInfo->flags; logger->next = instance->loggers; instance->loggers = logger; - logger->user_data = (void *) user_data; + logger->user_data = pCreateInfo->pUserData; *( struct icd_instance_logger **)msg_obj = logger; return VK_SUCCESS; } -VkResult icd_instance_destroy_logger( +void icd_instance_destroy_logger( struct icd_instance *instance, - const VkDebugReportCallbackLUNARG msg_obj) + const VkDebugReportCallbackLUNARG msg_obj, + const VkAllocationCallbacks *pAllocator) { struct icd_instance_logger *logger, *prev; VkDebugReportCallbackLUNARG local_msg_obj = msg_obj; @@ -171,15 +171,14 @@ VkResult icd_instance_destroy_logger( instance->loggers = logger->next; icd_instance_free(instance, logger); - - return VK_SUCCESS; } void icd_instance_log(const struct icd_instance *instance, VkFlags msg_flags, VkDebugReportObjectTypeLUNARG obj_type, uint64_t src_object, - size_t location, int32_t msg_code, + size_t location, + int32_t msg_code, const char *msg) { const struct icd_instance_logger *logger; diff --git a/icd/common/icd-instance.h b/icd/common/icd-instance.h index 600df597..d9cb847c 100644 --- a/icd/common/icd-instance.h +++ b/icd/common/icd-instance.h @@ -35,8 +35,8 @@ extern "C" { #endif struct icd_instance_logger { - PFN_vkDbgMsgCallback func; - void *user_data; + PFN_vkDebugReportCallbackLUNARG func; + const void *user_data; VkFlags flags; struct icd_instance_logger *next; @@ -69,14 +69,12 @@ static inline void icd_instance_free(const struct icd_instance *instance, } VkResult icd_instance_create_logger(struct icd_instance *instance, - VkFlags msg_flags, - PFN_vkDbgMsgCallback func, - void *user_data, + VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackLUNARG *msg_obj); -VkResult icd_instance_destroy_logger( - struct icd_instance *instance, - const VkDebugReportCallbackLUNARG msg_obj); +void icd_instance_destroy_logger(struct icd_instance *instance, + const VkDebugReportCallbackLUNARG msg_obj, const VkAllocationCallbacks *pAllocator); void icd_instance_log(const struct icd_instance *instance, VkFlags msg_flags, diff --git a/include/vulkan/vk_layer.h b/include/vulkan/vk_layer.h index 471f8ff3..5ac2f7ed 100644 --- a/include/vulkan/vk_layer.h +++ b/include/vulkan/vk_layer.h @@ -174,8 +174,8 @@ typedef struct VkLayerInstanceDispatchTable_ PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR; PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR; - PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback; - PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback; + PFN_vkCreateDebugReportCallbackLUNARG CreateDebugReportCallbackLUNARG; + PFN_vkDestroyDebugReportCallbackLUNARG DestroyDebugReportCallbackLUNARG; #ifdef VK_USE_PLATFORM_MIR_KHR PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR; PFN_vkGetPhysicalDeviceMirPresentationSupportKHR GetPhysicalDeviceMirPresentationSupportKHR; @@ -205,7 +205,7 @@ typedef struct VkLayerInstanceDispatchTable_ typedef struct VkLayerDbgFunctionNode_ { VkDebugReportCallbackLUNARG msgCallback; - PFN_vkDbgMsgCallback pfnMsgCallback; + PFN_vkDebugReportCallbackLUNARG pfnMsgCallback; VkFlags msgFlags; const void *pUserData; struct VkLayerDbgFunctionNode_ *pNext; diff --git a/include/vulkan/vk_lunarg_debug_report.h b/include/vulkan/vk_lunarg_debug_report.h index 5fc3de0b..936625fe 100644 --- a/include/vulkan/vk_lunarg_debug_report.h +++ b/include/vulkan/vk_lunarg_debug_report.h @@ -110,11 +110,12 @@ typedef enum _DEBUG_REPORT_ERROR #define VK_OBJECT_TYPE_MSG_CALLBACK VK_DEBUG_REPORT_ENUM_EXTEND(VkDebugReportObjectTypeLUNARG, 0) #define VK_ERROR_VALIDATION_FAILED VK_DEBUG_REPORT_ENUM_EXTEND(VkResult, 0) +#define VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG VK_DEBUG_REPORT_ENUM_EXTEND(VkStructureType, 0) // ------------------------------------------------------------------------------------------------ // Vulkan function pointers -typedef VkBool32 (*PFN_vkDbgMsgCallback)( +typedef VkBool32 (*PFN_vkDebugReportCallbackLUNARG)( VkFlags msgFlags, VkDebugReportObjectTypeLUNARG objType, uint64_t srcObject, @@ -124,26 +125,33 @@ typedef VkBool32 (*PFN_vkDbgMsgCallback)( const char* pMsg, const void* pUserData); +typedef struct VkDebugReportCallbackCreateInfoLUNARG { + VkStructureType sType; + const void* pNext; + VkDebugReportFlagsLUNARG flags; + PFN_vkDebugReportCallbackLUNARG pfnCallback; + const void* pUserData; +} VkDebugReportCallbackCreateInfoLUNARG; + // ------------------------------------------------------------------------------------------------ // API functions -typedef VkResult (VKAPI_PTR *PFN_vkDbgCreateMsgCallback)(VkInstance instance, VkFlags msgFlags, const PFN_vkDbgMsgCallback pfnMsgCallback, void* pUserData, VkDebugReportCallbackLUNARG* pMsgCallback); -typedef VkResult (VKAPI_PTR *PFN_vkDbgDestroyMsgCallback)(VkInstance instance, VkDebugReportCallbackLUNARG msgCallback); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDebugReportCallbackLUNARG)(VkInstance instance, VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackLUNARG* pCallback); +typedef VkResult (VKAPI_PTR *PFN_vkDestroyDebugReportCallbackLUNARG)(VkInstance instance, VkDebugReportCallbackLUNARG callback, const VkAllocationCallbacks *pAllocator); #ifdef VK_PROTOTYPES // DebugReport extension entrypoints -VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback( - VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDebugReportCallbackLUNARG* pMsgCallback); - -VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback( - VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback); - +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackCreateInfoLUNARG* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackLUNARG* pCallback); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackLUNARG callback, + const VkAllocationCallbacks* pAllocator); #endif // VK_PROTOTYPES #ifdef __cplusplus diff --git a/layers/device_limits.cpp b/layers/device_limits.cpp index c4e67c2d..d57ce6db 100644 --- a/layers/device_limits.cpp +++ b/layers/device_limits.cpp @@ -114,12 +114,24 @@ static void init_device_limits(layer_data *my_data, const VkAllocationCallbacks { option_str = getLayerOption("DeviceLimitsLogFilename"); log_output = getLayerLogOutput(option_str, "DeviceLimits"); - layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo; + memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); + dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgCreateInfo.flags = report_flags; + dbgCreateInfo.pfnCallback = log_callback; + dbgCreateInfo.pUserData = (void *) log_output; + layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, pAllocator, &callback); my_data->logging_callback.push_back(callback); } if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { - layer_create_msg_callback(my_data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo; + memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); + dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgCreateInfo.flags = report_flags; + dbgCreateInfo.pfnCallback = win32_debug_output_msg; + dbgCreateInfo.pUserData = NULL; + layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, pAllocator, &callback); my_data->logging_callback.push_back(callback); } @@ -191,7 +203,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance // Clean up logging callback, if any while (my_data->logging_callback.size() > 0) { VkDebugReportCallbackLUNARG callback = my_data->logging_callback.back(); - layer_destroy_msg_callback(my_data->report_data, callback); + layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); my_data->logging_callback.pop_back(); } @@ -550,29 +562,28 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( dev_data->device_dispatch_table->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback( - VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDebugReportCallbackLUNARG* pMsgCallback) +VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackCreateInfoLUNARG* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackLUNARG* pMsgCallback) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult res = my_data->instance_dispatch_table->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + VkResult res = my_data->instance_dispatch_table->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pMsgCallback); if (VK_SUCCESS == res) { - res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + res = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); } return res; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback( - VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback) +VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackLUNARG msgCallback, + const VkAllocationCallbacks* pAllocator) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult res = my_data->instance_dispatch_table->DbgDestroyMsgCallback(instance, msgCallback); - layer_destroy_msg_callback(my_data->report_data, msgCallback); - return res; + my_data->instance_dispatch_table->DestroyDebugReportCallbackLUNARG(instance, msgCallback, pAllocator); + layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); } VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char* funcName) diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 5ad5ee47..c2afbdc6 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -2569,12 +2569,24 @@ static void init_draw_state(layer_data *my_data, const VkAllocationCallbacks *pA { option_str = getLayerOption("DrawStateLogFilename"); log_output = getLayerLogOutput(option_str, "DrawState"); - layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = log_callback; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &callback); my_data->logging_callback.push_back(callback); } if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { - layer_create_msg_callback(my_data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = win32_debug_output_msg; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &callback); my_data->logging_callback.push_back(callback); } @@ -2617,7 +2629,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance // Clean up logging callback, if any while (my_data->logging_callback.size() > 0) { VkDebugReportCallbackLUNARG callback = my_data->logging_callback.back(); - layer_destroy_msg_callback(my_data->report_data, callback); + layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); my_data->logging_callback.pop_back(); } @@ -5409,29 +5421,30 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, return VK_ERROR_VALIDATION_FAILED; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback( - VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDebugReportCallbackLUNARG* pMsgCallback) +VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackCreateInfoLUNARG* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackLUNARG* pMsgCallback) { layer_data* my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult res = my_data->instance_dispatch_table->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; + VkResult res = pTable->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pMsgCallback); if (VK_SUCCESS == res) { - res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + res = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); } return res; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback( - VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback) +VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackLUNARG msgCallback, + const VkAllocationCallbacks* pAllocator) { layer_data* my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult res = my_data->instance_dispatch_table->DbgDestroyMsgCallback(instance, msgCallback); - layer_destroy_msg_callback(my_data->report_data, msgCallback); - return res; + VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; + pTable->DestroyDebugReportCallbackLUNARG(instance, msgCallback, pAllocator); + layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); } VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDbgMarkerBegin(VkCommandBuffer commandBuffer, const char* pMarker) diff --git a/layers/image.cpp b/layers/image.cpp index e4892864..cde964af 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -84,39 +84,49 @@ static void InitImage(layer_data *data, const VkAllocationCallbacks *pAllocator) FILE *log_output = NULL; const char* option_str = getLayerOption("ImageLogFilename"); log_output = getLayerLogOutput(option_str, "Image"); - layer_create_msg_callback(data->report_data, report_flags, log_callback, (void *) log_output, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = log_callback; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(data->report_data, &dbgInfo, pAllocator, &callback); data->logging_callback.push_back(callback); } if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { - layer_create_msg_callback(data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = win32_debug_output_msg; + dbgInfo.flags = report_flags; + layer_create_msg_callback(data->report_data, &dbgInfo, pAllocator, &callback); data->logging_callback.push_back(callback); } } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback( - VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDebugReportCallbackLUNARG* pMsgCallback) +VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackCreateInfoLUNARG* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackLUNARG* pMsgCallback) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult res = my_data->instance_dispatch_table->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + VkResult res = my_data->instance_dispatch_table->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pMsgCallback); if (res == VK_SUCCESS) { - res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + res = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); } return res; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback( - VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback) +VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackLUNARG msgCallback, + const VkAllocationCallbacks* pAllocator) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult res = my_data->instance_dispatch_table->DbgDestroyMsgCallback(instance, msgCallback); - layer_destroy_msg_callback(my_data->report_data, msgCallback); - return res; + my_data->instance_dispatch_table->DestroyDebugReportCallbackLUNARG(instance, msgCallback, pAllocator); + layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) @@ -145,7 +155,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance // Clean up logging callback, if any while (my_data->logging_callback.size() > 0) { VkDebugReportCallbackLUNARG callback = my_data->logging_callback.back(); - layer_destroy_msg_callback(my_data->report_data, callback); + layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); my_data->logging_callback.pop_back(); } diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index bd65bcbc..62a78ba8 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -1010,12 +1010,24 @@ init_mem_tracker( { option_str = getLayerOption("MemTrackerLogFilename"); log_output = getLayerLogOutput(option_str, "MemTracker"); - layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = log_callback; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &callback); my_data->logging_callback.push_back(callback); } if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { - layer_create_msg_callback(my_data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = win32_debug_output_msg; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &callback); my_data->logging_callback.push_back(callback); } @@ -1043,7 +1055,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( // Clean up logging callback, if any while (my_data->logging_callback.size() > 0) { VkDebugReportCallbackLUNARG callback = my_data->logging_callback.back(); - layer_destroy_msg_callback(my_data->report_data, callback); + layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); my_data->logging_callback.pop_back(); } @@ -2561,32 +2573,30 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool( my_data->device_dispatch_table->CmdResetQueryPool(commandBuffer, queryPool, startQuery, queryCount); } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback( - VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void *pUserData, - VkDebugReportCallbackLUNARG *pMsgCallback) +VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackCreateInfoLUNARG* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackLUNARG* pMsgCallback) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; - VkResult res = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + VkResult res = pTable->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pMsgCallback); if (res == VK_SUCCESS) { - res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + res = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); } return res; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback( - VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback) +VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG( + VkInstance instance, + VkDebugReportCallbackLUNARG msgCallback, + const VkAllocationCallbacks* pAllocator) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; - VkResult res = pTable->DbgDestroyMsgCallback(instance, msgCallback); - layer_destroy_msg_callback(my_data->report_data, msgCallback); - - return res; + pTable->DestroyDebugReportCallbackLUNARG(instance, msgCallback, pAllocator); + layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( diff --git a/layers/object_track.h b/layers/object_track.h index 14101519..08f36c7a 100644 --- a/layers/object_track.h +++ b/layers/object_track.h @@ -425,7 +425,13 @@ initObjectTracker( { option_str = getLayerOption("ObjectTrackerLogFilename"); log_output = getLayerLogOutput(option_str, "ObjectTracker"); - layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &(my_data->logging_callback)); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = log_callback; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &my_data->logging_callback); } if (!objLockInitialized) diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp index 42068a9d..0514bf18 100644 --- a/layers/param_checker.cpp +++ b/layers/param_checker.cpp @@ -96,46 +96,58 @@ static void InitParamChecker(layer_data *data, const VkAllocationCallbacks *pAll FILE *log_output = NULL; const char* option_str = getLayerOption("ParamCheckerLogFilename"); log_output = getLayerLogOutput(option_str, "ParamChecker"); - layer_create_msg_callback(data->report_data, report_flags, log_callback, (void *) log_output, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo; + memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); + dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgCreateInfo.flags = report_flags; + dbgCreateInfo.pfnCallback = log_callback; + dbgCreateInfo.pUserData = log_output; + + layer_create_msg_callback(data->report_data, &dbgCreateInfo, pAllocator, &callback); data->logging_callback.push_back(callback); } if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { - layer_create_msg_callback(data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo; + memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); + dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgCreateInfo.flags = report_flags; + dbgCreateInfo.pfnCallback = win32_debug_output_msg; + dbgCreateInfo.pUserData = NULL; + + layer_create_msg_callback(data->report_data, &dbgCreateInfo, pAllocator, &callback); data->logging_callback.push_back(callback); } } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback( +VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG( VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, + VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackLUNARG* pMsgCallback) { VkLayerInstanceDispatchTable *pTable = get_dispatch_table(pc_instance_table_map, instance); - VkResult result = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + VkResult result = pTable->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pMsgCallback); if (result == VK_SUCCESS) { layer_data *data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - result = layer_create_msg_callback(data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + result = layer_create_msg_callback(data->report_data, pCreateInfo, pAllocator, pMsgCallback); } return result; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback( +VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG( VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback) + VkDebugReportCallbackLUNARG msgCallback, + const VkAllocationCallbacks *pAllocator) { VkLayerInstanceDispatchTable *pTable = get_dispatch_table(pc_instance_table_map, instance); - VkResult result = pTable->DbgDestroyMsgCallback(instance, msgCallback); + pTable->DestroyDebugReportCallbackLUNARG(instance, msgCallback, pAllocator); layer_data *data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - layer_destroy_msg_callback(data->report_data, msgCallback); - - return result; + layer_destroy_msg_callback(data->report_data, msgCallback, pAllocator); } static const VkLayerProperties pc_global_layers[] = { @@ -1760,7 +1772,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( layer_data *my_data = get_my_data_ptr(key, layer_data_map); while (my_data->logging_callback.size() > 0) { VkDebugReportCallbackLUNARG callback = my_data->logging_callback.back(); - layer_destroy_msg_callback(my_data->report_data, callback); + layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); my_data->logging_callback.pop_back(); } diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 4c419288..2b8ed24c 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -126,13 +126,26 @@ static void initSwapchain(layer_data *my_data, const VkAllocationCallbacks *pAll // Turn on logging, since it was requested: option_str = getLayerOption("SwapchainLogFilename"); log_output = getLayerLogOutput(option_str, "Swapchain"); - layer_create_msg_callback(my_data->report_data, report_flags, - log_callback, (void *) log_output, + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = log_callback; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(my_data->report_data, + &dbgInfo, + pAllocator, &callback); my_data->logging_callback.push_back(callback); } if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { - layer_create_msg_callback(my_data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); + VkDebugReportCallbackCreateInfoLUNARG dbgInfo; + memset(&dbgInfo, 0, sizeof(dbgInfo)); + dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; + dbgInfo.pfnCallback = win32_debug_output_msg; + dbgInfo.pUserData = log_output; + dbgInfo.flags = report_flags; + layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &callback); my_data->logging_callback.push_back(callback); } } @@ -210,7 +223,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance // Clean up logging callback, if any while (my_data->logging_callback.size() > 0) { VkDebugReportCallbackLUNARG callback = my_data->logging_callback.back(); - layer_destroy_msg_callback(my_data->report_data, callback); + layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); my_data->logging_callback.pop_back(); } layer_debug_report_destroy_instance(my_data->report_data); @@ -1113,22 +1126,21 @@ static inline PFN_vkVoidFunction layer_intercept_instance_proc(const char *name) return NULL; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback(VkInstance instance, VkFlags msgFlags, const PFN_vkDbgMsgCallback pfnMsgCallback, void* pUserData, VkDebugReportCallbackLUNARG* pMsgCallback) +VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG(VkInstance instance, VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackLUNARG* pMsgCallback) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult result = my_data->instance_dispatch_table->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + VkResult result = my_data->instance_dispatch_table->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pMsgCallback); if (VK_SUCCESS == result) { - result = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + result = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); } return result; } -VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback(VkInstance instance, VkDebugReportCallbackLUNARG msgCallback) +VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG(VkInstance instance, VkDebugReportCallbackLUNARG msgCallback, const VkAllocationCallbacks *pAllocator) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - VkResult result = my_data->instance_dispatch_table->DbgDestroyMsgCallback(instance, msgCallback); - layer_destroy_msg_callback(my_data->report_data, msgCallback); - return result; + my_data->instance_dispatch_table->DestroyDebugReportCallbackLUNARG(instance, msgCallback, pAllocator); + layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); } VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* funcName) diff --git a/layers/vk_layer_config.cpp b/layers/vk_layer_config.cpp index 6d09a18e..4ca7b2cf 100755 --- a/layers/vk_layer_config.cpp +++ b/layers/vk_layer_config.cpp @@ -121,9 +121,9 @@ FILE* getLayerLogOutput(const char *_option, const char *layerName) return log_output; } -uint32_t getLayerOptionFlags(const char *_option, uint32_t optionDefault) +VkDebugReportFlagsLUNARG getLayerOptionFlags(const char *_option, uint32_t optionDefault) { - uint32_t flags = optionDefault; + VkDebugReportFlagsLUNARG flags = optionDefault; const char *option = (g_configFileObj.getOption(_option)); /* parse comma-separated options */ diff --git a/layers/vk_layer_config.h b/layers/vk_layer_config.h index c1fa1e15..167aaf67 100644 --- a/layers/vk_layer_config.h +++ b/layers/vk_layer_config.h @@ -32,7 +32,7 @@ extern "C" { const char *getLayerOption(const char *_option); FILE* getLayerLogOutput(const char *_option, const char *layerName); -uint32_t getLayerOptionFlags(const char *_option, uint32_t optionDefault); +VkDebugReportFlagsLUNARG getLayerOptionFlags(const char *_option, uint32_t optionDefault); bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault); void setLayerOption(const char *_option, const char *_val); diff --git a/layers/vk_layer_logging.h b/layers/vk_layer_logging.h index b603da82..325b3f05 100644 --- a/layers/vk_layer_logging.h +++ b/layers/vk_layer_logging.h @@ -88,8 +88,8 @@ static inline debug_report_data *debug_report_create_instance( debug_report_data *debug_data; PFN_vkGetInstanceProcAddr gpa = table->GetInstanceProcAddr; - table->DbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) gpa(inst, "vkDbgCreateMsgCallback"); - table->DbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) gpa(inst, "vkDbgDestroyMsgCallback"); + table->CreateDebugReportCallbackLUNARG = (PFN_vkCreateDebugReportCallbackLUNARG) gpa(inst, "vkCreateDebugReportCallbackLUNARG"); + table->DestroyDebugReportCallbackLUNARG = (PFN_vkDestroyDebugReportCallbackLUNARG) gpa(inst, "vkDestroyDebugReportCallbackLUNARG"); debug_data = (debug_report_data *) malloc(sizeof(debug_report_data)); if (!debug_data) return NULL; @@ -148,31 +148,31 @@ static inline void layer_debug_report_destroy_device(VkDevice device) } static inline VkResult layer_create_msg_callback( - debug_report_data *debug_data, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void *pUserData, - VkDebugReportCallbackLUNARG *pMsgCallback) + debug_report_data *debug_data, + VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkDebugReportCallbackLUNARG *pCallback) { + /* TODO: Use app allocator */ VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode*)malloc(sizeof(VkLayerDbgFunctionNode)); if (!pNewDbgFuncNode) return VK_ERROR_OUT_OF_HOST_MEMORY; // Handle of 0 is logging_callback so use allocated Node address as unique handle - if (!(*pMsgCallback)) - *pMsgCallback = (VkDebugReportCallbackLUNARG) pNewDbgFuncNode; - pNewDbgFuncNode->msgCallback = *pMsgCallback; - pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; - pNewDbgFuncNode->msgFlags = msgFlags; - pNewDbgFuncNode->pUserData = pUserData; + if (!(*pCallback)) + *pCallback = (VkDebugReportCallbackLUNARG) pNewDbgFuncNode; + pNewDbgFuncNode->msgCallback = *pCallback; + pNewDbgFuncNode->pfnMsgCallback = pCreateInfo->pfnCallback; + pNewDbgFuncNode->msgFlags = pCreateInfo->flags; + pNewDbgFuncNode->pUserData = pCreateInfo->pUserData; pNewDbgFuncNode->pNext = debug_data->g_pDbgFunctionHead; debug_data->g_pDbgFunctionHead = pNewDbgFuncNode; - debug_data->active_flags |= msgFlags; + debug_data->active_flags |= pCreateInfo->flags; debug_report_log_msg( debug_data, VK_DEBUG_REPORT_DEBUG_BIT, - VK_OBJECT_TYPE_MSG_CALLBACK, (uint64_t) *pMsgCallback, + VK_OBJECT_TYPE_MSG_CALLBACK, (uint64_t) *pCallback, 0, DEBUG_REPORT_CALLBACK_REF, "DebugReport", "Added callback"); @@ -181,7 +181,8 @@ static inline VkResult layer_create_msg_callback( static inline void layer_destroy_msg_callback( debug_report_data *debug_data, - VkDebugReportCallbackLUNARG msg_callback) + VkDebugReportCallbackLUNARG callback, + const VkAllocationCallbacks *pAllocator) { VkLayerDbgFunctionNode *pTrav = debug_data->g_pDbgFunctionHead; VkLayerDbgFunctionNode *pPrev = pTrav; @@ -189,7 +190,7 @@ static inline void layer_destroy_msg_callback( debug_data->active_flags = 0; while (pTrav) { - if (pTrav->msgCallback == msg_callback) { + if (pTrav->msgCallback == callback) { matched = true; pPrev->pNext = pTrav->pNext; if (debug_data->g_pDbgFunctionHead == pTrav) { @@ -208,6 +209,7 @@ static inline void layer_destroy_msg_callback( pPrev = pTrav; pTrav = pTrav->pNext; if (matched) { + /* TODO: Use pAllocator */ free(pPrev); } } @@ -221,11 +223,11 @@ static inline PFN_vkVoidFunction debug_report_get_instance_proc_addr( return NULL; } - if (!strcmp(funcName, "vkDbgCreateMsgCallback")) { - return (PFN_vkVoidFunction) vkDbgCreateMsgCallback; + if (!strcmp(funcName, "vkCreateDebugReportCallbackLUNARG")) { + return (PFN_vkVoidFunction) vkCreateDebugReportCallbackLUNARG; } - if (!strcmp(funcName, "vkDbgDestroyMsgCallback")) { - return (PFN_vkVoidFunction) vkDbgDestroyMsgCallback; + if (!strcmp(funcName, "vkDestroyDebugReportCallbackLUNARG")) { + return (PFN_vkVoidFunction) vkDestroyDebugReportCallbackLUNARG; } return NULL; @@ -294,7 +296,7 @@ static inline VkBool32 log_msg( static inline VKAPI_ATTR VkBool32 VKAPI_CALL log_callback( VkFlags msgFlags, - VkDebugReportObjectTypeLUNARG objType, + VkDebugReportObjectTypeLUNARG objType, uint64_t srcObject, size_t location, int32_t msgCode, @@ -315,7 +317,7 @@ static inline VKAPI_ATTR VkBool32 VKAPI_CALL log_callback( static inline VKAPI_ATTR VkBool32 VKAPI_CALL win32_debug_output_msg( VkFlags msgFlags, - VkDebugReportObjectTypeLUNARG objType, + VkDebugReportObjectTypeLUNARG objType, uint64_t srcObject, size_t location, int32_t msgCode, diff --git a/layers/vk_layer_settings.txt b/layers/vk_layer_settings.txt index 1aee14f5..5634c9b7 100644 --- a/layers/vk_layer_settings.txt +++ b/layers/vk_layer_settings.txt @@ -14,7 +14,7 @@ # VK_DBG_LAYER_ACTION_LOG_MSG - Log a txt message to stdout or to a log file # specified via the LogFilename setting (see below) # VK_DBG_LAYER_ACTION_CALLBACK - Call user defined callback function(s) that -# have been registered via the vkDbgCreateMsgCallback() extension. Since +# have been registered via the VK_EXT_LUNARG_debug_report extension. Since # app must register callback, this is a NOOP for the settings file. # VK_DBG_LAYER_ACTION_BREAK - Trigger a breakpoint. # diff --git a/loader/debug_report.c b/loader/debug_report.c index b7057e6c..f6b3a31a 100644 --- a/loader/debug_report.c +++ b/loader/debug_report.c @@ -65,12 +65,11 @@ void debug_report_create_instance( } } -static VKAPI_ATTR VkResult VKAPI_CALL debug_report_DbgCreateMsgCallback( +static VKAPI_ATTR VkResult VKAPI_CALL debug_report_CreateDebugReportCallback( VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDebugReportCallbackLUNARG* pMsgCallback) + VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, + VkAllocationCallbacks *pAllocator, + VkDebugReportCallbackLUNARG* pCallback) { VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode *) loader_heap_alloc((struct loader_instance *)instance, sizeof(VkLayerDbgFunctionNode), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!pNewDbgFuncNode) @@ -78,12 +77,12 @@ static VKAPI_ATTR VkResult VKAPI_CALL debug_report_DbgCreateMsgCallback( struct loader_instance *inst = loader_get_instance(instance); loader_platform_thread_lock_mutex(&loader_lock); - VkResult result = inst->disp->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + VkResult result = inst->disp->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pCallback); if (result == VK_SUCCESS) { - pNewDbgFuncNode->msgCallback = *pMsgCallback; - pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; - pNewDbgFuncNode->msgFlags = msgFlags; - pNewDbgFuncNode->pUserData = pUserData; + pNewDbgFuncNode->msgCallback = *pCallback; + pNewDbgFuncNode->pfnMsgCallback = pCreateInfo->pfnCallback; + pNewDbgFuncNode->msgFlags = pCreateInfo->flags; + pNewDbgFuncNode->pUserData = pCreateInfo->pUserData; pNewDbgFuncNode->pNext = inst->DbgFunctionHead; inst->DbgFunctionHead = pNewDbgFuncNode; } else { @@ -93,19 +92,20 @@ static VKAPI_ATTR VkResult VKAPI_CALL debug_report_DbgCreateMsgCallback( return result; } -static VKAPI_ATTR VkResult VKAPI_CALL debug_report_DbgDestroyMsgCallback( +static VKAPI_ATTR VkResult VKAPI_CALL debug_report_DestroyDebugReportCallback( VkInstance instance, - VkDebugReportCallbackLUNARG msg_callback) + VkDebugReportCallbackLUNARG callback, + VkAllocationCallbacks *pAllocator) { struct loader_instance *inst = loader_get_instance(instance); loader_platform_thread_lock_mutex(&loader_lock); VkLayerDbgFunctionNode *pTrav = inst->DbgFunctionHead; VkLayerDbgFunctionNode *pPrev = pTrav; - VkResult result = inst->disp->DbgDestroyMsgCallback(instance, msg_callback); + VkResult result = inst->disp->DestroyDebugReportCallbackLUNARG(instance, callback, pAllocator); while (pTrav) { - if (pTrav->msgCallback == msg_callback) { + if (pTrav->msgCallback == callback) { pPrev->pNext = pTrav->pNext; if (inst->DbgFunctionHead == pTrav) inst->DbgFunctionHead = pTrav->pNext; @@ -123,15 +123,14 @@ static VKAPI_ATTR VkResult VKAPI_CALL debug_report_DbgDestroyMsgCallback( /* * This is the instance chain terminator function - * for DbgCreateMsgCallback + * for CreateDebugReportCallback */ -VKAPI_ATTR VkResult VKAPI_CALL loader_DbgCreateMsgCallback( - VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDebugReportCallbackLUNARG* pMsgCallback) +VKAPI_ATTR VkResult VKAPI_CALL loader_CreateDebugReportCallback( + VkInstance instance, + VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkDebugReportCallbackLUNARG *pCallback) { VkDebugReportCallbackLUNARG *icd_info; const struct loader_icd *icd; @@ -151,16 +150,15 @@ VKAPI_ATTR VkResult VKAPI_CALL loader_DbgCreateMsgCallback( storage_idx = 0; for (icd = inst->icds; icd; icd = icd->next) { - if (!icd->DbgCreateMsgCallback) { + if (!icd->CreateDebugReportCallbackLUNARG) { continue; } - res = icd->DbgCreateMsgCallback( - icd->instance, - msgFlags, - pfnMsgCallback, - pUserData, - &icd_info[storage_idx]); + res = icd->CreateDebugReportCallbackLUNARG( + icd->instance, + pCreateInfo, + pAllocator, + &icd_info[storage_idx]); if (res != VK_SUCCESS) { break; @@ -173,9 +171,10 @@ VKAPI_ATTR VkResult VKAPI_CALL loader_DbgCreateMsgCallback( storage_idx = 0; for (icd = inst->icds; icd; icd = icd->next) { if (icd_info[storage_idx]) { - icd->DbgDestroyMsgCallback( + icd->DestroyDebugReportCallbackLUNARG( icd->instance, - icd_info[storage_idx]); + icd_info[storage_idx], + pAllocator); } storage_idx++; } @@ -183,18 +182,17 @@ VKAPI_ATTR VkResult VKAPI_CALL loader_DbgCreateMsgCallback( return res; } - *(VkDebugReportCallbackLUNARG **)pMsgCallback = icd_info; + *(VkDebugReportCallbackLUNARG **)pCallback = icd_info; return VK_SUCCESS; } /* * This is the instance chain terminator function - * for DbgDestroyMsgCallback + * for DestroyDebugReportCallback */ -VKAPI_ATTR VkResult VKAPI_CALL loader_DbgDestroyMsgCallback( - VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback) +VKAPI_ATTR VkResult VKAPI_CALL loader_DestroyDebugReportCallback(VkInstance instance, + VkDebugReportCallbackLUNARG callback, const VkAllocationCallbacks *pAllocator) { uint32_t storage_idx; VkDebugReportCallbackLUNARG *icd_info; @@ -207,13 +205,14 @@ VKAPI_ATTR VkResult VKAPI_CALL loader_DbgDestroyMsgCallback( break; } - icd_info = *(VkDebugReportCallbackLUNARG **) &msgCallback; + icd_info = *(VkDebugReportCallbackLUNARG **) &callback; storage_idx = 0; for (icd = inst->icds; icd; icd = icd->next) { if (icd_info[storage_idx]) { - icd->DbgDestroyMsgCallback( + icd->DestroyDebugReportCallbackLUNARG( icd->instance, - icd_info[storage_idx]); + icd_info[storage_idx], + pAllocator); } storage_idx++; } @@ -229,12 +228,12 @@ bool debug_report_instance_gpa( // so always return the entry points if name matches and it's enabled *addr = NULL; - if (!strcmp("vkDbgCreateMsgCallback", name)) { - *addr = ptr_instance->debug_report_enabled ? (void *) debug_report_DbgCreateMsgCallback : NULL; + if (!strcmp("vkCreateDebugReportCallbackLUNARG", name)) { + *addr = ptr_instance->debug_report_enabled ? (void *) debug_report_CreateDebugReportCallback : NULL; return true; } - if (!strcmp("vkDbgDestroyMsgCallback", name)) { - *addr = ptr_instance->debug_report_enabled ? (void *) debug_report_DbgDestroyMsgCallback : NULL; + if (!strcmp("vkDestroyDebugReportCallbackLUNARG", name)) { + *addr = ptr_instance->debug_report_enabled ? (void *) debug_report_DestroyDebugReportCallback : NULL; return true; } return false; diff --git a/loader/debug_report.h b/loader/debug_report.h index a6107a7f..82100214 100644 --- a/loader/debug_report.h +++ b/loader/debug_report.h @@ -102,13 +102,13 @@ bool debug_report_instance_gpa( const char* name, void **addr); -VKAPI_ATTR VkResult VKAPI_CALL loader_DbgCreateMsgCallback( - VkInstance instance, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDebugReportCallbackLUNARG* pMsgCallback); +VKAPI_ATTR VkResult VKAPI_CALL loader_CreateDebugReportCallback( + VkInstance instance, + VkDebugReportCallbackCreateInfoLUNARG *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkDebugReportCallbackLUNARG *pCallback); -VKAPI_ATTR VkResult VKAPI_CALL loader_DbgDestroyMsgCallback( - VkInstance instance, - VkDebugReportCallbackLUNARG msgCallback); +VKAPI_ATTR VkResult VKAPI_CALL loader_DestroyDebugReportCallback( + VkInstance instance, + VkDebugReportCallbackLUNARG callback, + const VkAllocationCallbacks *pAllocator); diff --git a/loader/loader.c b/loader/loader.c index 5673be41..6e37f061 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -114,8 +114,8 @@ const VkLayerInstanceDispatchTable instance_disp = { .GetPhysicalDeviceSurfaceCapabilitiesKHR = loader_GetPhysicalDeviceSurfaceCapabilitiesKHR, .GetPhysicalDeviceSurfaceFormatsKHR = loader_GetPhysicalDeviceSurfaceFormatsKHR, .GetPhysicalDeviceSurfacePresentModesKHR = loader_GetPhysicalDeviceSurfacePresentModesKHR, - .DbgCreateMsgCallback = loader_DbgCreateMsgCallback, - .DbgDestroyMsgCallback = loader_DbgDestroyMsgCallback, + .CreateDebugReportCallbackLUNARG = loader_CreateDebugReportCallback, + .DestroyDebugReportCallbackLUNARG = loader_DestroyDebugReportCallback, #ifdef VK_USE_PLATFORM_MIR_KHR .CreateMirSurfaceKHR = loader_CreateMirSurfaceKHR, .GetPhysicalDeviceMirPresentationSupportKHR = loader_GetPhysicalDeviceMirPresentationSupportKHR, @@ -1341,8 +1341,8 @@ static bool loader_icd_init_entrys(struct loader_icd *icd, LOOKUP_GIPA(GetPhysicalDeviceQueueFamilyProperties, true); LOOKUP_GIPA(EnumerateDeviceExtensionProperties, true); LOOKUP_GIPA(GetPhysicalDeviceSparseImageFormatProperties, true); - LOOKUP_GIPA(DbgCreateMsgCallback, false); - LOOKUP_GIPA(DbgDestroyMsgCallback, false); + LOOKUP_GIPA(CreateDebugReportCallbackLUNARG, false); + LOOKUP_GIPA(DestroyDebugReportCallbackLUNARG, false); LOOKUP_GIPA(GetPhysicalDeviceSurfaceSupportKHR, false); LOOKUP_GIPA(GetPhysicalDeviceSurfaceCapabilitiesKHR, false); LOOKUP_GIPA(GetPhysicalDeviceSurfaceFormatsKHR, false); diff --git a/loader/loader.h b/loader/loader.h index 2b44de3b..0c0c94a8 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -188,8 +188,8 @@ struct loader_icd { PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties; - PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback; - PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback; + PFN_vkCreateDebugReportCallbackLUNARG CreateDebugReportCallbackLUNARG; + PFN_vkDestroyDebugReportCallbackLUNARG DestroyDebugReportCallbackLUNARG; PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR; PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; diff --git a/loader/table_ops.h b/loader/table_ops.h index ed9f8d6f..7cbb51c9 100644 --- a/loader/table_ops.h +++ b/loader/table_ops.h @@ -468,9 +468,9 @@ static inline void loader_init_instance_extension_dispatch_table( PFN_vkGetInstanceProcAddr gpa, VkInstance inst) { - table->DbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) gpa(inst, "vkDbgCreateMsgCallback"); - table->DbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) gpa(inst, "vkDbgDestroyMsgCallback"); table->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) gpa(inst, "vkDestroySurfaceKHR"); + table->CreateDebugReportCallbackLUNARG = (PFN_vkCreateDebugReportCallbackLUNARG) gpa(inst, "vkCreateDebugReportCallbackLUNARG"); + table->DestroyDebugReportCallbackLUNARG = (PFN_vkDestroyDebugReportCallbackLUNARG) gpa(inst, "vkDestroyDebugReportCallbackLUNARG"); table->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(inst, "vkGetPhysicalDeviceSurfaceSupportKHR"); table->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(inst, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); table->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(inst, "vkGetPhysicalDeviceSurfaceFormatsKHR"); @@ -571,10 +571,10 @@ static inline void *loader_lookup_instance_dispatch_table( if (!strcmp(name, "GetPhysicalDeviceXlibPresentationSupportKHR")) return (void *) table->GetPhysicalDeviceXlibPresentationSupportKHR; #endif - if (!strcmp(name, "DbgCreateMsgCallback")) - return (void *) table->DbgCreateMsgCallback; - if (!strcmp(name, "DbgDestroyMsgCallback")) - return (void *) table->DbgDestroyMsgCallback; + if (!strcmp(name, "CreateDebugReportCallbackLUNARG")) + return (void *) table->CreateDebugReportCallbackLUNARG; + if (!strcmp(name, "DestroyDebugReportCallbackLUNARG")) + return (void *) table->DestroyDebugReportCallbackLUNARG; return NULL; } diff --git a/vk-layer-generate.py b/vk-layer-generate.py index 43bd11ce..7eaf3271 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -227,22 +227,28 @@ class Subcommand(object): def _gen_create_msg_callback(self): r_body = [] r_body.append('%s' % self.lineinfo.get()) - r_body.append('VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgCreateMsgCallback(VkInstance instance, VkFlags msgFlags, const PFN_vkDbgMsgCallback pfnMsgCallback, void* pUserData, VkDebugReportCallbackLUNARG* pMsgCallback)') + r_body.append('VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackLUNARG(VkInstance instance,') + r_body.append(' VkDebugReportCallbackCreateInfoLUNARG* pCreateInfo,') + r_body.append(' const VkAllocationCallbacks* pAllocator,') + r_body.append(' VkDebugReportCallbackLUNARG* pCallback)') r_body.append('{') # Switch to this code section for the new per-instance storage and debug callbacks if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading': r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(%s_instance_table_map, instance);' % self.layer_name ) - r_body.append(' VkResult result = pInstanceTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);') + r_body.append(' VkResult result = pInstanceTable->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pCallback);') r_body.append(' if (VK_SUCCESS == result) {') r_body.append(' layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);') - r_body.append(' result = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);') + r_body.append(' result = layer_create_msg_callback(my_data->report_data,') + r_body.append(' pCreateInfo,') + r_body.append(' pAllocator,') + r_body.append(' pCallback);') r_body.append(' }') r_body.append(' return result;') else: - r_body.append(' VkResult result = instance_dispatch_table(instance)->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);') + r_body.append(' VkResult result = instance_dispatch_table(instance)->CreateDebugReportCallbackLUNARG(instance, pCreateInfo, pAllocator, pCallback);') r_body.append(' if (VK_SUCCESS == result) {') r_body.append(' layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);') - r_body.append(' result = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);') + r_body.append(' result = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pCallback);') r_body.append(' }') r_body.append(' return result;') r_body.append('}') @@ -251,20 +257,16 @@ class Subcommand(object): def _gen_destroy_msg_callback(self): r_body = [] r_body.append('%s' % self.lineinfo.get()) - r_body.append('VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDbgDestroyMsgCallback(VkInstance instance, VkDebugReportCallbackLUNARG msgCallback)') + r_body.append('VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackLUNARG(VkInstance instance, VkDebugReportCallbackLUNARG msgCallback, const VkAllocationCallbacks *pAllocator)') r_body.append('{') # Switch to this code section for the new per-instance storage and debug callbacks if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading': r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(%s_instance_table_map, instance);' % self.layer_name ) - r_body.append(' VkResult result = pInstanceTable->DbgDestroyMsgCallback(instance, msgCallback);') - r_body.append(' layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);') - r_body.append(' layer_destroy_msg_callback(my_data->report_data, msgCallback);') - r_body.append(' return result;') else: - r_body.append(' VkResult result = instance_dispatch_table(instance)->DbgDestroyMsgCallback(instance, msgCallback);') - r_body.append(' layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);') - r_body.append(' layer_destroy_msg_callback(my_data->report_data, msgCallback);') - r_body.append(' return result;') + r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = instance_dispatch_table(instance);') + r_body.append(' pInstanceTable->DestroyDebugReportCallbackLUNARG(instance, msgCallback, pAllocator);') + r_body.append(' layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);') + r_body.append(' layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator);') r_body.append('}') return "\n".join(r_body) @@ -339,9 +341,9 @@ class Subcommand(object): intercept = self.generate_intercept(proto, qual) if intercept is None: # fill in default intercept for certain entrypoints - if 'DbgCreateMsgCallback' == proto.name: + if 'CreateDebugReportCallbackLUNARG' == proto.name: intercept = self._gen_layer_dbg_create_msg_callback() - elif 'DbgDestroyMsgCallback' == proto.name: + elif 'DestroyDebugReportCallbackLUNARG' == proto.name: intercept = self._gen_layer_dbg_destroy_msg_callback() elif 'CreateDevice' == proto.name: funcs.append('/* CreateDevice HERE */') @@ -626,8 +628,13 @@ class Subcommand(object): func_body.append(' {') func_body.append(' option_str = getLayerOption("%sLogFilename");' % self.layer_name) func_body.append(' log_output = getLayerLogOutput(option_str,"%s");' % self.layer_name) - func_body.append(' layer_create_msg_callback(my_data->report_data, report_flags,') - func_body.append(' log_callback, (void *) log_output,') + func_body.append(' VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo;') + func_body.append(' memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));') + func_body.append(' dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG;') + func_body.append(' dbgCreateInfo.flags = report_flags;') + func_body.append(' dbgCreateInfo.pfnCallback = log_callback;') + func_body.append(' dbgCreateInfo.pUserData = NULL;') + func_body.append(' layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, pAllocator,') func_body.append(' &my_data->logging_callback);') func_body.append(' }') func_body.append('') @@ -664,7 +671,14 @@ class Subcommand(object): func_body.append(' {') func_body.append(' strOpt = getLayerOption("%sLogFilename");' % self.layer_name) func_body.append(' log_output = getLayerLogOutput(strOpt, "%s");' % self.layer_name) - func_body.append(' layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &my_data->logging_callback);') + func_body.append(' VkDebugReportCallbackCreateInfoLUNARG dbgCreateInfo;') + func_body.append(' memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));') + func_body.append(' dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG;') + func_body.append(' dbgCreateInfo.flags = report_flags;') + func_body.append(' dbgCreateInfo.pfnCallback = log_callback;') + func_body.append(' dbgCreateInfo.pUserData = log_output;') + func_body.append(' layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, pAllocator,') + func_body.append(' &my_data->logging_callback);') func_body.append(' }') func_body.append('') if lockname is not None: @@ -769,7 +783,7 @@ class GenericLayerSubcommand(Subcommand): ' // Clean up logging callback, if any\n' ' layer_data *my_data = get_my_data_ptr(key, layer_data_map);\n' ' if (my_data->logging_callback) {\n' - ' layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback);\n' + ' layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback, pAllocator);\n' ' }\n\n' ' layer_debug_report_destroy_instance(my_data->report_data);\n' ' layer_data_map.erase(key);\n' @@ -1493,7 +1507,7 @@ class ObjectTrackerSubcommand(Subcommand): gedi_txt.append(' // Clean up logging callback, if any') gedi_txt.append(' layer_data *my_data = get_my_data_ptr(key, layer_data_map);') gedi_txt.append(' if (my_data->logging_callback) {') - gedi_txt.append(' layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback);') + gedi_txt.append(' layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback, pAllocator);') gedi_txt.append(' }') gedi_txt.append('') gedi_txt.append(' layer_debug_report_destroy_instance(mid(instance));') @@ -1571,7 +1585,7 @@ class ObjectTrackerSubcommand(Subcommand): return "\n".join(cbv_txt) def generate_intercept(self, proto, qual): - if proto.name in [ 'DbgCreateMsgCallback', 'EnumerateInstanceLayerProperties', 'EnumerateInstanceExtensionProperties','EnumerateDeviceLayerProperties', 'EnumerateDeviceExtensionProperties' ]: + if proto.name in [ 'CreateDebugReportCallbackLUNARG', 'EnumerateInstanceLayerProperties', 'EnumerateInstanceExtensionProperties','EnumerateDeviceLayerProperties', 'EnumerateDeviceExtensionProperties' ]: # use default version return None @@ -1961,7 +1975,7 @@ class ThreadingSubcommand(Subcommand): return "\n".join(header_txt) def generate_intercept(self, proto, qual): - if proto.name in [ 'DbgCreateMsgCallback' ]: + if proto.name in [ 'CreateDebugReportCallbackLUNARG' ]: # use default version return None decl = proto.c_func(prefix="vk", attr="VKAPI") @@ -2055,7 +2069,7 @@ class ThreadingSubcommand(Subcommand): ' // Clean up logging callback, if any\n' ' layer_data *my_data = get_my_data_ptr(key, layer_data_map);\n' ' if (my_data->logging_callback) {\n' - ' layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback);\n' + ' layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback, pAllocator);\n' ' }\n' '\n' ' layer_debug_report_destroy_instance(my_data->report_data);\n' diff --git a/vk_helper.py b/vk_helper.py index c875c2c9..0d050839 100755 --- a/vk_helper.py +++ b/vk_helper.py @@ -1349,6 +1349,7 @@ class StructWrapperGen: def _generateSizeHelperHeaderC(self): header = [] header.append('#include "vk_struct_size_helper.h"') + header.append('#include "vulkan/vk_lunarg_debug_report.h"') header.append('#include ') header.append('#include ') header.append('\n// Function definitions\n') diff --git a/vulkan.py b/vulkan.py index 1e32b2d8..897688f8 100755 --- a/vulkan.py +++ b/vulkan.py @@ -192,7 +192,7 @@ class Extension(object): # VK core API core = Extension( name="VK_CORE", - headers=["vulkan/vulkan.h", "vk_lunarg_debug_report.h"], + headers=["vulkan/vulkan.h", "vulkan/vk_lunarg_debug_report.h"], objects=[ "VkInstance", "VkPhysicalDevice", @@ -1124,16 +1124,16 @@ lunarg_debug_report = Extension( "VkDebugReportCallbackLUNARG", ], protos=[ - Proto("VkResult", "DbgCreateMsgCallback", + Proto("VkResult", "CreateDebugReportCallbackLUNARG", [Param("VkInstance", "instance"), - Param("VkFlags", "msgFlags"), - Param("const PFN_vkDbgMsgCallback", "pfnMsgCallback"), - Param("void*", "pUserData"), - Param("VkDebugReportCallbackLUNARG*", "pMsgCallback")]), + Param("VkDebugReportCallbackCreateInfoLUNARG*", "pCreateInfo"), + Param("const VkAllocationCallbacks*", "pAllocator"), + Param("VkDebugReportCallbackLUNARG*", "pCallback")]), - Proto("VkResult", "DbgDestroyMsgCallback", + Proto("VkResult", "DestroyDebugReportCallbackLUNARG", [Param("VkInstance", "instance"), - Param("VkDebugReportCallbackLUNARG", "msgCallback")]), + Param("VkDebugReportCallbackLUNARG", "callback"), + Param("const VkAllocationCallbacks*", "pAllocator")]), ], ) lunarg_debug_marker = Extension( @@ -1269,7 +1269,7 @@ def parse_vk_h(filename): # make them an extension and print ext = Extension("VK_CORE", - headers=["vulkan/vulkan.h", "vk_lunarg_debug_report.h"], + headers=["vulkan/vulkan.h", "vulkan/vk_lunarg_debug_report.h"], objects=object_lines, protos=protos) print("core =", str(ext)) -- cgit v1.2.3