Thanks.
How to give information to a “Vulkan Create function” such as “vkCreateGraphicsPipelines”? For examples give inputs “Name, Type, File, Line-Number, etc.” to that create function, so all the multiple “Custom Malloc(s)” inside it will use those inputs. My goal is to fix memory leak problem, so less precise information (input) is enough just for hints to fix memory leak.
How about pUserData?
I found an example but I don’t believe it will help me, the code below is from “Vulkan C++ examples and demos > examples > debugmaker.cpp” (GitHub - SaschaWillems/Vulkan: Examples and demos for the new Vulkan API), but the big problem is ‘active’ is always false because vkDebugMarkerSetObjectName and the others variables are all ‘nullptr’. It’s explained in the comment below that a “graphics debugger” is needed. But the problem is it requires Visual Studio 2017, and I’m using Visual Studio 2015. Also, I don’t believe it will help me because it only requires a “graphics debugger”, so I’m stuck.
bool active = false;
bool extensionPresent = false;
PFN_vkDebugMarkerSetObjectTagEXT vkDebugMarkerSetObjectTag = VK_NULL_HANDLE;
PFN_vkDebugMarkerSetObjectNameEXT vkDebugMarkerSetObjectName = VK_NULL_HANDLE;
PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBegin = VK_NULL_HANDLE;
PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEnd = VK_NULL_HANDLE;
PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsert = VK_NULL_HANDLE;
// Get function pointers for the debug report extensions from the device
void setup(VkDevice device, VkPhysicalDevice physicalDevice)
{
// Check if the debug marker extension is present (which is the case if run from a graphics debugger)
uint32_t extensionCount;
vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extensionCount, nullptr);
std::vector<VkExtensionProperties> extensions(extensionCount);
vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extensionCount, extensions.data());
for (auto extension : extensions) {
if (strcmp(extension.extensionName, VK_EXT_DEBUG_MARKER_EXTENSION_NAME) == 0) {
extensionPresent = true;
break;
}
}
if (extensionPresent) {
// The debug marker extension is not part of the core, so function pointers need to be loaded manually
vkDebugMarkerSetObjectTag = (PFN_vkDebugMarkerSetObjectTagEXT)vkGetDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT");
vkDebugMarkerSetObjectName = (PFN_vkDebugMarkerSetObjectNameEXT)vkGetDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT");
vkCmdDebugMarkerBegin = (PFN_vkCmdDebugMarkerBeginEXT)vkGetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT");
vkCmdDebugMarkerEnd = (PFN_vkCmdDebugMarkerEndEXT)vkGetDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT");
vkCmdDebugMarkerInsert = (PFN_vkCmdDebugMarkerInsertEXT)vkGetDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT");
// Set flag if at least one function pointer is present
active = (vkDebugMarkerSetObjectName != VK_NULL_HANDLE);
}
else {
std::cout << "Warning: " << VK_EXT_DEBUG_MARKER_EXTENSION_NAME << " not present, debug markers are disabled.";
std::cout << "Try running from inside a Vulkan graphics debugger (e.g. RenderDoc)" << std::endl;
}
}
Why am I showing it? Because of the code below, but ‘active’ is always false, because I’m not using a “debugging application” or “graphics debugger”, just my own C++ app.
// Sets the debug name of an object
// All Objects in Vulkan are represented by their 64-bit handles which are passed into this function
// along with the object type
void setObjectName(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT objectType, const char *name)
{
// Check for valid function pointer (may not be present if not running in a debugging application)
if (active)
{
VkDebugMarkerObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = objectType;
nameInfo.object = object;
nameInfo.pObjectName = name;
vkDebugMarkerSetObjectName(device, &nameInfo);
}
}
The code below is not important to read, just in case someone else needs to know how to display unfreed memory when the program exits (outputs will show up when vkDestroyDevice and vkDestroyInstance are called), but it will show that all ‘name’ are NULL because they are not set, and I’m not using a “graphics debugger” (origin of the code: ImGui SDL Vulkan):
static void CleanupVulkan()
{
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
#ifdef IMGUI_VULKAN_DEBUG_REPORT
// Remove the debug report callback
auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
#endif // IMGUI_VULKAN_DEBUG_REPORT
vkDestroyDevice(g_Device, g_Allocator);
vkDestroyInstance(g_Instance, g_Allocator);
}
Back to the question: “Why cannot I set vkDebugMarkerSetObjectName? And it’s always nullptr”.
Simpler question: “DebugReport” is designed for “graphics debugger”, so I would prefer using the custom allocation callback, using of pUserData, because it’s simpler, but I don’t know how to do it, but how?