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