Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2016 Valve Corporation |
| 3 | * Copyright (c) 2015-2016 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2016 Google Inc. |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 5 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and/or associated documentation files (the "Materials"), to |
| 8 | * deal in the Materials without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Materials, and to permit persons to whom the Materials |
| 11 | * are furnished to do so, subject to the following conditions: |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 12 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 13 | * The above copyright notice(s) and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Materials. |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 15 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 16 | * The Materials are Confidential Information as defined by the Khronos |
| 17 | * Membership Agreement until designated non-confidential by Khronos, at which |
| 18 | * point this condition clause shall be removed. |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 19 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 20 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 23 | * |
| 24 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 25 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 26 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 27 | * USE OR OTHER DEALINGS IN THE MATERIALS |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 28 | * |
| 29 | * Author: Mark Lobodzinski <mark@lunarg.com> |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 30 | * Author: Mike Stroyan <mike@LunarG.com> |
| 31 | * Author: Tobin Ehlis <tobin@lunarg.com> |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 32 | */ |
| 33 | |
| 34 | #include <stdio.h> |
| 35 | #include <stdlib.h> |
| 36 | #include <string.h> |
| 37 | #include <unordered_map> |
| 38 | #include <memory> |
| 39 | |
| 40 | #include "vk_loader_platform.h" |
| 41 | #include "vk_dispatch_table_helper.h" |
| 42 | #include "vk_struct_string_helper_cpp.h" |
| 43 | #if defined(__GNUC__) |
| 44 | #pragma GCC diagnostic ignored "-Wwrite-strings" |
| 45 | #endif |
| 46 | #if defined(__GNUC__) |
| 47 | #pragma GCC diagnostic warning "-Wwrite-strings" |
| 48 | #endif |
| 49 | #include "vk_struct_size_helper.h" |
| 50 | #include "device_limits.h" |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 51 | #include "vulkan/vk_layer.h" |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 52 | #include "vk_layer_config.h" |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 53 | #include "vulkan/vk_debug_marker_layer.h" |
Michael Lentine | 5d8ad0a | 2016-01-28 15:03:46 -0600 | [diff] [blame] | 54 | #include "vk_enum_validate_helper.h" |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 55 | #include "vk_layer_table.h" |
| 56 | #include "vk_layer_debug_marker_table.h" |
| 57 | #include "vk_layer_data.h" |
| 58 | #include "vk_layer_logging.h" |
| 59 | #include "vk_layer_extension_utils.h" |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 60 | #include "vk_layer_utils.h" |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 61 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 62 | struct devExts { |
| 63 | bool debug_marker_enabled; |
| 64 | }; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 65 | |
| 66 | // This struct will be stored in a map hashed by the dispatchable object |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 67 | struct layer_data { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 68 | debug_report_data *report_data; |
| 69 | std::vector<VkDebugReportCallbackEXT> logging_callback; |
| 70 | VkLayerDispatchTable *device_dispatch_table; |
| 71 | VkLayerInstanceDispatchTable *instance_dispatch_table; |
| 72 | devExts device_extensions; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 73 | // Track state of each instance |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 74 | unique_ptr<INSTANCE_STATE> instanceState; |
| 75 | unique_ptr<PHYSICAL_DEVICE_STATE> physicalDeviceState; |
| 76 | VkPhysicalDeviceFeatures actualPhysicalDeviceFeatures; |
| 77 | VkPhysicalDeviceFeatures requestedPhysicalDeviceFeatures; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 78 | unordered_map<VkDevice, VkPhysicalDeviceProperties> physDevPropertyMap; |
| 79 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 80 | // Track physical device per logical device |
| 81 | VkPhysicalDevice physicalDevice; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 82 | // Vector indices correspond to queueFamilyIndex |
| 83 | vector<unique_ptr<VkQueueFamilyProperties>> queueFamilyProperties; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 84 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 85 | layer_data() : |
| 86 | report_data(nullptr), |
| 87 | device_dispatch_table(nullptr), |
| 88 | instance_dispatch_table(nullptr), |
| 89 | device_extensions(), |
| 90 | instanceState(nullptr), |
| 91 | physicalDeviceState(nullptr), |
| 92 | actualPhysicalDeviceFeatures(), |
| 93 | requestedPhysicalDeviceFeatures(), |
| 94 | physicalDevice() |
| 95 | {}; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 96 | }; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 97 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 98 | static unordered_map<void *, layer_data *> layer_data_map; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 99 | |
| 100 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
| 101 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 102 | // TODO : This can be much smarter, using separate locks for separate global data |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 103 | static int globalLockInitialized = 0; |
| 104 | static loader_platform_thread_mutex globalLock; |
| 105 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 106 | template layer_data *get_my_data_ptr<layer_data>( |
| 107 | void *data_key, |
| 108 | std::unordered_map<void *, layer_data *> &data_map); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 109 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 110 | static void init_device_limits(layer_data *my_data, const VkAllocationCallbacks *pAllocator) |
| 111 | { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 112 | uint32_t report_flags = 0; |
| 113 | uint32_t debug_action = 0; |
| 114 | FILE *log_output = NULL; |
| 115 | const char *option_str; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 116 | VkDebugReportCallbackEXT callback; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 117 | // initialize DeviceLimits options |
| 118 | report_flags = getLayerOptionFlags("DeviceLimitsReportFlags", 0); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 119 | getLayerOptionEnum("DeviceLimitsDebugAction", (uint32_t *) &debug_action); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 120 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 121 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 122 | { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 123 | option_str = getLayerOption("DeviceLimitsLogFilename"); |
Tobin Ehlis | b1df55e | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 124 | log_output = getLayerLogOutput(option_str, "DeviceLimits"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 125 | VkDebugReportCallbackCreateInfoEXT dbgCreateInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 126 | memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 127 | dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 128 | dbgCreateInfo.flags = report_flags; |
| 129 | dbgCreateInfo.pfnCallback = log_callback; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 130 | dbgCreateInfo.pUserData = (void *) log_output; |
| 131 | layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, pAllocator, &callback); |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 132 | my_data->logging_callback.push_back(callback); |
| 133 | } |
| 134 | |
| 135 | if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 136 | VkDebugReportCallbackCreateInfoEXT dbgCreateInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 137 | memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 138 | dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 139 | dbgCreateInfo.flags = report_flags; |
| 140 | dbgCreateInfo.pfnCallback = win32_debug_output_msg; |
| 141 | dbgCreateInfo.pUserData = NULL; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 142 | layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, pAllocator, &callback); |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 143 | my_data->logging_callback.push_back(callback); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 144 | } |
| 145 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 146 | if (!globalLockInitialized) |
| 147 | { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 148 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
| 149 | // suggestion is to call this during vkCreateInstance(), and then we |
| 150 | // can clean it up during vkDestroyInstance(). However, that requires |
| 151 | // that the layer have per-instance locks. We need to come back and |
| 152 | // address this soon. |
| 153 | loader_platform_thread_create_mutex(&globalLock); |
| 154 | globalLockInitialized = 1; |
| 155 | } |
| 156 | } |
Courtney Goeltzenleuchter | 20c3501 | 2015-11-30 12:14:06 -0700 | [diff] [blame] | 157 | |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 158 | static const VkExtensionProperties instance_extensions[] = { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 159 | { |
| 160 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, |
| 161 | VK_EXT_DEBUG_REPORT_SPEC_VERSION |
| 162 | } |
| 163 | }; |
Courtney Goeltzenleuchter | 20c3501 | 2015-11-30 12:14:06 -0700 | [diff] [blame] | 164 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 165 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties( |
| 166 | const char *pLayerName, |
| 167 | uint32_t *pCount, |
| 168 | VkExtensionProperties* pProperties) |
| 169 | { |
| 170 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 171 | } |
| 172 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 173 | static const VkLayerProperties dl_global_layers[] = { |
| 174 | { |
| 175 | "VK_LAYER_LUNARG_device_limits", |
| 176 | VK_API_VERSION, |
| 177 | VK_MAKE_VERSION(0, 1, 0), |
| 178 | "Validation layer: Device Limits", |
| 179 | } |
| 180 | }; |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 181 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 182 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( |
| 183 | uint32_t *pCount, |
| 184 | VkLayerProperties* pProperties) |
| 185 | { |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 186 | return util_GetLayerProperties(ARRAY_SIZE(dl_global_layers), |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 187 | dl_global_layers, |
| 188 | pCount, pProperties); |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 189 | } |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 190 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 191 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) |
| 192 | { |
| 193 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 194 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 195 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 196 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 197 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 198 | if (fpCreateInstance == NULL) { |
| 199 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 200 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 201 | |
| 202 | // Advance the link info for the next element on the chain |
| 203 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 204 | |
| 205 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 206 | if (result != VK_SUCCESS) |
| 207 | return result; |
| 208 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 209 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 210 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 211 | layer_init_instance_dispatch_table(*pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 212 | |
| 213 | my_data->report_data = debug_report_create_instance( |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 214 | my_data->instance_dispatch_table, |
| 215 | *pInstance, |
| 216 | pCreateInfo->enabledExtensionCount, |
| 217 | pCreateInfo->ppEnabledExtensionNames); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 218 | |
| 219 | init_device_limits(my_data, pAllocator); |
| 220 | my_data->instanceState = unique_ptr<INSTANCE_STATE>(new INSTANCE_STATE()); |
| 221 | |
| 222 | return VK_SUCCESS; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /* hook DestroyInstance to remove tableInstanceMap entry */ |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 226 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator) |
| 227 | { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 228 | dispatch_key key = get_dispatch_key(instance); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 229 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 230 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 231 | pTable->DestroyInstance(instance, pAllocator); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 232 | |
| 233 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 234 | while (my_data->logging_callback.size() > 0) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 235 | VkDebugReportCallbackEXT callback = my_data->logging_callback.back(); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 236 | layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 237 | my_data->logging_callback.pop_back(); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | layer_debug_report_destroy_instance(my_data->report_data); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 241 | delete my_data->instance_dispatch_table; |
| 242 | layer_data_map.erase(key); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 243 | if (layer_data_map.empty()) { |
| 244 | // Release mutex when destroying last instance. |
| 245 | loader_platform_thread_delete_mutex(&globalLock); |
| 246 | globalLockInitialized = 0; |
| 247 | } |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 248 | } |
| 249 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 250 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) |
| 251 | { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 252 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 253 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 254 | if (my_data->instanceState) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 255 | // For this instance, flag when vkEnumeratePhysicalDevices goes to QUERY_COUNT and then QUERY_DETAILS |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 256 | if (NULL == pPhysicalDevices) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 257 | my_data->instanceState->vkEnumeratePhysicalDevicesState = QUERY_COUNT; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 258 | } else { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 259 | if (UNCALLED == my_data->instanceState->vkEnumeratePhysicalDevicesState) { |
| 260 | // Flag error here, shouldn't be calling this without having queried count |
| 261 | skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 262 | "Invalid call sequence to vkEnumeratePhysicalDevices() w/ non-NULL pPhysicalDevices. You should first call vkEnumeratePhysicalDevices() w/ NULL pPhysicalDevices to query pPhysicalDeviceCount."); |
| 263 | } // TODO : Could also flag a warning if re-calling this function in QUERY_DETAILS state |
| 264 | else if (my_data->instanceState->physicalDevicesCount != *pPhysicalDeviceCount) { |
| 265 | // TODO: Having actual count match count from app is not a requirement, so this can be a warning |
| 266 | skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", |
| 267 | "Call to vkEnumeratePhysicalDevices() w/ pPhysicalDeviceCount value %u, but actual count supported by this instance is %u.", *pPhysicalDeviceCount, my_data->instanceState->physicalDevicesCount); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 268 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 269 | my_data->instanceState->vkEnumeratePhysicalDevicesState = QUERY_DETAILS; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 270 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 271 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 272 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 273 | VkResult result = my_data->instance_dispatch_table->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 274 | if (NULL == pPhysicalDevices) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 275 | my_data->instanceState->physicalDevicesCount = *pPhysicalDeviceCount; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 276 | } else { // Save physical devices |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 277 | for (uint32_t i=0; i < *pPhysicalDeviceCount; i++) { |
| 278 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(pPhysicalDevices[i]), layer_data_map); |
| 279 | phy_dev_data->physicalDeviceState = unique_ptr<PHYSICAL_DEVICE_STATE>(new PHYSICAL_DEVICE_STATE()); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 280 | // Init actual features for each physical device |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 281 | my_data->instance_dispatch_table->GetPhysicalDeviceFeatures(pPhysicalDevices[i], &(phy_dev_data->actualPhysicalDeviceFeatures)); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | return result; |
| 285 | } else { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 286 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, DEVLIMITS_INVALID_INSTANCE, "DL", |
| 287 | "Invalid instance (%#" PRIxLEAST64 ") passed into vkEnumeratePhysicalDevices().", (uint64_t)instance); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 288 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 289 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 290 | } |
| 291 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 292 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures) |
| 293 | { |
| 294 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 295 | phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceFeaturesState = QUERY_DETAILS; |
| 296 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceFeatures(physicalDevice, pFeatures); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 297 | } |
| 298 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 299 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) |
| 300 | { |
| 301 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map)->instance_dispatch_table->GetPhysicalDeviceFormatProperties( |
| 302 | physicalDevice, format, pFormatProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 303 | } |
| 304 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 305 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) |
| 306 | { |
| 307 | return get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map)->instance_dispatch_table->GetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, pImageFormatProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 308 | } |
| 309 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 310 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties) |
| 311 | { |
| 312 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 313 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties(physicalDevice, pProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 314 | } |
| 315 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 316 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkQueueFamilyProperties* pQueueFamilyProperties) |
| 317 | { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 318 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 319 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 320 | if (phy_dev_data->physicalDeviceState) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 321 | if (NULL == pQueueFamilyProperties) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 322 | phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_COUNT; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 323 | } else { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 324 | // Verify that for each physical device, this function is called first with NULL pQueueFamilyProperties ptr in order to get count |
| 325 | if (UNCALLED == phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceQueueFamilyPropertiesState) { |
| 326 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 327 | "Invalid call sequence to vkGetPhysicalDeviceQueueFamilyProperties() w/ non-NULL pQueueFamilyProperties. You should first call vkGetPhysicalDeviceQueueFamilyProperties() w/ NULL pQueueFamilyProperties to query pCount."); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 328 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 329 | // Then verify that pCount that is passed in on second call matches what was returned |
| 330 | if (phy_dev_data->physicalDeviceState->queueFamilyPropertiesCount != *pCount) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 331 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 332 | // TODO: this is not a requirement of the Valid Usage section for vkGetPhysicalDeviceQueueFamilyProperties, so provide as warning |
| 333 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", |
| 334 | "Call to vkGetPhysicalDeviceQueueFamilyProperties() w/ pCount value %u, but actual count supported by this physicalDevice is %u.", *pCount, phy_dev_data->physicalDeviceState->queueFamilyPropertiesCount); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 335 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 336 | phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_DETAILS; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 337 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 338 | if (skipCall) |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 339 | return; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 340 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pCount, pQueueFamilyProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 341 | if (NULL == pQueueFamilyProperties) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 342 | phy_dev_data->physicalDeviceState->queueFamilyPropertiesCount = *pCount; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 343 | } else { // Save queue family properties |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 344 | phy_dev_data->queueFamilyProperties.reserve(*pCount); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 345 | for (uint32_t i=0; i < *pCount; i++) { |
| 346 | phy_dev_data->queueFamilyProperties.emplace_back(new VkQueueFamilyProperties(pQueueFamilyProperties[i])); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 347 | } |
| 348 | } |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 349 | return; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 350 | } else { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 351 | log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_PHYSICAL_DEVICE, "DL", |
| 352 | "Invalid physicalDevice (%#" PRIxLEAST64 ") passed into vkGetPhysicalDeviceQueueFamilyProperties().", (uint64_t)physicalDevice); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 353 | } |
| 354 | } |
| 355 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 356 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties) |
| 357 | { |
| 358 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map)->instance_dispatch_table->GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 359 | } |
| 360 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 361 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pNumProperties, VkSparseImageFormatProperties* pProperties) |
| 362 | { |
| 363 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map)->instance_dispatch_table->GetPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, type, samples, usage, tiling, pNumProperties, pProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 364 | } |
| 365 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 366 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport( |
| 367 | VkCommandBuffer commandBuffer, |
| 368 | uint32_t firstViewport, |
| 369 | uint32_t viewportCount, |
| 370 | const VkViewport* pViewports) |
| 371 | { |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 372 | VkBool32 skipCall = VK_FALSE; |
| 373 | /* TODO: Verify viewportCount < maxViewports from VkPhysicalDeviceLimits */ |
| 374 | if (VK_FALSE == skipCall) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 375 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 376 | my_data->device_dispatch_table->CmdSetViewport(commandBuffer, firstViewport, viewportCount, pViewports); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 377 | } |
| 378 | } |
| 379 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 380 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor( |
| 381 | VkCommandBuffer commandBuffer, |
| 382 | uint32_t firstScissor, |
| 383 | uint32_t scissorCount, |
| 384 | const VkRect2D* pScissors) |
| 385 | { |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 386 | VkBool32 skipCall = VK_FALSE; |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 387 | /* TODO: Verify scissorCount < maxViewports from VkPhysicalDeviceLimits */ |
| 388 | /* TODO: viewportCount and scissorCount must match at draw time */ |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 389 | if (VK_FALSE == skipCall) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 390 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 391 | my_data->device_dispatch_table->CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 395 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 396 | { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 397 | uint32_t i; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 398 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 399 | my_data->device_extensions.debug_marker_enabled = false; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 400 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 401 | for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 402 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], DEBUG_MARKER_EXTENSION_NAME) == 0) { |
| 403 | /* Found a matching extension name, mark it enabled and init dispatch table*/ |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 404 | initDebugMarkerTable(device); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 405 | my_data->device_extensions.debug_marker_enabled = true; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 406 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 407 | |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 408 | } |
| 409 | } |
| 410 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 411 | // Verify that features have been queried and verify that requested features are available |
| 412 | static VkBool32 validate_features_request(layer_data *phy_dev_data) |
| 413 | { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 414 | VkBool32 skipCall = VK_FALSE; |
| 415 | // Verify that all of the requested features are available |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 416 | // Get ptrs into actual and requested structs and if requested is 1 but actual is 0, request is invalid |
| 417 | VkBool32* actual = (VkBool32*)&(phy_dev_data->actualPhysicalDeviceFeatures); |
| 418 | VkBool32* requested = (VkBool32*)&(phy_dev_data->requestedPhysicalDeviceFeatures); |
| 419 | // TODO : This is a nice, compact way to loop through struct, but a bad way to report issues |
| 420 | // Need to provide the struct member name with the issue. To do that seems like we'll |
| 421 | // have to loop through each struct member which should be done w/ codegen to keep in synch. |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 422 | uint32_t errors = 0; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 423 | uint32_t totalBools = sizeof(VkPhysicalDeviceFeatures)/sizeof(VkBool32); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 424 | for (uint32_t i = 0; i < totalBools; i++) { |
| 425 | if (requested[i] > actual[i]) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 426 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_FEATURE_REQUESTED, "DL", |
| 427 | "While calling vkCreateDevice(), requesting feature #%u in VkPhysicalDeviceFeatures struct, which is not available on this device.", i); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 428 | errors++; |
| 429 | } |
| 430 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 431 | if (errors && (UNCALLED == phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceFeaturesState)) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 432 | // If user didn't request features, notify them that they should |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 433 | // TODO: Verify this against the spec. I believe this is an invalid use of the API and should return an error |
| 434 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_FEATURE_REQUESTED, "DL", |
| 435 | "You requested features that are unavailable on this device. You should first query feature availability by calling vkGetPhysicalDeviceFeatures()."); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 436 | } |
Tobin Ehlis | 72b27cc | 2015-09-29 11:22:37 -0600 | [diff] [blame] | 437 | return skipCall; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 438 | } |
| 439 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 440 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) |
| 441 | { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 442 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 443 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
Tobin Ehlis | 54a6c18 | 2015-09-22 14:00:58 -0600 | [diff] [blame] | 444 | // First check is app has actually requested queueFamilyProperties |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 445 | if (!phy_dev_data->physicalDeviceState) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 446 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 447 | "Invalid call to vkCreateDevice() w/o first calling vkEnumeratePhysicalDevices()."); |
| 448 | } else if (QUERY_DETAILS != phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceQueueFamilyPropertiesState) { |
| 449 | // TODO: This is not called out as an invalid use in the spec so make more informative recommendation. |
| 450 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 451 | "Call to vkCreateDevice() w/o first calling vkGetPhysicalDeviceQueueFamilyProperties()."); |
Tobin Ehlis | 54a6c18 | 2015-09-22 14:00:58 -0600 | [diff] [blame] | 452 | } else { |
| 453 | // Check that the requested queue properties are valid |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 454 | for (uint32_t i=0; i<pCreateInfo->queueCreateInfoCount; i++) { |
| 455 | uint32_t requestedIndex = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex; |
| 456 | if (phy_dev_data->queueFamilyProperties.size() <= requestedIndex) { // requested index is out of bounds for this physical device |
| 457 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 458 | "Invalid queue create request in vkCreateDevice(). Invalid queueFamilyIndex %u requested.", requestedIndex); |
| 459 | } else if (pCreateInfo->pQueueCreateInfos[i].queueCount > phy_dev_data->queueFamilyProperties[requestedIndex]->queueCount) { |
| 460 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 461 | "Invalid queue create request in vkCreateDevice(). QueueFamilyIndex %u only has %u queues, but requested queueCount is %u.", requestedIndex, phy_dev_data->queueFamilyProperties[requestedIndex]->queueCount, pCreateInfo->pQueueCreateInfos[i].queueCount); |
Tobin Ehlis | 54a6c18 | 2015-09-22 14:00:58 -0600 | [diff] [blame] | 462 | } |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 463 | } |
| 464 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 465 | // Check that any requested features are available |
| 466 | if (pCreateInfo->pEnabledFeatures) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 467 | phy_dev_data->requestedPhysicalDeviceFeatures = *(pCreateInfo->pEnabledFeatures); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 468 | skipCall |= validate_features_request(phy_dev_data); |
| 469 | } |
| 470 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 471 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 472 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 473 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 474 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 475 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 476 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 477 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 478 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice) fpGetInstanceProcAddr(NULL, "vkCreateDevice"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 479 | if (fpCreateDevice == NULL) { |
| 480 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 481 | } |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 482 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 483 | // Advance the link info for the next element on the chain |
| 484 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 485 | |
| 486 | VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
| 487 | if (result != VK_SUCCESS) { |
| 488 | return result; |
| 489 | } |
| 490 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 491 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 492 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 493 | my_device_data->device_dispatch_table = new VkLayerDispatchTable; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 494 | layer_init_device_dispatch_table(*pDevice, my_device_data->device_dispatch_table, fpGetDeviceProcAddr); |
| 495 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 496 | my_device_data->physicalDevice = gpu; |
| 497 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
| 498 | |
| 499 | // Get physical device properties for this device |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 500 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties(gpu, &(phy_dev_data->physDevPropertyMap[*pDevice])); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 501 | return result; |
| 502 | } |
| 503 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 504 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator) |
| 505 | { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 506 | // Free device lifetime allocations |
| 507 | dispatch_key key = get_dispatch_key(device); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 508 | layer_data *my_device_data = get_my_data_ptr(key, layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 509 | my_device_data->device_dispatch_table->DestroyDevice(device, pAllocator); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 510 | tableDebugMarkerMap.erase(key); |
| 511 | delete my_device_data->device_dispatch_table; |
| 512 | layer_data_map.erase(key); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 513 | } |
| 514 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 515 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) |
| 516 | { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 517 | // TODO : Verify that requested QueueFamilyIndex for this pool exists |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 518 | VkResult result = get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 519 | return result; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 520 | } |
| 521 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 522 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator) |
| 523 | { |
| 524 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyCommandPool(device, commandPool, pAllocator); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 525 | } |
| 526 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 527 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) |
| 528 | { |
| 529 | VkResult result = get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->ResetCommandPool(device, commandPool, flags); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 530 | return result; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 531 | } |
| 532 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 533 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pCreateInfo, VkCommandBuffer* pCommandBuffer) |
| 534 | { |
| 535 | VkResult result = get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->AllocateCommandBuffers(device, pCreateInfo, pCommandBuffer); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 536 | return result; |
| 537 | } |
Mark Lobodzinski | fbb130e | 2015-10-06 11:59:54 -0600 | [diff] [blame] | 538 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 539 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t count, const VkCommandBuffer* pCommandBuffers) |
| 540 | { |
| 541 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->FreeCommandBuffers(device, commandPool, count, pCommandBuffers); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 542 | } |
| 543 | |
Michael Lentine | 09853ef | 2016-01-28 14:20:46 -0600 | [diff] [blame] | 544 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo) |
| 545 | { |
| 546 | bool skipCall = false; |
| 547 | layer_data *dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 548 | const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo; |
| 549 | if (dev_data->actualPhysicalDeviceFeatures.inheritedQueries == VK_FALSE && pInfo && pInfo->occlusionQueryEnable != VK_FALSE) { |
| 550 | skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer), __LINE__, |
| 551 | DEVLIMITS_INVALID_INHERITED_QUERY, "DL", |
| 552 | "Cannot set inherited occlusionQueryEnable in vkBeginCommandBuffer() when device does not support inheritedQueries."); |
| 553 | } |
Michael Lentine | 5d8ad0a | 2016-01-28 15:03:46 -0600 | [diff] [blame] | 554 | if (dev_data->actualPhysicalDeviceFeatures.inheritedQueries != VK_FALSE && pInfo && pInfo->occlusionQueryEnable != VK_FALSE && |
| 555 | !validate_VkQueryControlFlagBits(VkQueryControlFlagBits(pInfo->queryFlags))) { |
| 556 | skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer), __LINE__, |
| 557 | DEVLIMITS_INVALID_INHERITED_QUERY, "DL", |
| 558 | "Cannot enable in occlusion queries in vkBeginCommandBuffer() and set queryFlags to %d which is not a valid combination of VkQueryControlFlagBits.", |
| 559 | pInfo->queryFlags); |
| 560 | } |
Michael Lentine | 09853ef | 2016-01-28 14:20:46 -0600 | [diff] [blame] | 561 | if (!skipCall) |
| 562 | dev_data->device_dispatch_table->BeginCommandBuffer(commandBuffer, pBeginInfo); |
| 563 | } |
| 564 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 565 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue) |
| 566 | { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 567 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 568 | layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 569 | VkPhysicalDevice gpu = dev_data->physicalDevice; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 570 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 571 | if (queueFamilyIndex >= phy_dev_data->queueFamilyProperties.size()) { // requested index is out of bounds for this physical device |
| 572 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 573 | "Invalid queueFamilyIndex %u requested in vkGetDeviceQueue().", queueFamilyIndex); |
| 574 | } else if (queueIndex >= phy_dev_data->queueFamilyProperties[queueFamilyIndex]->queueCount) { |
| 575 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 576 | "Invalid queue request in vkGetDeviceQueue(). QueueFamilyIndex %u only has %u queues, but requested queueIndex is %u.", queueFamilyIndex, phy_dev_data->queueFamilyProperties[queueFamilyIndex]->queueCount, queueIndex); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 577 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 578 | if (skipCall) |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 579 | return; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 580 | dev_data->device_dispatch_table->GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 581 | } |
| 582 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 583 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory( |
| 584 | VkDevice device, |
| 585 | VkBuffer buffer, |
| 586 | VkDeviceMemory mem, |
| 587 | VkDeviceSize memoryOffset) |
| 588 | { |
| 589 | layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 590 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 591 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 592 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 593 | VkDeviceSize uniformAlignment = dev_data->physDevPropertyMap[device].limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 594 | if (vk_safe_modulo(memoryOffset, uniformAlignment) != 0) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 595 | skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 596 | __LINE__, DEVLIMITS_INVALID_UNIFORM_BUFFER_OFFSET, "DL", |
| 597 | "vkBindBufferMemory(): memoryOffset %#" PRIxLEAST64 " must be a multiple of device limit minUniformBufferOffsetAlignment %#" PRIxLEAST64, |
| 598 | memoryOffset, uniformAlignment); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | if (VK_FALSE == skipCall) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 602 | result = dev_data->device_dispatch_table->BindBufferMemory(device, buffer, mem, memoryOffset); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 603 | } |
| 604 | return result; |
| 605 | } |
| 606 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 607 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets( |
| 608 | VkDevice device, |
| 609 | uint32_t descriptorWriteCount, |
| 610 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 611 | uint32_t descriptorCopyCount, |
| 612 | const VkCopyDescriptorSet *pDescriptorCopies) |
| 613 | { |
| 614 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 615 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 616 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 617 | |
Mark Young | ee3f3a2 | 2016-01-25 12:18:32 -0700 | [diff] [blame] | 618 | for (uint32_t i = 0; i < descriptorWriteCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 619 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 620 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
| 621 | VkDeviceSize uniformAlignment = dev_data->physDevPropertyMap[device].limits.minUniformBufferOffsetAlignment; |
| 622 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 623 | if (vk_safe_modulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { |
| 624 | skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 625 | __LINE__, DEVLIMITS_INVALID_UNIFORM_BUFFER_OFFSET, "DL", |
| 626 | "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (%#" PRIxLEAST64 ") must be a multiple of device limit minUniformBufferOffsetAlignment %#" PRIxLEAST64, |
| 627 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 628 | } |
| 629 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 630 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 631 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 632 | VkDeviceSize storageAlignment = dev_data->physDevPropertyMap[device].limits.minStorageBufferOffsetAlignment; |
| 633 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 634 | if (vk_safe_modulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { |
| 635 | skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 636 | __LINE__, DEVLIMITS_INVALID_STORAGE_BUFFER_OFFSET, "DL", |
| 637 | "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (%#" PRIxLEAST64 ") must be a multiple of device limit minStorageBufferOffsetAlignment %#" PRIxLEAST64, |
| 638 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 639 | } |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | if (skipCall == VK_FALSE) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 644 | dev_data->device_dispatch_table->UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 645 | } |
| 646 | } |
| 647 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 648 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer( |
| 649 | VkCommandBuffer commandBuffer, |
| 650 | VkBuffer dstBuffer, |
| 651 | VkDeviceSize dstOffset, |
| 652 | VkDeviceSize dataSize, |
| 653 | const uint32_t* pData) |
| 654 | { |
| 655 | layer_data *dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 656 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 657 | // dstOffset is the byte offset into the buffer to start updating and must be a multiple of 4. |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 658 | if (dstOffset & 3) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 659 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 660 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 661 | "vkCmdUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 662 | return; |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | // dataSize is the number of bytes to update, which must be a multiple of 4. |
| 667 | if (dataSize & 3) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 668 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 669 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 670 | "vkCmdUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 671 | return; |
| 672 | } |
| 673 | } |
| 674 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 675 | dev_data->device_dispatch_table->CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 676 | } |
| 677 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 678 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( |
| 679 | VkCommandBuffer commandBuffer, |
| 680 | VkBuffer dstBuffer, |
| 681 | VkDeviceSize dstOffset, |
| 682 | VkDeviceSize size, |
| 683 | uint32_t data) |
| 684 | { |
| 685 | layer_data *dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 686 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 687 | // dstOffset is the byte offset into the buffer to start filling and must be a multiple of 4. |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 688 | if (dstOffset & 3) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 689 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 690 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 691 | "vkCmdFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 692 | return; |
| 693 | } |
| 694 | } |
| 695 | |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 696 | // size is the number of bytes to fill, which must be a multiple of 4. |
| 697 | if (size & 3) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 698 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 699 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 700 | "vkCmdFillBuffer parameter, VkDeviceSize size, is not a multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 701 | return; |
| 702 | } |
| 703 | } |
| 704 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 705 | dev_data->device_dispatch_table->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 706 | } |
| 707 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 708 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT( |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 709 | VkInstance instance, |
| 710 | const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, |
| 711 | const VkAllocationCallbacks* pAllocator, |
| 712 | VkDebugReportCallbackEXT* pMsgCallback) |
| 713 | { |
| 714 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 715 | VkResult res = my_data->instance_dispatch_table->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 716 | if (VK_SUCCESS == res) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 717 | res = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 718 | } |
| 719 | return res; |
| 720 | } |
| 721 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 722 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT( |
| 723 | VkInstance instance, |
| 724 | VkDebugReportCallbackEXT msgCallback, |
| 725 | const VkAllocationCallbacks* pAllocator) |
| 726 | { |
| 727 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 728 | my_data->instance_dispatch_table->DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 729 | layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 730 | } |
| 731 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 732 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT( |
| 733 | VkInstance instance, |
| 734 | VkDebugReportFlagsEXT flags, |
| 735 | VkDebugReportObjectTypeEXT objType, |
| 736 | uint64_t object, |
| 737 | size_t location, |
| 738 | int32_t msgCode, |
| 739 | const char* pLayerPrefix, |
| 740 | const char* pMsg) |
| 741 | { |
| 742 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 743 | my_data->instance_dispatch_table->DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 744 | } |
| 745 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 746 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char* funcName) |
| 747 | { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 748 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 749 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 750 | if (!strcmp(funcName, "vkDestroyDevice")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 751 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 752 | if (!strcmp(funcName, "vkGetDeviceQueue")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 753 | return (PFN_vkVoidFunction) vkGetDeviceQueue; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 754 | if (!strcmp(funcName, "CreateCommandPool")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 755 | return (PFN_vkVoidFunction) vkCreateCommandPool; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 756 | if (!strcmp(funcName, "DestroyCommandPool")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 757 | return (PFN_vkVoidFunction) vkDestroyCommandPool; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 758 | if (!strcmp(funcName, "ResetCommandPool")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 759 | return (PFN_vkVoidFunction) vkResetCommandPool; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 760 | if (!strcmp(funcName, "vkAllocateCommandBuffers")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 761 | return (PFN_vkVoidFunction) vkAllocateCommandBuffers; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 762 | if (!strcmp(funcName, "vkFreeCommandBuffers")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 763 | return (PFN_vkVoidFunction) vkFreeCommandBuffers; |
Michael Lentine | 09853ef | 2016-01-28 14:20:46 -0600 | [diff] [blame] | 764 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
| 765 | return (PFN_vkVoidFunction) vkBeginCommandBuffer; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 766 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 767 | return (PFN_vkVoidFunction) vkCmdUpdateBuffer; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 768 | if (!strcmp(funcName, "vkBindBufferMemory")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 769 | return (PFN_vkVoidFunction) vkBindBufferMemory; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 770 | if (!strcmp(funcName, "vkUpdateDescriptorSets")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 771 | return (PFN_vkVoidFunction) vkUpdateDescriptorSets; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 772 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 773 | return (PFN_vkVoidFunction) vkCmdFillBuffer; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 774 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 775 | if (dev == NULL) |
| 776 | return NULL; |
| 777 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 778 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); |
| 779 | VkLayerDispatchTable* pTable = my_data->device_dispatch_table; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 780 | { |
| 781 | if (pTable->GetDeviceProcAddr == NULL) |
| 782 | return NULL; |
| 783 | return pTable->GetDeviceProcAddr(dev, funcName); |
| 784 | } |
| 785 | } |
| 786 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 787 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* funcName) |
| 788 | { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 789 | PFN_vkVoidFunction fptr; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 790 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 791 | layer_data *my_data; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 792 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 793 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 794 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 795 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 796 | if (!strcmp(funcName, "vkCreateInstance")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 797 | return (PFN_vkVoidFunction) vkCreateInstance; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 798 | if (!strcmp(funcName, "vkDestroyInstance")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 799 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 800 | if (!strcmp(funcName, "vkCreateDevice")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 801 | return (PFN_vkVoidFunction) vkCreateDevice; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 802 | if (!strcmp(funcName, "vkEnumeratePhysicalDevices")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 803 | return (PFN_vkVoidFunction) vkEnumeratePhysicalDevices; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 804 | if (!strcmp(funcName, "vkGetPhysicalDeviceFeatures")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 805 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceFeatures; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 806 | if (!strcmp(funcName, "vkGetPhysicalDeviceFormatProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 807 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceFormatProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 808 | if (!strcmp(funcName, "vkGetPhysicalDeviceImageFormatProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 809 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceImageFormatProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 810 | if (!strcmp(funcName, "vkGetPhysicalDeviceProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 811 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 812 | if (!strcmp(funcName, "vkGetPhysicalDeviceQueueFamilyProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 813 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceQueueFamilyProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 814 | if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 815 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceMemoryProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 816 | if (!strcmp(funcName, "vkGetPhysicalDeviceSparseImageFormatProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 817 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceSparseImageFormatProperties; |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 818 | if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 819 | return (PFN_vkVoidFunction) vkEnumerateInstanceLayerProperties; |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 820 | if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 821 | return (PFN_vkVoidFunction) vkEnumerateInstanceExtensionProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 822 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 823 | if (!instance) return NULL; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 824 | |
| 825 | my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 826 | |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 827 | fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
| 828 | if (fptr) |
| 829 | return fptr; |
| 830 | |
| 831 | { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 832 | VkLayerInstanceDispatchTable* pTable = my_data->instance_dispatch_table; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 833 | if (pTable->GetInstanceProcAddr == NULL) |
| 834 | return NULL; |
| 835 | return pTable->GetInstanceProcAddr(instance, funcName); |
| 836 | } |
| 837 | } |