loader: Only use driver's DebugReport if it has one
Change-Id: Ic020b9d5a95c9ddd20dd4c94fd6e7de050b83f2b
(cherry picked from commit b776ba1cff149bb724a1958cc3f470ba5c113b63)
diff --git a/vulkan/libvulkan/debug_report.cpp b/vulkan/libvulkan/debug_report.cpp
index fea9f18..41b6040 100644
--- a/vulkan/libvulkan/debug_report.cpp
+++ b/vulkan/libvulkan/debug_report.cpp
@@ -23,11 +23,16 @@
const VkDebugReportCallbackCreateInfoEXT* create_info,
const VkAllocationCallbacks* allocator,
VkDebugReportCallbackEXT* callback) {
- VkDebugReportCallbackEXT driver_callback;
- VkResult result = GetDriverDispatch(instance).CreateDebugReportCallbackEXT(
- GetDriverInstance(instance), create_info, allocator, &driver_callback);
- if (result != VK_SUCCESS)
- return result;
+ VkDebugReportCallbackEXT driver_callback = VK_NULL_HANDLE;
+
+ if (GetDriverDispatch(instance).CreateDebugReportCallbackEXT) {
+ VkResult result =
+ GetDriverDispatch(instance).CreateDebugReportCallbackEXT(
+ GetDriverInstance(instance), create_info, allocator,
+ &driver_callback);
+ if (result != VK_SUCCESS)
+ return result;
+ }
const VkAllocationCallbacks* alloc =
allocator ? allocator : GetAllocator(instance);
@@ -35,8 +40,10 @@
alloc->pfnAllocation(alloc->pUserData, sizeof(Node), alignof(Node),
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!mem) {
- GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
- GetDriverInstance(instance), driver_callback, allocator);
+ if (GetDriverDispatch(instance).DestroyDebugReportCallbackEXT) {
+ GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
+ GetDriverInstance(instance), driver_callback, allocator);
+ }
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
@@ -61,8 +68,10 @@
prev->next = node->next;
lock.unlock();
- GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
- GetDriverInstance(instance), node->driver_callback, allocator);
+ if (GetDriverDispatch(instance).DestroyDebugReportCallbackEXT) {
+ GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
+ GetDriverInstance(instance), node->driver_callback, allocator);
+ }
const VkAllocationCallbacks* alloc =
allocator ? allocator : GetAllocator(instance);
@@ -112,9 +121,11 @@
int32_t message_code,
const char* layer_prefix,
const char* message) {
- GetDriverDispatch(instance).DebugReportMessageEXT(
- GetDriverInstance(instance), flags, object_type, object, location,
- message_code, layer_prefix, message);
+ if (GetDriverDispatch(instance).DebugReportMessageEXT) {
+ GetDriverDispatch(instance).DebugReportMessageEXT(
+ GetDriverInstance(instance), flags, object_type, object, location,
+ message_code, layer_prefix, message);
+ }
GetDebugReportCallbacks(instance).Message(flags, object_type, object,
location, message_code,
layer_prefix, message);