Skip to content

Commit

Permalink
loader: Fix debug utils terminators being skipped
Browse files Browse the repository at this point in the history
Change-Id: I9e08b59669bd301e3c5361ae4ea16102461fb34b
  • Loading branch information
lenny-lunarg committed Feb 1, 2020
1 parent fb94ccd commit 9fdca38
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 31 deletions.
34 changes: 30 additions & 4 deletions loader/loader.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
*
* Copyright (c) 2014-2019 The Khronos Group Inc.
* Copyright (c) 2014-2019 Valve Corporation
* Copyright (c) 2014-2019 LunarG, Inc.
* Copyright (c) 2014-2020 The Khronos Group Inc.
* Copyright (c) 2014-2020 Valve Corporation
* Copyright (c) 2014-2020 LunarG, Inc.
* Copyright (C) 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -2044,7 +2044,7 @@ VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance
return res;
}

struct loader_icd_term *loader_get_icd_and_device(const VkDevice device, struct loader_device **found_dev, uint32_t *icd_index) {
struct loader_icd_term *loader_get_icd_and_device(const void* device, struct loader_device **found_dev, uint32_t *icd_index) {
*found_dev = NULL;
for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) {
uint32_t index = 0;
Expand Down Expand Up @@ -4852,6 +4852,32 @@ static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_instance_internal(VkI
return (PFN_vkVoidFunction)terminator_CreateDevice;
}

// The VK_EXT_debug_utils functions need a special case here so the terminators can still be found from vkGetInstanceProcAddr
if (!strcmp(pName, "vkSetDebugUtilsObjectNameEXT")) {
return (PFN_vkVoidFunction)terminator_SetDebugUtilsObjectNameEXT;
}
if (!strcmp(pName, "vkSetDebugUtilsObjectTagEXT")) {
return (PFN_vkVoidFunction)terminator_SetDebugUtilsObjectTagEXT;
}
if (!strcmp(pName, "vkQueueBeginDebugUtilsLabelEXT")) {
return (PFN_vkVoidFunction)terminator_QueueBeginDebugUtilsLabelEXT;
}
if (!strcmp(pName, "vkQueueEndDebugUtilsLabelEXT")) {
return (PFN_vkVoidFunction)terminator_QueueEndDebugUtilsLabelEXT;
}
if (!strcmp(pName, "vkQueueInsertDebugUtilsLabelEXT")) {
return (PFN_vkVoidFunction)terminator_QueueInsertDebugUtilsLabelEXT;
}
if (!strcmp(pName, "vkCmdBeginDebugUtilsLabelEXT")) {
return (PFN_vkVoidFunction)terminator_CmdBeginDebugUtilsLabelEXT;
}
if (!strcmp(pName, "vkCmdEndDebugUtilsLabelEXT")) {
return (PFN_vkVoidFunction)terminator_CmdEndDebugUtilsLabelEXT;
}
if (!strcmp(pName, "vkCmdInsertDebugUtilsLabelEXT")) {
return (PFN_vkVoidFunction)terminator_CmdInsertDebugUtilsLabelEXT;
}

// inst is not wrapped
if (inst == VK_NULL_HANDLE) {
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion loader/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void loaderScanForImplicitLayers(struct loader_instance *inst, struct loader_lay
bool loaderImplicitLayerIsEnabled(const struct loader_instance *inst, const struct loader_layer_properties *prop);
VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list,
struct loader_extension_list *inst_exts);
struct loader_icd_term *loader_get_icd_and_device(const VkDevice device, struct loader_device **found_dev, uint32_t *icd_index);
struct loader_icd_term *loader_get_icd_and_device(const void *device, struct loader_device **found_dev, uint32_t *icd_index);
void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev);
void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName);
void *loader_get_dev_ext_trampoline(uint32_t index);
Expand Down
36 changes: 10 additions & 26 deletions scripts/loader_extension_generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/python3 -i
#
# Copyright (c) 2015-2017 The Khronos Group Inc.
# Copyright (c) 2015-2017 Valve Corporation
# Copyright (c) 2015-2017 LunarG, Inc.
# Copyright (c) 2015-2020 The Khronos Group Inc.
# Copyright (c) 2015-2020 Valve Corporation
# Copyright (c) 2015-2020 LunarG, Inc.
# Copyright (c) 2015-2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -63,6 +63,12 @@
'vkDebugMarkerSetObjectNameEXT',
'vkSetDebugUtilsObjectNameEXT',
'vkSetDebugUtilsObjectTagEXT',
'vkQueueBeginDebugUtilsLabelEXT',
'vkQueueEndDebugUtilsLabelEXT',
'vkQueueInsertDebugUtilsLabelEXT',
'vkCmdBeginDebugUtilsLabelEXT',
'vkCmdEndDebugUtilsLabelEXT',
'vkCmdInsertDebugUtilsLabelEXT',
'vkGetDeviceGroupSurfacePresentModes2EXT']

# These are the aliased functions that use the same terminator for both extension and core versions
Expand Down Expand Up @@ -1180,29 +1186,7 @@ def CreateTrampTermFuncs(self):

elif ext_cmd.handle_type == 'VkInstance':
funcs += '#error("Not implemented. Likely needs to be manually generated!");\n'
elif 'DebugUtilsLabel' in ext_cmd.name:
funcs += ' const VkLayerDispatchTable *disp = loader_get_dispatch('
funcs += ext_cmd.params[0].name
funcs += ');\n'
if ext_cmd.ext_name in NULL_CHECK_EXT_NAMES:
funcs += ' if (disp->' + base_name + ' != NULL) {\n'
funcs += ' '
funcs += ' '
if has_return_type:
funcs += 'return '
funcs += 'disp->'
funcs += base_name
funcs += '('
count = 0
for param in ext_cmd.params:
if count != 0:
funcs += ', '
funcs += param.name
count += 1
funcs += ');\n'
if ext_cmd.ext_name in NULL_CHECK_EXT_NAMES:
funcs += ' }\n'
elif 'DebugMarkerSetObject' in ext_cmd.name or 'SetDebugUtilsObject' in ext_cmd.name:
elif 'DebugMarkerSetObject' in ext_cmd.name or 'SetDebugUtilsObject' in ext_cmd.name or 'DebugUtilsLabel' in ext_cmd.name:
funcs += ' uint32_t icd_index = 0;\n'
funcs += ' struct loader_device *dev;\n'
funcs += ' struct loader_icd_term *icd_term = loader_get_icd_and_device(%s, &dev, &icd_index);\n' % (ext_cmd.params[0].name)
Expand Down

0 comments on commit 9fdca38

Please sign in to comment.