Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Vulkan |
| 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | |
| 29 | #include <iostream> |
| 30 | #include <string> |
| 31 | #include <sstream> |
| 32 | #include <unordered_map> |
| 33 | |
Tobin Ehlis | 7a51d90 | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 34 | #include "vk_loader_platform.h" |
Tobin Ehlis | 2d1d970 | 2015-07-03 09:42:57 -0600 | [diff] [blame] | 35 | #include "vk_layer.h" |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 36 | #include "vk_layer_config.h" |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 37 | #include "vk_enum_validate_helper.h" |
| 38 | #include "vk_struct_validate_helper.h" |
| 39 | //The following is #included again to catch certain OS-specific functions being used: |
Tobin Ehlis | 7a51d90 | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 40 | #include "vk_loader_platform.h" |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 41 | |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 42 | #include "vk_layer_table.h" |
| 43 | #include "vk_layer_data.h" |
| 44 | #include "vk_layer_logging.h" |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 45 | #include "vk_layer_extension_utils.h" |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 46 | |
| 47 | typedef struct _layer_data { |
| 48 | debug_report_data *report_data; |
| 49 | VkDbgMsgCallback logging_callback; |
Chris Forbes | d757630 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 50 | VkPhysicalDevice physicalDevice; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 51 | } layer_data; |
| 52 | |
| 53 | static std::unordered_map<void*, layer_data*> layer_data_map; |
| 54 | static device_table_map image_device_table_map; |
| 55 | static instance_table_map image_instance_table_map; |
| 56 | |
| 57 | // "my device data" |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 58 | debug_report_data *mdd(const void* object) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 59 | { |
| 60 | dispatch_key key = get_dispatch_key(object); |
| 61 | layer_data *data = get_my_data_ptr(key, layer_data_map); |
| 62 | #if DISPATCH_MAP_DEBUG |
| 63 | fprintf(stderr, "MDD: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, data); |
| 64 | #endif |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 65 | return data->report_data; |
| 66 | } |
| 67 | |
| 68 | // "my instance data" |
| 69 | debug_report_data *mid(VkInstance object) |
| 70 | { |
| 71 | dispatch_key key = get_dispatch_key(object); |
Courtney Goeltzenleuchter | 0719921 | 2015-06-22 16:19:14 -0600 | [diff] [blame] | 72 | layer_data *data = get_my_data_ptr(key, layer_data_map); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 73 | #if DISPATCH_MAP_DEBUG |
| 74 | fprintf(stderr, "MID: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, data); |
| 75 | #endif |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 76 | return data->report_data; |
| 77 | } |
| 78 | |
| 79 | static void InitImage(layer_data *data) |
| 80 | { |
| 81 | uint32_t report_flags = getLayerOptionFlags("ImageReportFlags", 0); |
| 82 | |
| 83 | uint32_t debug_action = 0; |
| 84 | getLayerOptionEnum("ImageDebugAction", (uint32_t *) &debug_action); |
| 85 | if(debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 86 | { |
| 87 | FILE *log_output = NULL; |
| 88 | const char* option_str = getLayerOption("ImageLogFilename"); |
| 89 | if(option_str) |
| 90 | { |
| 91 | log_output = fopen(option_str, "w"); |
| 92 | } |
| 93 | if(log_output == NULL) |
| 94 | { |
| 95 | log_output = stdout; |
| 96 | } |
| 97 | |
| 98 | layer_create_msg_callback(data->report_data, report_flags, log_callback, (void*)log_output, &data->logging_callback); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 103 | VkInstance instance, |
| 104 | VkFlags msgFlags, |
| 105 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 106 | void* pUserData, |
| 107 | VkDbgMsgCallback* pMsgCallback) |
| 108 | { |
| 109 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(image_instance_table_map, instance); |
| 110 | VkResult res = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 111 | if (res == VK_SUCCESS) { |
| 112 | layer_data *data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 113 | |
| 114 | res = layer_create_msg_callback(data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 115 | } |
| 116 | return res; |
| 117 | } |
| 118 | |
| 119 | VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 120 | VkInstance instance, |
| 121 | VkDbgMsgCallback msgCallback) |
| 122 | { |
| 123 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(image_instance_table_map, instance); |
| 124 | VkResult res = pTable->DbgDestroyMsgCallback(instance, msgCallback); |
| 125 | |
| 126 | layer_data *data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 127 | layer_destroy_msg_callback(data->report_data, msgCallback); |
| 128 | |
| 129 | return res; |
| 130 | } |
| 131 | |
| 132 | VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance) |
| 133 | { |
| 134 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(image_instance_table_map, *pInstance); |
| 135 | VkResult result = pTable->CreateInstance(pCreateInfo, pInstance); |
| 136 | |
| 137 | if (result == VK_SUCCESS) { |
| 138 | layer_data *data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 139 | data->report_data = debug_report_create_instance(pTable, *pInstance, pCreateInfo->extensionCount, |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 140 | pCreateInfo->ppEnabledExtensionNames); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 141 | |
| 142 | InitImage(data); |
| 143 | } |
| 144 | |
| 145 | return result; |
| 146 | } |
| 147 | |
| 148 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance) |
| 149 | { |
| 150 | // Grab the key before the instance is destroyed. |
| 151 | dispatch_key key = get_dispatch_key(instance); |
| 152 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(image_instance_table_map, instance); |
| 153 | VkResult result = pTable->DestroyInstance(instance); |
| 154 | |
| 155 | // Clean up logging callback, if any |
| 156 | layer_data *data = get_my_data_ptr(key, layer_data_map); |
| 157 | if(data->logging_callback) |
| 158 | { |
| 159 | layer_destroy_msg_callback(data->report_data, data->logging_callback); |
| 160 | } |
| 161 | |
| 162 | layer_debug_report_destroy_instance(mid(instance)); |
| 163 | layer_data_map.erase(pTable); |
| 164 | |
| 165 | image_instance_table_map.erase(key); |
| 166 | assert(image_instance_table_map.size() == 0 && "Should not have any instance mappings hanging around"); |
| 167 | |
| 168 | return result; |
| 169 | } |
| 170 | |
| 171 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) |
| 172 | { |
Courtney Goeltzenleuchter | be63799 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 173 | VkLayerDispatchTable *pTable = get_dispatch_table(image_device_table_map, *pDevice); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 174 | VkResult result = pTable->CreateDevice(physicalDevice, pCreateInfo, pDevice); |
| 175 | if(result == VK_SUCCESS) |
| 176 | { |
| 177 | layer_data *instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 178 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 179 | device_data->report_data = layer_debug_report_create_device(instance_data->report_data, *pDevice); |
Chris Forbes | d757630 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 180 | device_data->physicalDevice = physicalDevice; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | return result; |
| 184 | } |
| 185 | |
| 186 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) |
| 187 | { |
| 188 | layer_debug_report_destroy_device(device); |
| 189 | |
| 190 | dispatch_key key = get_dispatch_key(device); |
| 191 | #if DISPATCH_MAP_DEBUG |
| 192 | fprintf(stderr, "Device: %p, key: %p\n", device, key); |
| 193 | #endif |
| 194 | |
| 195 | VkResult result = get_dispatch_table(image_device_table_map, device)->DestroyDevice(device); |
| 196 | image_device_table_map.erase(key); |
| 197 | assert(image_device_table_map.size() == 0 && "Should not have any instance mappings hanging around"); |
| 198 | |
| 199 | return result; |
| 200 | } |
| 201 | |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 202 | static const VkLayerProperties pc_global_layers[] = { |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 203 | { |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 204 | "Image", |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 205 | VK_API_VERSION, |
| 206 | VK_MAKE_VERSION(0, 1, 0), |
| 207 | "Validation layer: Image ParamChecker", |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 208 | } |
| 209 | }; |
| 210 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 211 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 212 | const char *pLayerName, |
| 213 | uint32_t *pCount, |
| 214 | VkExtensionProperties* pProperties) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 215 | { |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 216 | /* ParamChecker does not have any global extensions */ |
| 217 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 218 | } |
| 219 | |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 220 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalLayerProperties( |
| 221 | uint32_t *pCount, |
| 222 | VkLayerProperties* pProperties) |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 223 | { |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 224 | return util_GetLayerProperties(ARRAY_SIZE(pc_global_layers), |
| 225 | pc_global_layers, |
| 226 | pCount, pProperties); |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 230 | VkPhysicalDevice physicalDevice, |
| 231 | const char* pLayerName, |
| 232 | uint32_t* pCount, |
| 233 | VkExtensionProperties* pProperties) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 234 | { |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 235 | /* ParamChecker does not have any physical device extensions */ |
| 236 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
| 237 | } |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 238 | |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 239 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceLayerProperties( |
| 240 | VkPhysicalDevice physicalDevice, |
| 241 | uint32_t* pCount, |
| 242 | VkLayerProperties* pProperties) |
| 243 | { |
| 244 | /* ParamChecker's physical device layers are the same as global */ |
| 245 | return util_GetLayerProperties(ARRAY_SIZE(pc_global_layers), pc_global_layers, |
| 246 | pCount, pProperties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage) |
| 250 | { |
| 251 | if(pCreateInfo->format != VK_FORMAT_UNDEFINED) |
| 252 | { |
Courtney Goeltzenleuchter | 0719921 | 2015-06-22 16:19:14 -0600 | [diff] [blame] | 253 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 254 | VkFormatProperties properties; |
Courtney Goeltzenleuchter | ab36aa6 | 2015-07-12 12:40:29 -0600 | [diff] [blame] | 255 | VkResult result = get_dispatch_table(image_instance_table_map, device_data->physicalDevice)->GetPhysicalDeviceFormatProperties( |
Chris Forbes | d757630 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 256 | device_data->physicalDevice, pCreateInfo->format, &properties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 257 | if(result != VK_SUCCESS) |
| 258 | { |
| 259 | char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, cannot be validated"; |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 260 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", str); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0)) |
| 264 | { |
| 265 | char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, contains unsupported format"; |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 266 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", str); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
| 270 | VkResult result = get_dispatch_table(image_device_table_map, device)->CreateImage(device, pCreateInfo, pImage); |
| 271 | |
| 272 | return result; |
| 273 | } |
| 274 | |
| 275 | VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass) |
| 276 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 277 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 278 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 279 | if(pCreateInfo->pAttachments[i].format != VK_FORMAT_UNDEFINED) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 280 | { |
Courtney Goeltzenleuchter | 0719921 | 2015-06-22 16:19:14 -0600 | [diff] [blame] | 281 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 282 | VkFormatProperties properties; |
Courtney Goeltzenleuchter | ab36aa6 | 2015-07-12 12:40:29 -0600 | [diff] [blame] | 283 | VkResult result = get_dispatch_table(image_instance_table_map, device_data->physicalDevice)->GetPhysicalDeviceFormatProperties( |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 284 | device_data->physicalDevice, pCreateInfo->pAttachments[i].format, &properties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 285 | if(result != VK_SUCCESS) |
| 286 | { |
| 287 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 288 | ss << "vkCreateRenderPass parameter, VkFormat in pCreateInfo->pAttachments[" << i << "], cannot be validated"; |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 289 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 290 | continue; |
| 291 | } |
| 292 | |
| 293 | if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0)) |
| 294 | { |
| 295 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 296 | ss << "vkCreateRenderPass parameter, VkFormat in pCreateInfo->pAttachments[" << i << "], contains unsupported format"; |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 297 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 302 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 303 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 304 | if(!validate_VkImageLayout(pCreateInfo->pAttachments[i].initialLayout) || |
| 305 | !validate_VkImageLayout(pCreateInfo->pAttachments[i].finalLayout)) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 306 | { |
| 307 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 308 | ss << "vkCreateRenderPass parameter, VkImageLayout in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 309 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 310 | } |
| 311 | } |
| 312 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 313 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 314 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 315 | if(!validate_VkAttachmentLoadOp(pCreateInfo->pAttachments[i].loadOp)) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 316 | { |
| 317 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 318 | ss << "vkCreateRenderPass parameter, VkAttachmentLoadOp in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 319 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 320 | } |
| 321 | } |
| 322 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 323 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 324 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 325 | if(!validate_VkAttachmentStoreOp(pCreateInfo->pAttachments[i].storeOp)) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 326 | { |
| 327 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 328 | ss << "vkCreateRenderPass parameter, VkAttachmentStoreOp in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Tony Barbour | 2a199c1 | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 329 | log_msg(mdd(device), VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 333 | VkResult result = get_dispatch_table(image_device_table_map, device)->CreateRenderPass(device, pCreateInfo, pRenderPass); |
| 334 | |
| 335 | return result; |
| 336 | } |
| 337 | |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 338 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, const char* funcName) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 339 | { |
| 340 | if (device == NULL) { |
| 341 | return NULL; |
| 342 | } |
| 343 | |
| 344 | /* loader uses this to force layer initialization; device object is wrapped */ |
| 345 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) { |
| 346 | initDeviceTable(image_device_table_map, (const VkBaseLayerObject *) device); |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 347 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 348 | } |
| 349 | |
Courtney Goeltzenleuchter | be63799 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 350 | if (!strcmp(funcName, "vkCreateDevice")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 351 | return (PFN_vkVoidFunction) vkCreateDevice; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 352 | if (!strcmp(funcName, "vkDestroyDevice")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 353 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 354 | if (!strcmp(funcName, "vkCreateImage")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 355 | return (PFN_vkVoidFunction) vkCreateImage; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 356 | if (!strcmp(funcName, "vkCreateRenderPass")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 357 | return (PFN_vkVoidFunction) vkCreateRenderPass; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 358 | |
| 359 | { |
| 360 | if (get_dispatch_table(image_device_table_map, device)->GetDeviceProcAddr == NULL) |
| 361 | return NULL; |
| 362 | return get_dispatch_table(image_device_table_map, device)->GetDeviceProcAddr(device, funcName); |
| 363 | } |
| 364 | } |
| 365 | |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 366 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance, const char* funcName) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 367 | { |
| 368 | if (instance == NULL) { |
| 369 | return NULL; |
| 370 | } |
| 371 | |
| 372 | /* loader uses this to force layer initialization; instance object is wrapped */ |
| 373 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) { |
| 374 | initInstanceTable(image_instance_table_map, (const VkBaseLayerObject *) instance); |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 375 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | if (!strcmp(funcName, "vkCreateInstance")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 379 | return (PFN_vkVoidFunction) vkCreateInstance; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 380 | if (!strcmp(funcName, "vkDestroyInstance")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 381 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 382 | if (!strcmp(funcName, "vkGetGlobalLayerProperties")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 383 | return (PFN_vkVoidFunction) vkGetGlobalLayerProperties; |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 384 | if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 385 | return (PFN_vkVoidFunction) vkGetGlobalExtensionProperties; |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 386 | if (!strcmp(funcName, "vkGetPhysicalDeviceLayerProperties")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 387 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceLayerProperties; |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 388 | if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 389 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceExtensionProperties; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 390 | |
| 391 | layer_data *data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame^] | 392 | PFN_vkVoidFunction fptr = debug_report_get_instance_proc_addr(data->report_data, funcName); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 393 | if(fptr) |
| 394 | return fptr; |
| 395 | |
| 396 | { |
| 397 | if (get_dispatch_table(image_instance_table_map, instance)->GetInstanceProcAddr == NULL) |
| 398 | return NULL; |
| 399 | return get_dispatch_table(image_instance_table_map, instance)->GetInstanceProcAddr(instance, funcName); |
| 400 | } |
| 401 | } |