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" |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 54 | #include "vk_layer_table.h" |
| 55 | #include "vk_layer_debug_marker_table.h" |
| 56 | #include "vk_layer_data.h" |
| 57 | #include "vk_layer_logging.h" |
| 58 | #include "vk_layer_extension_utils.h" |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 59 | #include "vk_layer_utils.h" |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 60 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 61 | struct devExts { |
| 62 | bool debug_marker_enabled; |
| 63 | }; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 64 | |
| 65 | // 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] | 66 | struct layer_data { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 67 | debug_report_data *report_data; |
| 68 | std::vector<VkDebugReportCallbackEXT> logging_callback; |
| 69 | VkLayerDispatchTable *device_dispatch_table; |
| 70 | VkLayerInstanceDispatchTable *instance_dispatch_table; |
| 71 | devExts device_extensions; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 72 | // Track state of each instance |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 73 | unique_ptr<INSTANCE_STATE> instanceState; |
| 74 | unique_ptr<PHYSICAL_DEVICE_STATE> physicalDeviceState; |
| 75 | VkPhysicalDeviceFeatures actualPhysicalDeviceFeatures; |
| 76 | VkPhysicalDeviceFeatures requestedPhysicalDeviceFeatures; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 77 | unordered_map<VkDevice, VkPhysicalDeviceProperties> physDevPropertyMap; |
| 78 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 79 | // Track physical device per logical device |
| 80 | VkPhysicalDevice physicalDevice; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 81 | // Vector indices correspond to queueFamilyIndex |
| 82 | vector<unique_ptr<VkQueueFamilyProperties>> queueFamilyProperties; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 83 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 84 | layer_data() |
| 85 | : report_data(nullptr), device_dispatch_table(nullptr), |
| 86 | instance_dispatch_table(nullptr), device_extensions(), |
| 87 | instanceState(nullptr), physicalDeviceState(nullptr), |
| 88 | actualPhysicalDeviceFeatures(), requestedPhysicalDeviceFeatures(), |
| 89 | physicalDevice(){}; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 90 | }; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 91 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 92 | static unordered_map<void *, layer_data *> layer_data_map; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 93 | |
| 94 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
| 95 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 96 | // TODO : This can be much smarter, using separate locks for separate global |
| 97 | // data |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 98 | static int globalLockInitialized = 0; |
| 99 | static loader_platform_thread_mutex globalLock; |
| 100 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 101 | template layer_data * |
| 102 | get_my_data_ptr<layer_data>(void *data_key, |
| 103 | std::unordered_map<void *, layer_data *> &data_map); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 104 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 105 | static void init_device_limits(layer_data *my_data, |
| 106 | const VkAllocationCallbacks *pAllocator) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 107 | uint32_t report_flags = 0; |
| 108 | uint32_t debug_action = 0; |
| 109 | FILE *log_output = NULL; |
| 110 | const char *option_str; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 111 | VkDebugReportCallbackEXT callback; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 112 | // initialize DeviceLimits options |
| 113 | report_flags = getLayerOptionFlags("DeviceLimitsReportFlags", 0); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 114 | getLayerOptionEnum("DeviceLimitsDebugAction", (uint32_t *)&debug_action); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 115 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 116 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 117 | option_str = getLayerOption("DeviceLimitsLogFilename"); |
Tobin Ehlis | b1df55e | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 118 | log_output = getLayerLogOutput(option_str, "DeviceLimits"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 119 | VkDebugReportCallbackCreateInfoEXT dbgCreateInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 120 | memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 121 | dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 122 | dbgCreateInfo.flags = report_flags; |
| 123 | dbgCreateInfo.pfnCallback = log_callback; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 124 | dbgCreateInfo.pUserData = (void *)log_output; |
| 125 | layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, |
| 126 | pAllocator, &callback); |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 127 | my_data->logging_callback.push_back(callback); |
| 128 | } |
| 129 | |
| 130 | if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 131 | VkDebugReportCallbackCreateInfoEXT dbgCreateInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 132 | memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 133 | dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 134 | dbgCreateInfo.flags = report_flags; |
| 135 | dbgCreateInfo.pfnCallback = win32_debug_output_msg; |
| 136 | dbgCreateInfo.pUserData = NULL; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 137 | layer_create_msg_callback(my_data->report_data, &dbgCreateInfo, |
| 138 | pAllocator, &callback); |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 139 | my_data->logging_callback.push_back(callback); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 140 | } |
| 141 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 142 | if (!globalLockInitialized) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 143 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
| 144 | // suggestion is to call this during vkCreateInstance(), and then we |
| 145 | // can clean it up during vkDestroyInstance(). However, that requires |
| 146 | // that the layer have per-instance locks. We need to come back and |
| 147 | // address this soon. |
| 148 | loader_platform_thread_create_mutex(&globalLock); |
| 149 | globalLockInitialized = 1; |
| 150 | } |
| 151 | } |
Courtney Goeltzenleuchter | 20c3501 | 2015-11-30 12:14:06 -0700 | [diff] [blame] | 152 | |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 153 | static const VkExtensionProperties instance_extensions[] = { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 154 | {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}}; |
Courtney Goeltzenleuchter | 20c3501 | 2015-11-30 12:14:06 -0700 | [diff] [blame] | 155 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 156 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 157 | vkEnumerateInstanceExtensionProperties(const char *pLayerName, |
| 158 | uint32_t *pCount, |
| 159 | VkExtensionProperties *pProperties) { |
| 160 | return util_GetExtensionProperties(1, instance_extensions, pCount, |
| 161 | pProperties); |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 162 | } |
| 163 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 164 | static const VkLayerProperties dl_global_layers[] = {{ |
| 165 | "VK_LAYER_LUNARG_device_limits", VK_API_VERSION, VK_MAKE_VERSION(0, 1, 0), |
| 166 | "Validation layer: Device Limits", |
| 167 | }}; |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 168 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 169 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 170 | vkEnumerateInstanceLayerProperties(uint32_t *pCount, |
| 171 | VkLayerProperties *pProperties) { |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 172 | return util_GetLayerProperties(ARRAY_SIZE(dl_global_layers), |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 173 | dl_global_layers, pCount, pProperties); |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 174 | } |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 175 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 176 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 177 | vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
| 178 | const VkAllocationCallbacks *pAllocator, |
| 179 | VkInstance *pInstance) { |
| 180 | VkLayerInstanceCreateInfo *chain_info = |
| 181 | get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 182 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 183 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 184 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = |
| 185 | chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 186 | PFN_vkCreateInstance fpCreateInstance = |
| 187 | (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 188 | if (fpCreateInstance == NULL) { |
| 189 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 190 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 191 | |
| 192 | // Advance the link info for the next element on the chain |
| 193 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 194 | |
| 195 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 196 | if (result != VK_SUCCESS) |
| 197 | return result; |
| 198 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 199 | layer_data *my_data = |
| 200 | get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 201 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 202 | layer_init_instance_dispatch_table( |
| 203 | *pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 204 | |
| 205 | my_data->report_data = debug_report_create_instance( |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 206 | my_data->instance_dispatch_table, *pInstance, |
| 207 | pCreateInfo->enabledExtensionCount, |
| 208 | pCreateInfo->ppEnabledExtensionNames); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 209 | |
| 210 | init_device_limits(my_data, pAllocator); |
| 211 | my_data->instanceState = unique_ptr<INSTANCE_STATE>(new INSTANCE_STATE()); |
| 212 | |
| 213 | return VK_SUCCESS; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | /* hook DestroyInstance to remove tableInstanceMap entry */ |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 217 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 218 | vkDestroyInstance(VkInstance instance, |
| 219 | const VkAllocationCallbacks *pAllocator) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 220 | dispatch_key key = get_dispatch_key(instance); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 221 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 222 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 223 | pTable->DestroyInstance(instance, pAllocator); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 224 | |
| 225 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 226 | while (my_data->logging_callback.size() > 0) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 227 | VkDebugReportCallbackEXT callback = my_data->logging_callback.back(); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 228 | layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); |
Courtney Goeltzenleuchter | d6fce63 | 2015-10-05 14:51:41 -0600 | [diff] [blame] | 229 | my_data->logging_callback.pop_back(); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | layer_debug_report_destroy_instance(my_data->report_data); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 233 | delete my_data->instance_dispatch_table; |
| 234 | layer_data_map.erase(key); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 235 | if (layer_data_map.empty()) { |
| 236 | // Release mutex when destroying last instance. |
| 237 | loader_platform_thread_delete_mutex(&globalLock); |
| 238 | globalLockInitialized = 0; |
| 239 | } |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 240 | } |
| 241 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 242 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 243 | vkEnumeratePhysicalDevices(VkInstance instance, |
| 244 | uint32_t *pPhysicalDeviceCount, |
| 245 | VkPhysicalDevice *pPhysicalDevices) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 246 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 247 | layer_data *my_data = |
| 248 | get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 249 | if (my_data->instanceState) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 250 | // For this instance, flag when vkEnumeratePhysicalDevices goes to |
| 251 | // QUERY_COUNT and then QUERY_DETAILS |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 252 | if (NULL == pPhysicalDevices) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 253 | my_data->instanceState->vkEnumeratePhysicalDevicesState = |
| 254 | QUERY_COUNT; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 255 | } else { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 256 | if (UNCALLED == |
| 257 | my_data->instanceState->vkEnumeratePhysicalDevicesState) { |
| 258 | // Flag error here, shouldn't be calling this without having |
| 259 | // queried count |
| 260 | skipCall |= log_msg( |
| 261 | my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 262 | VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, |
| 263 | DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 264 | "Invalid call sequence to vkEnumeratePhysicalDevices() w/ " |
| 265 | "non-NULL pPhysicalDevices. You should first call " |
| 266 | "vkEnumeratePhysicalDevices() w/ NULL pPhysicalDevices to " |
| 267 | "query pPhysicalDeviceCount."); |
| 268 | } // TODO : Could also flag a warning if re-calling this function in |
| 269 | // QUERY_DETAILS state |
| 270 | else if (my_data->instanceState->physicalDevicesCount != |
| 271 | *pPhysicalDeviceCount) { |
| 272 | // TODO: Having actual count match count from app is not a |
| 273 | // requirement, so this can be a warning |
| 274 | skipCall |= |
| 275 | log_msg(my_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, |
| 276 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 277 | __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", |
| 278 | "Call to vkEnumeratePhysicalDevices() w/ " |
| 279 | "pPhysicalDeviceCount value %u, but actual count " |
| 280 | "supported by this instance is %u.", |
| 281 | *pPhysicalDeviceCount, |
| 282 | my_data->instanceState->physicalDevicesCount); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 283 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 284 | my_data->instanceState->vkEnumeratePhysicalDevicesState = |
| 285 | QUERY_DETAILS; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 286 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 287 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 288 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 289 | VkResult result = |
| 290 | my_data->instance_dispatch_table->EnumeratePhysicalDevices( |
| 291 | instance, pPhysicalDeviceCount, pPhysicalDevices); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 292 | if (NULL == pPhysicalDevices) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 293 | my_data->instanceState->physicalDevicesCount = |
| 294 | *pPhysicalDeviceCount; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 295 | } else { // Save physical devices |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 296 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
| 297 | layer_data *phy_dev_data = get_my_data_ptr( |
| 298 | get_dispatch_key(pPhysicalDevices[i]), layer_data_map); |
| 299 | phy_dev_data->physicalDeviceState = |
| 300 | unique_ptr<PHYSICAL_DEVICE_STATE>( |
| 301 | new PHYSICAL_DEVICE_STATE()); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 302 | // Init actual features for each physical device |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 303 | my_data->instance_dispatch_table->GetPhysicalDeviceFeatures( |
| 304 | pPhysicalDevices[i], |
| 305 | &(phy_dev_data->actualPhysicalDeviceFeatures)); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 306 | } |
| 307 | } |
| 308 | return result; |
| 309 | } else { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 310 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 311 | VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, |
| 312 | DEVLIMITS_INVALID_INSTANCE, "DL", |
| 313 | "Invalid instance (%#" PRIxLEAST64 |
| 314 | ") passed into vkEnumeratePhysicalDevices().", |
| 315 | (uint64_t)instance); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 316 | } |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 317 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 318 | } |
| 319 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 320 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 321 | vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, |
| 322 | VkPhysicalDeviceFeatures *pFeatures) { |
| 323 | layer_data *phy_dev_data = |
| 324 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 325 | phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceFeaturesState = |
| 326 | QUERY_DETAILS; |
| 327 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceFeatures( |
| 328 | physicalDevice, pFeatures); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 329 | } |
| 330 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 331 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 332 | vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, |
| 333 | VkFormat format, |
| 334 | VkFormatProperties *pFormatProperties) { |
| 335 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map) |
| 336 | ->instance_dispatch_table->GetPhysicalDeviceFormatProperties( |
| 337 | physicalDevice, format, pFormatProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 338 | } |
| 339 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 340 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 341 | vkGetPhysicalDeviceImageFormatProperties( |
| 342 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 343 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 344 | VkImageFormatProperties *pImageFormatProperties) { |
| 345 | return get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map) |
| 346 | ->instance_dispatch_table->GetPhysicalDeviceImageFormatProperties( |
| 347 | physicalDevice, format, type, tiling, usage, flags, |
| 348 | pImageFormatProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 349 | } |
| 350 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 351 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 352 | vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, |
| 353 | VkPhysicalDeviceProperties *pProperties) { |
| 354 | layer_data *phy_dev_data = |
| 355 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 356 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties( |
| 357 | physicalDevice, pProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 358 | } |
| 359 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 360 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 361 | vkGetPhysicalDeviceQueueFamilyProperties( |
| 362 | VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 363 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 364 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 365 | layer_data *phy_dev_data = |
| 366 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 367 | if (phy_dev_data->physicalDeviceState) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 368 | if (NULL == pQueueFamilyProperties) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 369 | phy_dev_data->physicalDeviceState |
| 370 | ->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_COUNT; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 371 | } else { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 372 | // Verify that for each physical device, this function is called |
| 373 | // first with NULL pQueueFamilyProperties ptr in order to get count |
| 374 | if (UNCALLED == |
| 375 | phy_dev_data->physicalDeviceState |
| 376 | ->vkGetPhysicalDeviceQueueFamilyPropertiesState) { |
| 377 | skipCall |= log_msg( |
| 378 | phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 379 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 380 | __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 381 | "Invalid call sequence to " |
| 382 | "vkGetPhysicalDeviceQueueFamilyProperties() w/ non-NULL " |
| 383 | "pQueueFamilyProperties. You should first call " |
| 384 | "vkGetPhysicalDeviceQueueFamilyProperties() w/ NULL " |
| 385 | "pQueueFamilyProperties to query pCount."); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 386 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 387 | // Then verify that pCount that is passed in on second call matches |
| 388 | // what was returned |
| 389 | if (phy_dev_data->physicalDeviceState->queueFamilyPropertiesCount != |
| 390 | *pCount) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 391 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 392 | // TODO: this is not a requirement of the Valid Usage section |
| 393 | // for vkGetPhysicalDeviceQueueFamilyProperties, so provide as |
| 394 | // warning |
| 395 | skipCall |= log_msg( |
| 396 | phy_dev_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, |
| 397 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 398 | __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", |
| 399 | "Call to vkGetPhysicalDeviceQueueFamilyProperties() w/ " |
| 400 | "pCount value %u, but actual count supported by this " |
| 401 | "physicalDevice is %u.", |
| 402 | *pCount, phy_dev_data->physicalDeviceState |
| 403 | ->queueFamilyPropertiesCount); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 404 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 405 | phy_dev_data->physicalDeviceState |
| 406 | ->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_DETAILS; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 407 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 408 | if (skipCall) |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 409 | return; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 410 | phy_dev_data->instance_dispatch_table |
| 411 | ->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pCount, |
| 412 | pQueueFamilyProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 413 | if (NULL == pQueueFamilyProperties) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 414 | phy_dev_data->physicalDeviceState->queueFamilyPropertiesCount = |
| 415 | *pCount; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 416 | } else { // Save queue family properties |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 417 | phy_dev_data->queueFamilyProperties.reserve(*pCount); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 418 | for (uint32_t i = 0; i < *pCount; i++) { |
| 419 | phy_dev_data->queueFamilyProperties.emplace_back( |
| 420 | new VkQueueFamilyProperties(pQueueFamilyProperties[i])); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 421 | } |
| 422 | } |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 423 | return; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 424 | } else { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 425 | log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 426 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, |
| 427 | DEVLIMITS_INVALID_PHYSICAL_DEVICE, "DL", |
| 428 | "Invalid physicalDevice (%#" PRIxLEAST64 |
| 429 | ") passed into vkGetPhysicalDeviceQueueFamilyProperties().", |
| 430 | (uint64_t)physicalDevice); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 431 | } |
| 432 | } |
| 433 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 434 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties( |
| 435 | VkPhysicalDevice physicalDevice, |
| 436 | VkPhysicalDeviceMemoryProperties *pMemoryProperties) { |
| 437 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map) |
| 438 | ->instance_dispatch_table->GetPhysicalDeviceMemoryProperties( |
| 439 | physicalDevice, pMemoryProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 440 | } |
| 441 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 442 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 443 | vkGetPhysicalDeviceSparseImageFormatProperties( |
| 444 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 445 | VkSampleCountFlagBits samples, VkImageUsageFlags usage, |
| 446 | VkImageTiling tiling, uint32_t *pNumProperties, |
| 447 | VkSparseImageFormatProperties *pProperties) { |
| 448 | get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map) |
| 449 | ->instance_dispatch_table->GetPhysicalDeviceSparseImageFormatProperties( |
| 450 | physicalDevice, format, type, samples, usage, tiling, |
| 451 | pNumProperties, pProperties); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 452 | } |
| 453 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 454 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 455 | vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 456 | uint32_t viewportCount, const VkViewport *pViewports) { |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 457 | VkBool32 skipCall = VK_FALSE; |
| 458 | /* TODO: Verify viewportCount < maxViewports from VkPhysicalDeviceLimits */ |
| 459 | if (VK_FALSE == skipCall) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 460 | layer_data *my_data = |
| 461 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 462 | my_data->device_dispatch_table->CmdSetViewport( |
| 463 | commandBuffer, firstViewport, viewportCount, pViewports); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 464 | } |
| 465 | } |
| 466 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 467 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 468 | vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
| 469 | uint32_t scissorCount, const VkRect2D *pScissors) { |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 470 | VkBool32 skipCall = VK_FALSE; |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 471 | /* TODO: Verify scissorCount < maxViewports from VkPhysicalDeviceLimits */ |
| 472 | /* TODO: viewportCount and scissorCount must match at draw time */ |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 473 | if (VK_FALSE == skipCall) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 474 | layer_data *my_data = |
| 475 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 476 | my_data->device_dispatch_table->CmdSetScissor( |
| 477 | commandBuffer, firstScissor, scissorCount, pScissors); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 478 | } |
| 479 | } |
| 480 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 481 | static void |
| 482 | createDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, |
| 483 | VkDevice device) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 484 | uint32_t i; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 485 | layer_data *my_data = |
| 486 | get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 487 | my_data->device_extensions.debug_marker_enabled = false; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 488 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 489 | for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 490 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 491 | DEBUG_MARKER_EXTENSION_NAME) == 0) { |
| 492 | /* Found a matching extension name, mark it enabled and init |
| 493 | * dispatch table*/ |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 494 | initDebugMarkerTable(device); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 495 | my_data->device_extensions.debug_marker_enabled = true; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 496 | } |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 500 | // Verify that features have been queried and verify that requested features are |
| 501 | // available |
| 502 | static VkBool32 validate_features_request(layer_data *phy_dev_data) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 503 | VkBool32 skipCall = VK_FALSE; |
| 504 | // Verify that all of the requested features are available |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 505 | // Get ptrs into actual and requested structs and if requested is 1 but |
| 506 | // actual is 0, request is invalid |
| 507 | VkBool32 *actual = |
| 508 | (VkBool32 *)&(phy_dev_data->actualPhysicalDeviceFeatures); |
| 509 | VkBool32 *requested = |
| 510 | (VkBool32 *)&(phy_dev_data->requestedPhysicalDeviceFeatures); |
| 511 | // TODO : This is a nice, compact way to loop through struct, but a bad way |
| 512 | // to report issues |
| 513 | // Need to provide the struct member name with the issue. To do that seems |
| 514 | // like we'll |
| 515 | // have to loop through each struct member which should be done w/ codegen |
| 516 | // to keep in synch. |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 517 | uint32_t errors = 0; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 518 | uint32_t totalBools = sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 519 | for (uint32_t i = 0; i < totalBools; i++) { |
| 520 | if (requested[i] > actual[i]) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 521 | skipCall |= log_msg( |
| 522 | phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 523 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, |
| 524 | DEVLIMITS_INVALID_FEATURE_REQUESTED, "DL", |
| 525 | "While calling vkCreateDevice(), requesting feature #%u in " |
| 526 | "VkPhysicalDeviceFeatures struct, which is not available on " |
| 527 | "this device.", |
| 528 | i); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 529 | errors++; |
| 530 | } |
| 531 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 532 | if (errors && |
| 533 | (UNCALLED == |
| 534 | phy_dev_data->physicalDeviceState->vkGetPhysicalDeviceFeaturesState)) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 535 | // If user didn't request features, notify them that they should |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 536 | // TODO: Verify this against the spec. I believe this is an invalid use |
| 537 | // of the API and should return an error |
| 538 | skipCall |= |
| 539 | log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, |
| 540 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 541 | __LINE__, DEVLIMITS_INVALID_FEATURE_REQUESTED, "DL", |
| 542 | "You requested features that are unavailable on this " |
| 543 | "device. You should first query feature availability by " |
| 544 | "calling vkGetPhysicalDeviceFeatures()."); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 545 | } |
Tobin Ehlis | 72b27cc | 2015-09-29 11:22:37 -0600 | [diff] [blame] | 546 | return skipCall; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 547 | } |
| 548 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 549 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 550 | vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, |
| 551 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 552 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 553 | layer_data *phy_dev_data = |
| 554 | get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
Tobin Ehlis | 54a6c18 | 2015-09-22 14:00:58 -0600 | [diff] [blame] | 555 | // First check is app has actually requested queueFamilyProperties |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 556 | if (!phy_dev_data->physicalDeviceState) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 557 | skipCall |= |
| 558 | log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 559 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 560 | __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 561 | "Invalid call to vkCreateDevice() w/o first calling " |
| 562 | "vkEnumeratePhysicalDevices()."); |
| 563 | } else if (QUERY_DETAILS != |
| 564 | phy_dev_data->physicalDeviceState |
| 565 | ->vkGetPhysicalDeviceQueueFamilyPropertiesState) { |
| 566 | // TODO: This is not called out as an invalid use in the spec so make |
| 567 | // more informative recommendation. |
| 568 | skipCall |= |
| 569 | log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, |
| 570 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 571 | __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 572 | "Call to vkCreateDevice() w/o first calling " |
| 573 | "vkGetPhysicalDeviceQueueFamilyProperties()."); |
Tobin Ehlis | 54a6c18 | 2015-09-22 14:00:58 -0600 | [diff] [blame] | 574 | } else { |
| 575 | // Check that the requested queue properties are valid |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 576 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) { |
| 577 | uint32_t requestedIndex = |
| 578 | pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex; |
| 579 | if (phy_dev_data->queueFamilyProperties.size() <= |
| 580 | requestedIndex) { // requested index is out of bounds for this |
| 581 | // physical device |
| 582 | skipCall |= log_msg( |
| 583 | phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 584 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 585 | __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 586 | "Invalid queue create request in vkCreateDevice(). Invalid " |
| 587 | "queueFamilyIndex %u requested.", |
| 588 | requestedIndex); |
| 589 | } else if (pCreateInfo->pQueueCreateInfos[i].queueCount > |
| 590 | phy_dev_data->queueFamilyProperties[requestedIndex] |
| 591 | ->queueCount) { |
| 592 | skipCall |= log_msg( |
| 593 | phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 594 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 595 | __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 596 | "Invalid queue create request in vkCreateDevice(). " |
| 597 | "QueueFamilyIndex %u only has %u queues, but requested " |
| 598 | "queueCount is %u.", |
| 599 | requestedIndex, |
| 600 | phy_dev_data->queueFamilyProperties[requestedIndex] |
| 601 | ->queueCount, |
| 602 | pCreateInfo->pQueueCreateInfos[i].queueCount); |
Tobin Ehlis | 54a6c18 | 2015-09-22 14:00:58 -0600 | [diff] [blame] | 603 | } |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 604 | } |
| 605 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 606 | // Check that any requested features are available |
| 607 | if (pCreateInfo->pEnabledFeatures) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 608 | phy_dev_data->requestedPhysicalDeviceFeatures = |
| 609 | *(pCreateInfo->pEnabledFeatures); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 610 | skipCall |= validate_features_request(phy_dev_data); |
| 611 | } |
| 612 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 613 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 614 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 615 | VkLayerDeviceCreateInfo *chain_info = |
| 616 | get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 617 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 618 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 619 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = |
| 620 | chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 621 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = |
| 622 | chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 623 | PFN_vkCreateDevice fpCreateDevice = |
| 624 | (PFN_vkCreateDevice)fpGetInstanceProcAddr(NULL, "vkCreateDevice"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 625 | if (fpCreateDevice == NULL) { |
| 626 | return VK_ERROR_INITIALIZATION_FAILED; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 627 | } |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 628 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 629 | // Advance the link info for the next element on the chain |
| 630 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 631 | |
| 632 | VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
| 633 | if (result != VK_SUCCESS) { |
| 634 | return result; |
| 635 | } |
| 636 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 637 | layer_data *my_instance_data = |
| 638 | get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 639 | layer_data *my_device_data = |
| 640 | get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 641 | my_device_data->device_dispatch_table = new VkLayerDispatchTable; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 642 | layer_init_device_dispatch_table( |
| 643 | *pDevice, my_device_data->device_dispatch_table, fpGetDeviceProcAddr); |
| 644 | my_device_data->report_data = layer_debug_report_create_device( |
| 645 | my_instance_data->report_data, *pDevice); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 646 | my_device_data->physicalDevice = gpu; |
| 647 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
| 648 | |
| 649 | // Get physical device properties for this device |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 650 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties( |
| 651 | gpu, &(phy_dev_data->physDevPropertyMap[*pDevice])); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 652 | return result; |
| 653 | } |
| 654 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 655 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 656 | vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 657 | // Free device lifetime allocations |
| 658 | dispatch_key key = get_dispatch_key(device); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 659 | 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] | 660 | my_device_data->device_dispatch_table->DestroyDevice(device, pAllocator); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 661 | tableDebugMarkerMap.erase(key); |
| 662 | delete my_device_data->device_dispatch_table; |
| 663 | layer_data_map.erase(key); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 664 | } |
| 665 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 666 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 667 | vkCreateCommandPool(VkDevice device, |
| 668 | const VkCommandPoolCreateInfo *pCreateInfo, |
| 669 | const VkAllocationCallbacks *pAllocator, |
| 670 | VkCommandPool *pCommandPool) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 671 | // TODO : Verify that requested QueueFamilyIndex for this pool exists |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 672 | VkResult result = get_my_data_ptr(get_dispatch_key(device), layer_data_map) |
| 673 | ->device_dispatch_table->CreateCommandPool( |
| 674 | device, pCreateInfo, pAllocator, pCommandPool); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 675 | return result; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 676 | } |
| 677 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 678 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 679 | vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 680 | const VkAllocationCallbacks *pAllocator) { |
| 681 | get_my_data_ptr(get_dispatch_key(device), layer_data_map) |
| 682 | ->device_dispatch_table->DestroyCommandPool(device, commandPool, |
| 683 | pAllocator); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 684 | } |
| 685 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 686 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 687 | vkResetCommandPool(VkDevice device, VkCommandPool commandPool, |
| 688 | VkCommandPoolResetFlags flags) { |
| 689 | VkResult result = get_my_data_ptr(get_dispatch_key(device), layer_data_map) |
| 690 | ->device_dispatch_table->ResetCommandPool( |
| 691 | device, commandPool, flags); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 692 | return result; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 693 | } |
| 694 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 695 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 696 | vkAllocateCommandBuffers(VkDevice device, |
| 697 | const VkCommandBufferAllocateInfo *pCreateInfo, |
| 698 | VkCommandBuffer *pCommandBuffer) { |
| 699 | VkResult result = get_my_data_ptr(get_dispatch_key(device), layer_data_map) |
| 700 | ->device_dispatch_table->AllocateCommandBuffers( |
| 701 | device, pCreateInfo, pCommandBuffer); |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 702 | return result; |
| 703 | } |
Mark Lobodzinski | fbb130e | 2015-10-06 11:59:54 -0600 | [diff] [blame] | 704 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 705 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 706 | vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 707 | uint32_t count, |
| 708 | const VkCommandBuffer *pCommandBuffers) { |
| 709 | get_my_data_ptr(get_dispatch_key(device), layer_data_map) |
| 710 | ->device_dispatch_table->FreeCommandBuffers(device, commandPool, count, |
| 711 | pCommandBuffers); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 712 | } |
| 713 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 714 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 715 | vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, |
| 716 | uint32_t queueIndex, VkQueue *pQueue) { |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 717 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 718 | layer_data *dev_data = |
| 719 | get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 720 | VkPhysicalDevice gpu = dev_data->physicalDevice; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 721 | layer_data *phy_dev_data = |
| 722 | get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 723 | if (queueFamilyIndex >= |
| 724 | phy_dev_data->queueFamilyProperties.size()) { // requested index is out |
| 725 | // of bounds for this |
| 726 | // physical device |
| 727 | skipCall |= log_msg( |
| 728 | phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 729 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, |
| 730 | DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 731 | "Invalid queueFamilyIndex %u requested in vkGetDeviceQueue().", |
| 732 | queueFamilyIndex); |
| 733 | } else if (queueIndex >= |
| 734 | phy_dev_data->queueFamilyProperties[queueFamilyIndex] |
| 735 | ->queueCount) { |
| 736 | skipCall |= log_msg( |
| 737 | phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 738 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, |
| 739 | DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 740 | "Invalid queue request in vkGetDeviceQueue(). QueueFamilyIndex %u " |
| 741 | "only has %u queues, but requested queueIndex is %u.", |
| 742 | queueFamilyIndex, |
| 743 | phy_dev_data->queueFamilyProperties[queueFamilyIndex]->queueCount, |
| 744 | queueIndex); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 745 | } |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 746 | if (skipCall) |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 747 | return; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 748 | dev_data->device_dispatch_table->GetDeviceQueue(device, queueFamilyIndex, |
| 749 | queueIndex, pQueue); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 750 | } |
| 751 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 752 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 753 | vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, |
| 754 | VkDeviceSize memoryOffset) { |
| 755 | layer_data *dev_data = |
| 756 | get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 757 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 758 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 759 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 760 | VkDeviceSize uniformAlignment = dev_data->physDevPropertyMap[device] |
| 761 | .limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 762 | if (vk_safe_modulo(memoryOffset, uniformAlignment) != 0) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 763 | skipCall |= |
| 764 | log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 765 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 766 | __LINE__, DEVLIMITS_INVALID_UNIFORM_BUFFER_OFFSET, "DL", |
| 767 | "vkBindBufferMemory(): memoryOffset %#" PRIxLEAST64 |
| 768 | " must be a multiple of device limit " |
| 769 | "minUniformBufferOffsetAlignment %#" PRIxLEAST64, |
| 770 | memoryOffset, uniformAlignment); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | if (VK_FALSE == skipCall) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 774 | result = dev_data->device_dispatch_table->BindBufferMemory( |
| 775 | device, buffer, mem, memoryOffset); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 776 | } |
| 777 | return result; |
| 778 | } |
| 779 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 780 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 781 | vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 782 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 783 | uint32_t descriptorCopyCount, |
| 784 | const VkCopyDescriptorSet *pDescriptorCopies) { |
| 785 | layer_data *dev_data = |
| 786 | get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 787 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 788 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 789 | |
Mark Young | ee3f3a2 | 2016-01-25 12:18:32 -0700 | [diff] [blame] | 790 | for (uint32_t i = 0; i < descriptorWriteCount; i++) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 791 | if ((pDescriptorWrites[i].descriptorType == |
| 792 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 793 | (pDescriptorWrites[i].descriptorType == |
| 794 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
| 795 | VkDeviceSize uniformAlignment = |
| 796 | dev_data->physDevPropertyMap[device] |
| 797 | .limits.minUniformBufferOffsetAlignment; |
| 798 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; |
| 799 | j++) { |
| 800 | if (vk_safe_modulo(pDescriptorWrites[i].pBufferInfo[j].offset, |
| 801 | uniformAlignment) != 0) { |
| 802 | skipCall |= log_msg( |
| 803 | dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 804 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 805 | __LINE__, DEVLIMITS_INVALID_UNIFORM_BUFFER_OFFSET, "DL", |
| 806 | "vkUpdateDescriptorSets(): " |
| 807 | "pDescriptorWrites[%d].pBufferInfo[%d].offset " |
| 808 | "(%#" PRIxLEAST64 |
| 809 | ") must be a multiple of device limit " |
| 810 | "minUniformBufferOffsetAlignment %#" PRIxLEAST64, |
| 811 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, |
| 812 | uniformAlignment); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 813 | } |
| 814 | } |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 815 | } else if ((pDescriptorWrites[i].descriptorType == |
| 816 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 817 | (pDescriptorWrites[i].descriptorType == |
| 818 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 819 | VkDeviceSize storageAlignment = |
| 820 | dev_data->physDevPropertyMap[device] |
| 821 | .limits.minStorageBufferOffsetAlignment; |
| 822 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; |
| 823 | j++) { |
| 824 | if (vk_safe_modulo(pDescriptorWrites[i].pBufferInfo[j].offset, |
| 825 | storageAlignment) != 0) { |
| 826 | skipCall |= log_msg( |
| 827 | dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 828 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, |
| 829 | __LINE__, DEVLIMITS_INVALID_STORAGE_BUFFER_OFFSET, "DL", |
| 830 | "vkUpdateDescriptorSets(): " |
| 831 | "pDescriptorWrites[%d].pBufferInfo[%d].offset " |
| 832 | "(%#" PRIxLEAST64 |
| 833 | ") must be a multiple of device limit " |
| 834 | "minStorageBufferOffsetAlignment %#" PRIxLEAST64, |
| 835 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, |
| 836 | storageAlignment); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 837 | } |
| 838 | } |
| 839 | } |
| 840 | } |
| 841 | if (skipCall == VK_FALSE) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 842 | dev_data->device_dispatch_table->UpdateDescriptorSets( |
| 843 | device, descriptorWriteCount, pDescriptorWrites, |
| 844 | descriptorCopyCount, pDescriptorCopies); |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 845 | } |
| 846 | } |
| 847 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 848 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 849 | vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
| 850 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 851 | const uint32_t *pData) { |
| 852 | layer_data *dev_data = |
| 853 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 854 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 855 | // dstOffset is the byte offset into the buffer to start updating and must |
| 856 | // be a multiple of 4. |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 857 | if (dstOffset & 3) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 858 | layer_data *my_data = |
| 859 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 860 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 861 | (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 862 | "vkCmdUpdateBuffer parameter, VkDeviceSize dstOffset, is " |
| 863 | "not a multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 864 | return; |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | // dataSize is the number of bytes to update, which must be a multiple of 4. |
| 869 | if (dataSize & 3) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 870 | layer_data *my_data = |
| 871 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 872 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 873 | (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 874 | "vkCmdUpdateBuffer parameter, VkDeviceSize dataSize, is " |
| 875 | "not a multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 876 | return; |
| 877 | } |
| 878 | } |
| 879 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 880 | dev_data->device_dispatch_table->CmdUpdateBuffer( |
| 881 | commandBuffer, dstBuffer, dstOffset, dataSize, pData); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 882 | } |
| 883 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 884 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 885 | vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
| 886 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) { |
| 887 | layer_data *dev_data = |
| 888 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 889 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 890 | // dstOffset is the byte offset into the buffer to start filling and must be |
| 891 | // a multiple of 4. |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 892 | if (dstOffset & 3) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 893 | layer_data *my_data = |
| 894 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 895 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 896 | (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 897 | "vkCmdFillBuffer parameter, VkDeviceSize dstOffset, is not " |
| 898 | "a multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 899 | return; |
| 900 | } |
| 901 | } |
| 902 | |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 903 | // size is the number of bytes to fill, which must be a multiple of 4. |
| 904 | if (size & 3) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 905 | layer_data *my_data = |
| 906 | get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 907 | if (log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 908 | (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "DL", |
| 909 | "vkCmdFillBuffer parameter, VkDeviceSize size, is not a " |
| 910 | "multiple of 4")) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 911 | return; |
| 912 | } |
| 913 | } |
| 914 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 915 | dev_data->device_dispatch_table->CmdFillBuffer(commandBuffer, dstBuffer, |
| 916 | dstOffset, size, data); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 917 | } |
| 918 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 919 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT( |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 920 | VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 921 | const VkAllocationCallbacks *pAllocator, |
| 922 | VkDebugReportCallbackEXT *pMsgCallback) { |
| 923 | layer_data *my_data = |
| 924 | get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 925 | VkResult res = |
| 926 | my_data->instance_dispatch_table->CreateDebugReportCallbackEXT( |
| 927 | instance, pCreateInfo, pAllocator, pMsgCallback); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 928 | if (VK_SUCCESS == res) { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 929 | res = layer_create_msg_callback(my_data->report_data, pCreateInfo, |
| 930 | pAllocator, pMsgCallback); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 931 | } |
| 932 | return res; |
| 933 | } |
| 934 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 935 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 936 | vkDestroyDebugReportCallbackEXT(VkInstance instance, |
| 937 | VkDebugReportCallbackEXT msgCallback, |
| 938 | const VkAllocationCallbacks *pAllocator) { |
| 939 | layer_data *my_data = |
| 940 | get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 941 | my_data->instance_dispatch_table->DestroyDebugReportCallbackEXT( |
| 942 | instance, msgCallback, pAllocator); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 943 | layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 944 | } |
| 945 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 946 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 947 | vkDebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, |
| 948 | VkDebugReportObjectTypeEXT objType, uint64_t object, |
| 949 | size_t location, int32_t msgCode, |
| 950 | const char *pLayerPrefix, const char *pMsg) { |
| 951 | layer_data *my_data = |
| 952 | get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 953 | my_data->instance_dispatch_table->DebugReportMessageEXT( |
| 954 | instance, flags, objType, object, location, msgCode, pLayerPrefix, |
| 955 | pMsg); |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 956 | } |
| 957 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 958 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL |
| 959 | vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 960 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 961 | return (PFN_vkVoidFunction)vkGetDeviceProcAddr; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 962 | if (!strcmp(funcName, "vkDestroyDevice")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 963 | return (PFN_vkVoidFunction)vkDestroyDevice; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 964 | if (!strcmp(funcName, "vkGetDeviceQueue")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 965 | return (PFN_vkVoidFunction)vkGetDeviceQueue; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 966 | if (!strcmp(funcName, "CreateCommandPool")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 967 | return (PFN_vkVoidFunction)vkCreateCommandPool; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 968 | if (!strcmp(funcName, "DestroyCommandPool")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 969 | return (PFN_vkVoidFunction)vkDestroyCommandPool; |
Tobin Ehlis | 9da6500 | 2015-09-24 15:25:16 -0600 | [diff] [blame] | 970 | if (!strcmp(funcName, "ResetCommandPool")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 971 | return (PFN_vkVoidFunction)vkResetCommandPool; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 972 | if (!strcmp(funcName, "vkAllocateCommandBuffers")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 973 | return (PFN_vkVoidFunction)vkAllocateCommandBuffers; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 974 | if (!strcmp(funcName, "vkFreeCommandBuffers")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 975 | return (PFN_vkVoidFunction)vkFreeCommandBuffers; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 976 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 977 | return (PFN_vkVoidFunction)vkCmdUpdateBuffer; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 978 | if (!strcmp(funcName, "vkBindBufferMemory")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 979 | return (PFN_vkVoidFunction)vkBindBufferMemory; |
Mark Lobodzinski | 941aea9 | 2016-01-13 10:23:15 -0700 | [diff] [blame] | 980 | if (!strcmp(funcName, "vkUpdateDescriptorSets")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 981 | return (PFN_vkVoidFunction)vkUpdateDescriptorSets; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 982 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 983 | return (PFN_vkVoidFunction)vkCmdFillBuffer; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 984 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 985 | if (dev == NULL) |
| 986 | return NULL; |
| 987 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 988 | layer_data *my_data = |
| 989 | get_my_data_ptr(get_dispatch_key(dev), layer_data_map); |
| 990 | VkLayerDispatchTable *pTable = my_data->device_dispatch_table; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 991 | { |
| 992 | if (pTable->GetDeviceProcAddr == NULL) |
| 993 | return NULL; |
| 994 | return pTable->GetDeviceProcAddr(dev, funcName); |
| 995 | } |
| 996 | } |
| 997 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 998 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL |
| 999 | vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1000 | PFN_vkVoidFunction fptr; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1001 | |
Tobin Ehlis | 1cb7f57 | 2015-10-06 09:09:24 -0600 | [diff] [blame] | 1002 | layer_data *my_data; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1003 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1004 | return (PFN_vkVoidFunction)vkGetInstanceProcAddr; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1005 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1006 | return (PFN_vkVoidFunction)vkGetDeviceProcAddr; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1007 | if (!strcmp(funcName, "vkCreateInstance")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1008 | return (PFN_vkVoidFunction)vkCreateInstance; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1009 | if (!strcmp(funcName, "vkDestroyInstance")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1010 | return (PFN_vkVoidFunction)vkDestroyInstance; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1011 | if (!strcmp(funcName, "vkCreateDevice")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1012 | return (PFN_vkVoidFunction)vkCreateDevice; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1013 | if (!strcmp(funcName, "vkEnumeratePhysicalDevices")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1014 | return (PFN_vkVoidFunction)vkEnumeratePhysicalDevices; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1015 | if (!strcmp(funcName, "vkGetPhysicalDeviceFeatures")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1016 | return (PFN_vkVoidFunction)vkGetPhysicalDeviceFeatures; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1017 | if (!strcmp(funcName, "vkGetPhysicalDeviceFormatProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1018 | return (PFN_vkVoidFunction)vkGetPhysicalDeviceFormatProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1019 | if (!strcmp(funcName, "vkGetPhysicalDeviceImageFormatProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1020 | return (PFN_vkVoidFunction)vkGetPhysicalDeviceImageFormatProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1021 | if (!strcmp(funcName, "vkGetPhysicalDeviceProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1022 | return (PFN_vkVoidFunction)vkGetPhysicalDeviceProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1023 | if (!strcmp(funcName, "vkGetPhysicalDeviceQueueFamilyProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1024 | return (PFN_vkVoidFunction)vkGetPhysicalDeviceQueueFamilyProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1025 | if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1026 | return (PFN_vkVoidFunction)vkGetPhysicalDeviceMemoryProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1027 | if (!strcmp(funcName, "vkGetPhysicalDeviceSparseImageFormatProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1028 | return ( |
| 1029 | PFN_vkVoidFunction)vkGetPhysicalDeviceSparseImageFormatProperties; |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 1030 | if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1031 | return (PFN_vkVoidFunction)vkEnumerateInstanceLayerProperties; |
Tobin Ehlis | fd3843f | 2015-09-29 12:26:00 -0600 | [diff] [blame] | 1032 | if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1033 | return (PFN_vkVoidFunction)vkEnumerateInstanceExtensionProperties; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1034 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1035 | if (!instance) |
| 1036 | return NULL; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1037 | |
| 1038 | my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 1039 | |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1040 | fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
| 1041 | if (fptr) |
| 1042 | return fptr; |
| 1043 | |
| 1044 | { |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 1045 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Tobin Ehlis | b5fc4fb | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1046 | if (pTable->GetInstanceProcAddr == NULL) |
| 1047 | return NULL; |
| 1048 | return pTable->GetInstanceProcAddr(instance, funcName); |
| 1049 | } |
| 1050 | } |