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