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