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