Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1 | /* |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 2 | * |
Courtney Goeltzenleuchter | fcbe16f | 2015-10-29 13:50:34 -0600 | [diff] [blame] | 3 | * Copyright (C) 2015 Valve Corporation |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 4 | * Copyright (C) 2015 Google Inc. |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 23 | * |
| 24 | * Author: Jeremy Hayes <jeremy@lunarg.com> |
| 25 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 26 | * Author: Mike Stroyan <mike@LunarG.com> |
| 27 | * Author: Tobin Ehlis <tobin@lunarg.com> |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 28 | */ |
| 29 | |
Courtney Goeltzenleuchter | 8f8367e | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 30 | #include <inttypes.h> |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 31 | #include <stdio.h> |
| 32 | #include <stdlib.h> |
| 33 | #include <string.h> |
Courtney Goeltzenleuchter | 8f8367e | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 34 | #include <assert.h> |
| 35 | #include <vector> |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 36 | #include <unordered_map> |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 37 | #include <memory> |
Courtney Goeltzenleuchter | 8f8367e | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 38 | using namespace std; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 39 | |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 40 | #include "vk_loader_platform.h" |
Courtney Goeltzenleuchter | 8f8367e | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 41 | #include "vk_dispatch_table_helper.h" |
| 42 | #include "vk_struct_string_helper_cpp.h" |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 43 | #include "vk_enum_validate_helper.h" |
Courtney Goeltzenleuchter | 8f8367e | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 44 | #include "image.h" |
| 45 | #include "vk_layer_config.h" |
| 46 | #include "vk_layer_extension_utils.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 47 | #include "vk_layer_table.h" |
| 48 | #include "vk_layer_data.h" |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 49 | #include "vk_layer_extension_utils.h" |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 50 | #include "vk_layer_utils.h" |
Courtney Goeltzenleuchter | 8f8367e | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 51 | #include "vk_layer_logging.h" |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 52 | |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 53 | using namespace std; |
| 54 | |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 55 | struct layer_data { |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 56 | debug_report_data *report_data; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 57 | vector<VkDebugReportCallbackEXT> logging_callback; |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 58 | VkLayerDispatchTable* device_dispatch_table; |
| 59 | VkLayerInstanceDispatchTable *instance_dispatch_table; |
| 60 | VkPhysicalDevice physicalDevice; |
| 61 | VkPhysicalDeviceProperties physicalDeviceProperties; |
| 62 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 63 | unordered_map<VkImage, IMAGE_STATE> imageMap; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 64 | |
| 65 | layer_data() : |
| 66 | report_data(nullptr), |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 67 | device_dispatch_table(nullptr), |
| 68 | instance_dispatch_table(nullptr), |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 69 | physicalDevice(0), |
| 70 | physicalDeviceProperties() |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 71 | {}; |
| 72 | }; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 73 | |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 74 | static unordered_map<void*, layer_data*> layer_data_map; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 75 | |
Courtney Goeltzenleuchter | 6d8e818 | 2015-11-25 14:31:49 -0700 | [diff] [blame] | 76 | static void InitImage(layer_data *data, const VkAllocationCallbacks *pAllocator) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 77 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 78 | VkDebugReportCallbackEXT callback; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 79 | uint32_t report_flags = getLayerOptionFlags("ImageReportFlags", 0); |
| 80 | |
| 81 | uint32_t debug_action = 0; |
| 82 | getLayerOptionEnum("ImageDebugAction", (uint32_t *) &debug_action); |
| 83 | if(debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 84 | { |
| 85 | FILE *log_output = NULL; |
| 86 | const char* option_str = getLayerOption("ImageLogFilename"); |
Tobin Ehlis | b1df55e | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 87 | log_output = getLayerLogOutput(option_str, "Image"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 88 | VkDebugReportCallbackCreateInfoEXT dbgInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 89 | memset(&dbgInfo, 0, sizeof(dbgInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 90 | dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 91 | dbgInfo.pfnCallback = log_callback; |
| 92 | dbgInfo.pUserData = log_output; |
| 93 | dbgInfo.flags = report_flags; |
| 94 | layer_create_msg_callback(data->report_data, &dbgInfo, pAllocator, &callback); |
Courtney Goeltzenleuchter | ffcdd8b | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 95 | data->logging_callback.push_back(callback); |
| 96 | } |
| 97 | |
| 98 | if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 99 | VkDebugReportCallbackCreateInfoEXT dbgInfo; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 100 | memset(&dbgInfo, 0, sizeof(dbgInfo)); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 101 | dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 102 | dbgInfo.pfnCallback = win32_debug_output_msg; |
| 103 | dbgInfo.flags = report_flags; |
| 104 | layer_create_msg_callback(data->report_data, &dbgInfo, pAllocator, &callback); |
Courtney Goeltzenleuchter | ffcdd8b | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 105 | data->logging_callback.push_back(callback); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 109 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT( |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 110 | VkInstance instance, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 111 | const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 112 | const VkAllocationCallbacks* pAllocator, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 113 | VkDebugReportCallbackEXT* pMsgCallback) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 114 | { |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 115 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 116 | VkResult res = my_data->instance_dispatch_table->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 117 | if (res == VK_SUCCESS) { |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 118 | res = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 119 | } |
| 120 | return res; |
| 121 | } |
| 122 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 123 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT( |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 124 | VkInstance instance, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 125 | VkDebugReportCallbackEXT msgCallback, |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 126 | const VkAllocationCallbacks* pAllocator) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 127 | { |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 128 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 129 | my_data->instance_dispatch_table->DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 130 | layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 131 | } |
| 132 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 133 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT( |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 134 | VkInstance instance, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 135 | VkDebugReportFlagsEXT flags, |
| 136 | VkDebugReportObjectTypeEXT objType, |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 137 | uint64_t object, |
| 138 | size_t location, |
| 139 | int32_t msgCode, |
| 140 | const char* pLayerPrefix, |
| 141 | const char* pMsg) |
| 142 | { |
| 143 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 144 | my_data->instance_dispatch_table->DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); |
Courtney Goeltzenleuchter | f0de724 | 2015-12-01 14:10:55 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 147 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 148 | { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 149 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 150 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 151 | assert(chain_info->u.pLayerInfo); |
| 152 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 153 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
| 154 | if (fpCreateInstance == NULL) { |
| 155 | return VK_ERROR_INITIALIZATION_FAILED; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 156 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 157 | |
| 158 | // Advance the link info for the next element on the chain |
| 159 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 160 | |
| 161 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 162 | if (result != VK_SUCCESS) |
| 163 | return result; |
| 164 | |
| 165 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 166 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
| 167 | layer_init_instance_dispatch_table(*pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr); |
| 168 | |
| 169 | my_data->report_data = debug_report_create_instance( |
| 170 | my_data->instance_dispatch_table, |
| 171 | *pInstance, |
| 172 | pCreateInfo->enabledExtensionCount, |
| 173 | pCreateInfo->ppEnabledExtensionNames); |
| 174 | |
| 175 | InitImage(my_data, pAllocator); |
| 176 | |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 177 | return result; |
| 178 | } |
| 179 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 180 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 181 | { |
| 182 | // Grab the key before the instance is destroyed. |
| 183 | dispatch_key key = get_dispatch_key(instance); |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 184 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 185 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 186 | pTable->DestroyInstance(instance, pAllocator); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 187 | |
| 188 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | ffcdd8b | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 189 | while (my_data->logging_callback.size() > 0) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 190 | VkDebugReportCallbackEXT callback = my_data->logging_callback.back(); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame] | 191 | layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); |
Courtney Goeltzenleuchter | ffcdd8b | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 192 | my_data->logging_callback.pop_back(); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 193 | } |
| 194 | |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 195 | layer_debug_report_destroy_instance(my_data->report_data); |
| 196 | delete my_data->instance_dispatch_table; |
| 197 | layer_data_map.erase(key); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 198 | |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 199 | } |
| 200 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 201 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 202 | { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 203 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 204 | |
| 205 | assert(chain_info->u.pLayerInfo); |
| 206 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 207 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 208 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice) fpGetInstanceProcAddr(NULL, "vkCreateDevice"); |
| 209 | if (fpCreateDevice == NULL) { |
| 210 | return VK_ERROR_INITIALIZATION_FAILED; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 211 | } |
| 212 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 213 | // Advance the link info for the next element on the chain |
| 214 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 215 | |
| 216 | VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 217 | if (result != VK_SUCCESS) { |
| 218 | return result; |
| 219 | } |
| 220 | |
| 221 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 222 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 223 | |
| 224 | // Setup device dispatch table |
| 225 | my_device_data->device_dispatch_table = new VkLayerDispatchTable; |
| 226 | layer_init_device_dispatch_table(*pDevice, my_device_data->device_dispatch_table, fpGetDeviceProcAddr); |
| 227 | |
| 228 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
| 229 | my_device_data->physicalDevice = physicalDevice; |
| 230 | |
| 231 | my_instance_data->instance_dispatch_table->GetPhysicalDeviceProperties(physicalDevice, &(my_device_data->physicalDeviceProperties)); |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 232 | |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 233 | return result; |
| 234 | } |
| 235 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 236 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 237 | { |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 238 | dispatch_key key = get_dispatch_key(device); |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 239 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 240 | my_data->device_dispatch_table->DestroyDevice(device, pAllocator); |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 241 | delete my_data->device_dispatch_table; |
| 242 | layer_data_map.erase(key); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 243 | } |
| 244 | |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 245 | static const VkExtensionProperties instance_extensions[] = { |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 246 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 247 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, |
Courtney Goeltzenleuchter | b69cd59 | 2016-01-19 16:08:39 -0700 | [diff] [blame] | 248 | VK_EXT_DEBUG_REPORT_SPEC_VERSION |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 249 | } |
| 250 | }; |
| 251 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 252 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties( |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 253 | const char *pLayerName, |
| 254 | uint32_t *pCount, |
| 255 | VkExtensionProperties* pProperties) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 256 | { |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 257 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 258 | } |
| 259 | |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 260 | static const VkLayerProperties pc_global_layers[] = { |
| 261 | { |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 262 | "VK_LAYER_LUNARG_image", |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 263 | VK_API_VERSION, |
| 264 | VK_MAKE_VERSION(0, 1, 0), |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 265 | "Validation layer: image", |
Courtney Goeltzenleuchter | 5285766 | 2015-12-01 14:08:28 -0700 | [diff] [blame] | 266 | } |
| 267 | }; |
| 268 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 269 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 270 | uint32_t *pCount, |
| 271 | VkLayerProperties* pProperties) |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 272 | { |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 273 | return util_GetLayerProperties(ARRAY_SIZE(pc_global_layers), |
| 274 | pc_global_layers, |
| 275 | pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 276 | } |
| 277 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 278 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties( |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 279 | VkPhysicalDevice physicalDevice, |
| 280 | const char* pLayerName, |
| 281 | uint32_t* pCount, |
| 282 | VkExtensionProperties* pProperties) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 283 | { |
Jon Ashburn | 751c484 | 2015-11-02 17:37:20 -0700 | [diff] [blame] | 284 | // Image does not have any physical device extensions |
| 285 | if (pLayerName == NULL) { |
| 286 | dispatch_key key = get_dispatch_key(physicalDevice); |
| 287 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 288 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
| 289 | return pTable->EnumerateDeviceExtensionProperties( |
| 290 | physicalDevice, |
| 291 | NULL, |
| 292 | pCount, |
| 293 | pProperties); |
| 294 | } else { |
| 295 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
| 296 | } |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 297 | } |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 298 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 299 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties( |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 300 | VkPhysicalDevice physicalDevice, |
| 301 | uint32_t* pCount, |
| 302 | VkLayerProperties* pProperties) |
| 303 | { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 304 | // ParamChecker's physical device layers are the same as global |
Courtney Goeltzenleuchter | 426e187 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 305 | return util_GetLayerProperties(ARRAY_SIZE(pc_global_layers), pc_global_layers, |
| 306 | pCount, pProperties); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 307 | } |
| 308 | |
Mark Lobodzinski | 2fd634c | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 309 | // Start of the Image layer proper |
| 310 | |
| 311 | // Returns TRUE if a format is a depth-compatible format |
| 312 | bool is_depth_format(VkFormat format) |
| 313 | { |
| 314 | bool result = VK_FALSE; |
| 315 | switch (format) { |
| 316 | case VK_FORMAT_D16_UNORM: |
Chia-I Wu | 935f2ed | 2015-11-10 17:01:22 +0800 | [diff] [blame] | 317 | case VK_FORMAT_X8_D24_UNORM_PACK32: |
Mark Lobodzinski | 2fd634c | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 318 | case VK_FORMAT_D32_SFLOAT: |
| 319 | case VK_FORMAT_S8_UINT: |
| 320 | case VK_FORMAT_D16_UNORM_S8_UINT: |
| 321 | case VK_FORMAT_D24_UNORM_S8_UINT: |
| 322 | case VK_FORMAT_D32_SFLOAT_S8_UINT: |
| 323 | result = VK_TRUE; |
| 324 | break; |
| 325 | default: |
| 326 | break; |
| 327 | } |
| 328 | return result; |
| 329 | } |
| 330 | |
Mark Lobodzinski | 601ed15 | 2015-11-10 11:01:32 -0700 | [diff] [blame] | 331 | static inline uint32_t validate_VkImageLayoutKHR(VkImageLayout input_value) |
| 332 | { |
| 333 | return ((validate_VkImageLayout(input_value) == 1) || |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 334 | (input_value == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)); |
Mark Lobodzinski | 601ed15 | 2015-11-10 11:01:32 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 337 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 338 | { |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 339 | VkBool32 skipCall = VK_FALSE; |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 340 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 341 | VkImageFormatProperties ImageFormatProperties = {0}; |
| 342 | |
| 343 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 344 | VkPhysicalDevice physicalDevice = device_data->physicalDevice; |
| 345 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 346 | |
| 347 | if (pCreateInfo->format != VK_FORMAT_UNDEFINED) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 348 | { |
| 349 | VkFormatProperties properties; |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 350 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceFormatProperties( |
Chris Forbes | bc0bb77 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 351 | device_data->physicalDevice, pCreateInfo->format, &properties); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 352 | |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 353 | if ((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0)) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 354 | { |
| 355 | char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, contains unsupported format"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 356 | // TODO: Verify against Valid Use section of spec. Generally if something yield an undefined result, it's invalid |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 357 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_FORMAT_UNSUPPORTED, "IMAGE", str); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 361 | // Internal call to get format info. Still goes through layers, could potentially go directly to ICD. |
| 362 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceImageFormatProperties( |
| 363 | physicalDevice, pCreateInfo->format, pCreateInfo->imageType, pCreateInfo->tiling, |
| 364 | pCreateInfo->usage, pCreateInfo->flags, &ImageFormatProperties); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 365 | |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 366 | VkDeviceSize imageGranularity = device_data->physicalDeviceProperties.limits.bufferImageGranularity; |
| 367 | imageGranularity = imageGranularity == 1 ? 0 : imageGranularity; |
| 368 | |
| 369 | if ((pCreateInfo->extent.depth > ImageFormatProperties.maxExtent.depth) || |
| 370 | (pCreateInfo->extent.width > ImageFormatProperties.maxExtent.width) || |
| 371 | (pCreateInfo->extent.height > ImageFormatProperties.maxExtent.height)) { |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 372 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)pImage, __LINE__, |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 373 | IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", |
| 374 | "CreateImage extents exceed allowable limits for format: " |
| 375 | "Width = %d Height = %d Depth = %d: Limits for Width = %d Height = %d Depth = %d for format %s.", |
| 376 | pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth, |
| 377 | ImageFormatProperties.maxExtent.width, ImageFormatProperties.maxExtent.height, ImageFormatProperties.maxExtent.depth, |
| 378 | string_VkFormat(pCreateInfo->format)); |
| 379 | |
| 380 | } |
| 381 | |
| 382 | uint64_t totalSize = ((uint64_t)pCreateInfo->extent.width * |
| 383 | (uint64_t)pCreateInfo->extent.height * |
| 384 | (uint64_t)pCreateInfo->extent.depth * |
| 385 | (uint64_t)pCreateInfo->arrayLayers * |
| 386 | (uint64_t)pCreateInfo->samples * |
| 387 | (uint64_t)vk_format_get_size(pCreateInfo->format) + |
| 388 | (uint64_t)imageGranularity ) & ~(uint64_t)imageGranularity; |
| 389 | |
| 390 | if (totalSize > ImageFormatProperties.maxResourceSize) { |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 391 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)pImage, __LINE__, |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 392 | IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", |
| 393 | "CreateImage resource size exceeds allowable maximum " |
| 394 | "Image resource size = %#" PRIxLEAST64 ", maximum resource size = %#" PRIxLEAST64 " ", |
| 395 | totalSize, ImageFormatProperties.maxResourceSize); |
| 396 | } |
| 397 | |
| 398 | if (pCreateInfo->mipLevels > ImageFormatProperties.maxMipLevels) { |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 399 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)pImage, __LINE__, |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 400 | IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", |
| 401 | "CreateImage mipLevels=%d exceeds allowable maximum supported by format of %d", |
| 402 | pCreateInfo->mipLevels, ImageFormatProperties.maxMipLevels); |
| 403 | } |
| 404 | |
| 405 | if (pCreateInfo->arrayLayers > ImageFormatProperties.maxArrayLayers) { |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 406 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)pImage, __LINE__, |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 407 | IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", |
| 408 | "CreateImage arrayLayers=%d exceeds allowable maximum supported by format of %d", |
| 409 | pCreateInfo->arrayLayers, ImageFormatProperties.maxArrayLayers); |
| 410 | } |
| 411 | |
| 412 | if ((pCreateInfo->samples & ImageFormatProperties.sampleCounts) == 0) { |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 413 | skipCall |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)pImage, __LINE__, |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 414 | IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", |
| 415 | "CreateImage samples %s is not supported by format 0x%.8X", |
| 416 | string_VkSampleCountFlagBits(pCreateInfo->samples), ImageFormatProperties.sampleCounts); |
| 417 | } |
| 418 | |
| 419 | if (VK_FALSE == skipCall) { |
| 420 | result = device_data->device_dispatch_table->CreateImage(device, pCreateInfo, pAllocator, pImage); |
| 421 | } |
| 422 | if (result == VK_SUCCESS) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 423 | device_data->imageMap[*pImage] = IMAGE_STATE(pCreateInfo); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 424 | } |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 425 | return result; |
| 426 | } |
| 427 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 428 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 429 | { |
| 430 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 431 | device_data->imageMap.erase(image); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 432 | device_data->device_dispatch_table->DestroyImage(device, image, pAllocator); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 433 | } |
| 434 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 435 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 436 | { |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 437 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | dea0095 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 438 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 439 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 440 | { |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 441 | if(pCreateInfo->pAttachments[i].format != VK_FORMAT_UNDEFINED) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 442 | { |
| 443 | VkFormatProperties properties; |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 444 | get_my_data_ptr(get_dispatch_key(my_data->physicalDevice), layer_data_map)->instance_dispatch_table->GetPhysicalDeviceFormatProperties( |
| 445 | my_data->physicalDevice, pCreateInfo->pAttachments[i].format, &properties); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 446 | |
| 447 | if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0)) |
| 448 | { |
| 449 | std::stringstream ss; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 450 | ss << "vkCreateRenderPass parameter, VkFormat in pCreateInfo->pAttachments[" << i << "], contains unsupported format"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 451 | // TODO: Verify against Valid Use section of spec. Generally if something yield an undefined result, it's invalid |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 452 | skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_FORMAT_UNSUPPORTED, "IMAGE", "%s", ss.str().c_str()); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 457 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 458 | { |
Mark Lobodzinski | 601ed15 | 2015-11-10 11:01:32 -0700 | [diff] [blame] | 459 | if(!validate_VkImageLayoutKHR(pCreateInfo->pAttachments[i].initialLayout) || |
| 460 | !validate_VkImageLayoutKHR(pCreateInfo->pAttachments[i].finalLayout)) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 461 | { |
| 462 | std::stringstream ss; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 463 | ss << "vkCreateRenderPass parameter, VkImageLayout in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 464 | // TODO: Verify against Valid Use section of spec. Generally if something yield an undefined result, it's invalid |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 465 | skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_RENDERPASS_INVALID_ATTACHMENT, "IMAGE", "%s", ss.str().c_str()); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 466 | } |
| 467 | } |
| 468 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 469 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 470 | { |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 471 | if(!validate_VkAttachmentLoadOp(pCreateInfo->pAttachments[i].loadOp)) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 472 | { |
| 473 | std::stringstream ss; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 474 | ss << "vkCreateRenderPass parameter, VkAttachmentLoadOp in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 475 | // TODO: Verify against Valid Use section of spec. Generally if something yield an undefined result, it's invalid |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 476 | skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_RENDERPASS_INVALID_ATTACHMENT, "IMAGE", "%s", ss.str().c_str()); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 477 | } |
| 478 | } |
| 479 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 480 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 481 | { |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 482 | if(!validate_VkAttachmentStoreOp(pCreateInfo->pAttachments[i].storeOp)) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 483 | { |
| 484 | std::stringstream ss; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 485 | ss << "vkCreateRenderPass parameter, VkAttachmentStoreOp in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 486 | // TODO: Verify against Valid Use section of spec. Generally if something yield an undefined result, it's invalid |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 487 | skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_RENDERPASS_INVALID_ATTACHMENT, "IMAGE", "%s", ss.str().c_str()); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 488 | } |
| 489 | } |
| 490 | |
Mark Lobodzinski | 2fd634c | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 491 | // Any depth buffers specified as attachments? |
| 492 | bool depthFormatPresent = VK_FALSE; |
| 493 | for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
| 494 | { |
| 495 | depthFormatPresent |= is_depth_format(pCreateInfo->pAttachments[i].format); |
| 496 | } |
| 497 | |
| 498 | if (depthFormatPresent == VK_FALSE) { |
| 499 | // No depth attachment is present, validate that subpasses set depthStencilAttachment to VK_ATTACHMENT_UNUSED; |
| 500 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 501 | if (pCreateInfo->pSubpasses[i].pDepthStencilAttachment && |
| 502 | pCreateInfo->pSubpasses[i].pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { |
Mark Lobodzinski | 2fd634c | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 503 | std::stringstream ss; |
| 504 | ss << "vkCreateRenderPass has no depth/stencil attachment, yet subpass[" << i << "] has VkSubpassDescription::depthStencilAttachment value that is not VK_ATTACHMENT_UNUSED"; |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 505 | skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_RENDERPASS_INVALID_DS_ATTACHMENT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | 2fd634c | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 506 | } |
| 507 | } |
| 508 | } |
Tobin Ehlis | dea0095 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 509 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 510 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 2fd634c | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 511 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 512 | VkResult result = my_data->device_dispatch_table->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 513 | |
| 514 | return result; |
| 515 | } |
| 516 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 517 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView) |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 518 | { |
| 519 | VkBool32 skipCall = VK_FALSE; |
| 520 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 521 | auto imageEntry = device_data->imageMap.find(pCreateInfo->image); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 522 | if (imageEntry != device_data->imageMap.end()) { |
Tobin Ehlis | d923d15 | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 523 | if (pCreateInfo->subresourceRange.baseMipLevel >= imageEntry->second.mipLevels) { |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 524 | std::stringstream ss; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 525 | ss << "vkCreateImageView called with baseMipLevel " << pCreateInfo->subresourceRange.baseMipLevel |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 526 | << " for image " << pCreateInfo->image << " that only has " << imageEntry->second.mipLevels << " mip levels."; |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 527 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_VIEW_CREATE_ERROR, "IMAGE", "%s", ss.str().c_str()); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 528 | } |
Tobin Ehlis | d923d15 | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 529 | if (pCreateInfo->subresourceRange.baseArrayLayer >= imageEntry->second.arraySize) { |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 530 | std::stringstream ss; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 531 | ss << "vkCreateImageView called with baseArrayLayer " << pCreateInfo->subresourceRange.baseArrayLayer << " for image " |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 532 | << pCreateInfo->image << " that only has " << imageEntry->second.arraySize << " mip levels."; |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 533 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_VIEW_CREATE_ERROR, "IMAGE", "%s", ss.str().c_str()); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 534 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 535 | if (!pCreateInfo->subresourceRange.levelCount) { |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 536 | std::stringstream ss; |
Jeremy Hayes | 5097da0 | 2015-11-17 18:24:56 -0700 | [diff] [blame] | 537 | ss << "vkCreateImageView called with 0 in pCreateInfo->subresourceRange.levelCount."; |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 538 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_VIEW_CREATE_ERROR, "IMAGE", "%s", ss.str().c_str()); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 539 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 540 | if (!pCreateInfo->subresourceRange.layerCount) { |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 541 | std::stringstream ss; |
Jeremy Hayes | 5097da0 | 2015-11-17 18:24:56 -0700 | [diff] [blame] | 542 | ss << "vkCreateImageView called with 0 in pCreateInfo->subresourceRange.layerCount."; |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 543 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, IMAGE_VIEW_CREATE_ERROR, "IMAGE", "%s", ss.str().c_str()); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 544 | } |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 545 | |
Mark Lobodzinski | 1e638c6 | 2016-01-11 16:50:30 -0700 | [diff] [blame] | 546 | VkImageCreateFlags imageFlags = imageEntry->second.flags; |
Tobin Ehlis | d923d15 | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 547 | VkFormat imageFormat = imageEntry->second.format; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 548 | VkFormat ivciFormat = pCreateInfo->format; |
| 549 | VkImageAspectFlags aspectMask = pCreateInfo->subresourceRange.aspectMask; |
| 550 | |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 551 | // Validate VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT state |
Mark Lobodzinski | 1e638c6 | 2016-01-11 16:50:30 -0700 | [diff] [blame] | 552 | if (imageFlags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) { |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 553 | // Format MUST be compatible (in the same format compatibility class) as the format the image was created with |
| 554 | if (vk_format_get_compatibility_class(imageFormat) != vk_format_get_compatibility_class(ivciFormat)) { |
| 555 | std::stringstream ss; |
| 556 | ss << "vkCreateImageView(): ImageView format " << string_VkFormat(ivciFormat) << " is not in the same format compatibility class as image (" << |
| 557 | (uint64_t)pCreateInfo->image << ") format " << string_VkFormat(imageFormat) << ". Images created with the VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " << |
| 558 | "can support ImageViews with differing formats but they must be in the same compatibility class."; |
| 559 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, |
| 560 | IMAGE_VIEW_CREATE_ERROR, "IMAGE", "%s", ss.str().c_str()); |
| 561 | } |
| 562 | } else { |
| 563 | // Format MUST be IDENTICAL to the format the image was created with |
| 564 | if (imageFormat != ivciFormat) { |
| 565 | std::stringstream ss; |
| 566 | ss << "vkCreateImageView() format " << string_VkFormat(ivciFormat) << " differs from image " << (uint64_t)pCreateInfo->image << " format " << |
| 567 | string_VkFormat(imageFormat) << ". Formats MUST be IDENTICAL unless VK_IMAGE_CREATE_MUTABLE_FORMAT BIT was set on image creation."; |
| 568 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, |
| 569 | IMAGE_VIEW_CREATE_ERROR, "IMAGE", "%s", ss.str().c_str()); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | // Validate correct image aspect bits for desired formats and format consistency |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 574 | if (vk_format_is_color(imageFormat)) { |
| 575 | if ((aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != VK_IMAGE_ASPECT_COLOR_BIT) { |
| 576 | std::stringstream ss; |
| 577 | ss << "vkCreateImageView: Color image formats must have the VK_IMAGE_ASPECT_COLOR_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 578 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 579 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 580 | } |
| 581 | if ((aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != aspectMask) { |
| 582 | std::stringstream ss; |
| 583 | ss << "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 584 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 585 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 586 | } |
| 587 | if (VK_FALSE == vk_format_is_color(ivciFormat)) { |
| 588 | std::stringstream ss; |
| 589 | ss << "vkCreateImageView: The image view's format can differ from the parent image's format, but both must be " |
| 590 | << "color formats. ImageFormat is " << string_VkFormat(imageFormat) << " ImageViewFormat is " << string_VkFormat(ivciFormat); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 591 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 592 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_FORMAT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 593 | } |
| 594 | // TODO: Uncompressed formats are compatible if they occupy they same number of bits per pixel. |
| 595 | // Compressed formats are compatible if the only difference between them is the numerical type of |
| 596 | // the uncompressed pixels (e.g. signed vs. unsigned, or sRGB vs. UNORM encoding). |
| 597 | } else if (vk_format_is_depth_and_stencil(imageFormat)) { |
Mark Lobodzinski | d21bbff | 2015-11-23 09:07:20 -0700 | [diff] [blame] | 598 | if ((aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) == 0) { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 599 | std::stringstream ss; |
Mark Lobodzinski | 26d5804 | 2015-11-18 09:14:04 -0700 | [diff] [blame] | 600 | ss << "vkCreateImageView: Depth/stencil image formats must have at least one of VK_IMAGE_ASPECT_DEPTH_BIT and VK_IMAGE_ASPECT_STENCIL_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 601 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 602 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 603 | } |
| 604 | if ((aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != aspectMask) { |
| 605 | std::stringstream ss; |
| 606 | ss << "vkCreateImageView: Combination depth/stencil image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT and VK_IMAGE_ASPECT_STENCIL_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 607 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 608 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 609 | } |
| 610 | } else if (vk_format_is_depth_only(imageFormat)) { |
| 611 | if ((aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) { |
| 612 | std::stringstream ss; |
| 613 | ss << "vkCreateImageView: Depth-only image formats must have the VK_IMAGE_ASPECT_DEPTH_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 614 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 615 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 616 | } |
| 617 | if ((aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != aspectMask) { |
| 618 | std::stringstream ss; |
| 619 | ss << "vkCreateImageView: Depth-only image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 620 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 621 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 622 | } |
| 623 | } else if (vk_format_is_stencil_only(imageFormat)) { |
| 624 | if ((aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT) { |
| 625 | std::stringstream ss; |
| 626 | ss << "vkCreateImageView: Stencil-only image formats must have the VK_IMAGE_ASPECT_STENCIL_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 627 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 628 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 629 | } |
| 630 | if ((aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != aspectMask) { |
| 631 | std::stringstream ss; |
| 632 | ss << "vkCreateImageView: Stencil-only image formats can have only the VK_IMAGE_ASPECT_STENCIL_BIT set"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 633 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 634 | (uint64_t)pCreateInfo->image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 635 | } |
| 636 | } |
| 637 | } |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 638 | |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 639 | if (skipCall) { |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 640 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 641 | } |
Tobin Ehlis | dea0095 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 642 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 643 | VkResult result = device_data->device_dispatch_table->CreateImageView(device, pCreateInfo, pAllocator, pView); |
Tobin Ehlis | ad8c446 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 644 | return result; |
| 645 | } |
| 646 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 647 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 648 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 649 | VkImage image, |
| 650 | VkImageLayout imageLayout, |
| 651 | const VkClearColorValue *pColor, |
| 652 | uint32_t rangeCount, |
| 653 | const VkImageSubresourceRange *pRanges) |
| 654 | { |
| 655 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 656 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 657 | // For each range, image aspect must be color only |
| 658 | for (uint32_t i = 0; i < rangeCount; i++) { |
| 659 | if (pRanges[i].aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 660 | char const str[] = "vkCmdClearColorImage aspectMasks for all subresource ranges must be set to VK_IMAGE_ASPECT_COLOR_BIT"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 661 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 662 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 663 | } |
| 664 | } |
| 665 | |
| 666 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 667 | device_data->device_dispatch_table->CmdClearColorImage(commandBuffer, image, imageLayout, |
| 668 | pColor, rangeCount, pRanges); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 669 | } |
| 670 | } |
| 671 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 672 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 673 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 674 | VkImage image, |
| 675 | VkImageLayout imageLayout, |
| 676 | const VkClearDepthStencilValue *pDepthStencil, |
| 677 | uint32_t rangeCount, |
| 678 | const VkImageSubresourceRange *pRanges) |
| 679 | { |
| 680 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 681 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 682 | // For each range, Image aspect must be depth or stencil or both |
| 683 | for (uint32_t i = 0; i < rangeCount; i++) { |
| 684 | if (((pRanges[i].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 685 | ((pRanges[i].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) |
| 686 | { |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 687 | char const str[] = "vkCmdClearDepthStencilImage aspectMasks for all subresource ranges must be " |
| 688 | "set to VK_IMAGE_ASPECT_DEPTH_BIT and/or VK_IMAGE_ASPECT_STENCIL_BIT"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 689 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 690 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 691 | } |
| 692 | } |
| 693 | |
| 694 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 695 | device_data->device_dispatch_table->CmdClearDepthStencilImage(commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 696 | image, imageLayout, pDepthStencil, rangeCount, pRanges); |
| 697 | } |
| 698 | } |
| 699 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 700 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 701 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 702 | VkImage srcImage, |
| 703 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 704 | VkImage dstImage, |
| 705 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 706 | uint32_t regionCount, |
| 707 | const VkImageCopy *pRegions) |
| 708 | { |
| 709 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 710 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 711 | auto srcImageEntry = device_data->imageMap.find(srcImage); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 712 | auto dstImageEntry = device_data->imageMap.find(dstImage); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 713 | |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 714 | // For each region, src and dst number of layers should not be zero |
| 715 | // For each region, src and dst number of layers must match |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 716 | // For each region, src aspect mask must match dest aspect mask |
| 717 | // For each region, color aspects cannot be mixed with depth/stencil aspects |
| 718 | for (uint32_t i = 0; i < regionCount; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 719 | if(pRegions[i].srcSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 720 | { |
| 721 | char const str[] = "vkCmdCopyImage: number of layers in source subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 722 | // TODO: Verify against Valid Use section of spec |
| 723 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 724 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 725 | } |
| 726 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 727 | if(pRegions[i].dstSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 728 | { |
| 729 | char const str[] = "vkCmdCopyImage: number of layers in destination subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 730 | // TODO: Verify against Valid Use section of spec |
| 731 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 732 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 733 | } |
| 734 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 735 | if(pRegions[i].srcSubresource.layerCount != pRegions[i].dstSubresource.layerCount) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 736 | { |
| 737 | char const str[] = "vkCmdCopyImage: number of layers in source and destination subresources must match"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 738 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 739 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 740 | } |
| 741 | |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 742 | if (pRegions[i].srcSubresource.aspectMask != pRegions[i].dstSubresource.aspectMask) { |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 743 | char const str[] = "vkCmdCopyImage: Src and dest aspectMasks for each region must match"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 744 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 745 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 746 | } |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 747 | if ((pRegions[i].srcSubresource.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) && |
| 748 | (pRegions[i].srcSubresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))) { |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 749 | char const str[] = "vkCmdCopyImage aspectMask cannot specify both COLOR and DEPTH/STENCIL aspects"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 750 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 751 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 752 | } |
| 753 | } |
| 754 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 755 | if ((srcImageEntry != device_data->imageMap.end()) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 756 | && (dstImageEntry != device_data->imageMap.end())) { |
| 757 | if (srcImageEntry->second.imageType != dstImageEntry->second.imageType) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 758 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image types."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 759 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 760 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_TYPE, "IMAGE", str); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 761 | } |
| 762 | // Check that format is same size or exact stencil/depth |
Tobin Ehlis | d923d15 | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 763 | if (is_depth_format(srcImageEntry->second.format)) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 764 | if (srcImageEntry->second.format != dstImageEntry->second.format) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 765 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image depth/stencil formats."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 766 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 767 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 768 | } |
| 769 | } else { |
Tobin Ehlis | d923d15 | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 770 | size_t srcSize = vk_format_get_size(srcImageEntry->second.format); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 771 | size_t destSize = vk_format_get_size(dstImageEntry->second.format); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 772 | if (srcSize != destSize) { |
| 773 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image format sizes."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 774 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 775 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 776 | } |
| 777 | } |
| 778 | } |
| 779 | |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 780 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 781 | device_data->device_dispatch_table->CmdCopyImage(commandBuffer, srcImage, |
| 782 | srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 783 | } |
| 784 | } |
| 785 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 786 | VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 787 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 788 | uint32_t attachmentCount, |
| 789 | const VkClearAttachment* pAttachments, |
| 790 | uint32_t rectCount, |
Courtney Goeltzenleuchter | 4ca43f6 | 2015-10-15 18:22:08 -0600 | [diff] [blame] | 791 | const VkClearRect* pRects) |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 792 | { |
| 793 | VkBool32 skipCall = VK_FALSE; |
| 794 | VkImageAspectFlags aspectMask; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 795 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 796 | for (uint32_t i = 0; i < attachmentCount; i++) { |
| 797 | aspectMask = pAttachments[i].aspectMask; |
| 798 | if (aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { |
| 799 | if (aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { |
| 800 | // VK_IMAGE_ASPECT_COLOR_BIT is not the only bit set for this attachment |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 801 | char const str[] = "vkCmdClearAttachments aspectMask [%d] must set only VK_IMAGE_ASPECT_COLOR_BIT of a color attachment."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 802 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 803 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str, i); |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 804 | } |
| 805 | } else { |
| 806 | // Image aspect must be depth or stencil or both |
| 807 | if (((aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 808 | ((aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) |
| 809 | { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 810 | char const str[] = "vkCmdClearAttachments aspectMask [%d] must be set to VK_IMAGE_ASPECT_DEPTH_BIT and/or VK_IMAGE_ASPECT_STENCIL_BIT"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 811 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 812 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str, i); |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 813 | } |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 818 | device_data->device_dispatch_table->CmdClearAttachments(commandBuffer, |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 819 | attachmentCount, pAttachments, rectCount, pRects); |
| 820 | } |
| 821 | } |
| 822 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 823 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 824 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 825 | VkImage srcImage, |
| 826 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 827 | VkBuffer dstBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 828 | uint32_t regionCount, |
| 829 | const VkBufferImageCopy *pRegions) |
| 830 | { |
| 831 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 832 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 833 | // For each region, the number of layers in the image subresource should not be zero |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 834 | // Image aspect must be ONE OF color, depth, stencil |
| 835 | for (uint32_t i = 0; i < regionCount; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 836 | if(pRegions[i].imageSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 837 | { |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 838 | char const str[] = "vkCmdCopyImageToBuffer: number of layers in image subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 839 | // TODO: Verify against Valid Use section of spec, if this case yields undefined results, then it's an error |
| 840 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 841 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 842 | } |
| 843 | |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 844 | VkImageAspectFlags aspectMask = pRegions[i].imageSubresource.aspectMask; |
| 845 | if ((aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) && |
| 846 | (aspectMask != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 847 | (aspectMask != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 848 | char const str[] = "vkCmdCopyImageToBuffer: aspectMasks for each region must specify only COLOR or DEPTH or STENCIL"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 849 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 850 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 851 | } |
| 852 | } |
| 853 | |
| 854 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 855 | device_data->device_dispatch_table->CmdCopyImageToBuffer(commandBuffer, |
| 856 | srcImage, srcImageLayout, dstBuffer, regionCount, pRegions); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 857 | } |
| 858 | } |
| 859 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 860 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 861 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 862 | VkBuffer srcBuffer, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 863 | VkImage dstImage, |
| 864 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 865 | uint32_t regionCount, |
| 866 | const VkBufferImageCopy *pRegions) |
| 867 | { |
| 868 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 869 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 870 | // For each region, the number of layers in the image subresource should not be zero |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 871 | // Image aspect must be ONE OF color, depth, stencil |
| 872 | for (uint32_t i = 0; i < regionCount; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 873 | if(pRegions[i].imageSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 874 | { |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 875 | char const str[] = "vkCmdCopyBufferToImage: number of layers in image subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 876 | // TODO: Verify against Valid Use section of spec, if this case yields undefined results, then it's an error |
| 877 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 878 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 879 | } |
| 880 | |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 881 | VkImageAspectFlags aspectMask = pRegions[i].imageSubresource.aspectMask; |
| 882 | if ((aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) && |
| 883 | (aspectMask != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 884 | (aspectMask != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 885 | char const str[] = "vkCmdCopyBufferToImage: aspectMasks for each region must specify only COLOR or DEPTH or STENCIL"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 886 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 887 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 888 | } |
| 889 | } |
| 890 | |
| 891 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 892 | device_data->device_dispatch_table->CmdCopyBufferToImage(commandBuffer, |
| 893 | srcBuffer, dstImage, dstImageLayout, regionCount, pRegions); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 894 | } |
| 895 | } |
| 896 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 897 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 898 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 899 | VkImage srcImage, |
| 900 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 901 | VkImage dstImage, |
| 902 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 903 | uint32_t regionCount, |
| 904 | const VkImageBlit *pRegions, |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 905 | VkFilter filter) |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 906 | { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 907 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 908 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 909 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 910 | auto srcImageEntry = device_data->imageMap.find(srcImage); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 911 | auto dstImageEntry = device_data->imageMap.find(dstImage); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 912 | |
| 913 | if ((srcImageEntry != device_data->imageMap.end()) && |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 914 | (dstImageEntry != device_data->imageMap.end())) { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 915 | |
Tobin Ehlis | d923d15 | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 916 | VkFormat srcFormat = srcImageEntry->second.format; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 917 | VkFormat dstFormat = dstImageEntry->second.format; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 918 | |
| 919 | // Validate consistency for signed and unsigned formats |
| 920 | if ((vk_format_is_sint(srcFormat) && !vk_format_is_sint(dstFormat)) || |
| 921 | (vk_format_is_uint(srcFormat) && !vk_format_is_uint(dstFormat))) { |
| 922 | std::stringstream ss; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 923 | ss << "vkCmdBlitImage: If one of srcImage and dstImage images has signed/unsigned integer format, " |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 924 | << "the other one must also have signed/unsigned integer format. " |
Mark Lobodzinski | 2e8ccbb | 2015-12-31 09:49:50 -0700 | [diff] [blame] | 925 | << "Source format is " << string_VkFormat(srcFormat) << " Destination format is " << string_VkFormat(dstFormat); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 926 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 927 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_FORMAT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | // Validate aspect bits and formats for depth/stencil images |
| 931 | if (vk_format_is_depth_or_stencil(srcFormat) || |
| 932 | vk_format_is_depth_or_stencil(dstFormat)) { |
| 933 | if (srcFormat != dstFormat) { |
| 934 | std::stringstream ss; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 935 | ss << "vkCmdBlitImage: If one of srcImage and dstImage images has a format of depth, stencil or depth " |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 936 | << "stencil, the other one must have exactly the same format. " |
Mark Lobodzinski | 2e8ccbb | 2015-12-31 09:49:50 -0700 | [diff] [blame] | 937 | << "Source format is " << string_VkFormat(srcFormat) << " Destination format is " << string_VkFormat(dstFormat); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 938 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 939 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_FORMAT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | for (uint32_t i = 0; i < regionCount; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 943 | if(pRegions[i].srcSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 944 | { |
| 945 | char const str[] = "vkCmdBlitImage: number of layers in source subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 946 | // TODO: Verify against Valid Use section of spec, if this case yields undefined results, then it's an error |
| 947 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 948 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 949 | } |
| 950 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 951 | if(pRegions[i].dstSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 952 | { |
| 953 | char const str[] = "vkCmdBlitImage: number of layers in destination subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 954 | // TODO: Verify against Valid Use section of spec, if this case yields undefined results, then it's an error |
| 955 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 956 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 957 | } |
| 958 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 959 | if(pRegions[i].srcSubresource.layerCount != pRegions[i].dstSubresource.layerCount) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 960 | { |
| 961 | char const str[] = "vkCmdBlitImage: number of layers in source and destination subresources must match"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 962 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 963 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 964 | } |
| 965 | |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 966 | VkImageAspectFlags srcAspect = pRegions[i].srcSubresource.aspectMask; |
| 967 | VkImageAspectFlags dstAspect = pRegions[i].dstSubresource.aspectMask; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 968 | |
| 969 | if (srcAspect != dstAspect) { |
| 970 | std::stringstream ss; |
| 971 | ss << "vkCmdBlitImage: Image aspects of depth/stencil images should match"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 972 | // TODO: Verify against Valid Use section of spec, if this case yields undefined results, then it's an error |
| 973 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 974 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 975 | } |
| 976 | if (vk_format_is_depth_and_stencil(srcFormat)) { |
Mark Lobodzinski | b016685 | 2016-01-12 13:18:44 -0700 | [diff] [blame] | 977 | if ((srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) && (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 978 | std::stringstream ss; |
Mark Lobodzinski | b016685 | 2016-01-12 13:18:44 -0700 | [diff] [blame] | 979 | ss << "vkCmdBlitImage: Combination depth/stencil image formats must have only one of VK_IMAGE_ASPECT_DEPTH_BIT " |
| 980 | << "and VK_IMAGE_ASPECT_STENCIL_BIT set in srcImage and dstImage"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 981 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 982 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 983 | } |
| 984 | } else if (vk_format_is_stencil_only(srcFormat)) { |
| 985 | if (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT) { |
| 986 | std::stringstream ss; |
| 987 | ss << "vkCmdBlitImage: Stencil-only image formats must have only the VK_IMAGE_ASPECT_STENCIL_BIT " |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 988 | << "set in both the srcImage and dstImage"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 989 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 990 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 991 | } |
| 992 | } else if (vk_format_is_depth_only(srcFormat)) { |
| 993 | if (srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) { |
| 994 | std::stringstream ss; |
| 995 | ss << "vkCmdBlitImage: Depth-only image formats must have only the VK_IMAGE_ASPECT_DEPTH " |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 996 | << "set in both the srcImage and dstImage"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 997 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 998 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 999 | } |
| 1000 | } |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | // Validate filter |
| 1005 | if (vk_format_is_depth_or_stencil(srcFormat) || |
| 1006 | vk_format_is_int(srcFormat)) { |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 1007 | if (filter != VK_FILTER_NEAREST) { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1008 | std::stringstream ss; |
| 1009 | ss << "vkCmdBlitImage: If the format of srcImage is a depth, stencil, depth stencil or integer-based format " |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 1010 | << "then filter must be VK_FILTER_NEAREST."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1011 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1012 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_FILTER, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1013 | } |
| 1014 | } |
| 1015 | } |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1016 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1017 | device_data->device_dispatch_table->CmdBlitImage(commandBuffer, srcImage, |
| 1018 | srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1019 | } |
| 1020 | |
Jeremy Hayes | 01b3889 | 2015-11-17 18:19:55 -0700 | [diff] [blame] | 1021 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier( |
| 1022 | VkCommandBuffer commandBuffer, |
| 1023 | VkPipelineStageFlags srcStageMask, |
| 1024 | VkPipelineStageFlags dstStageMask, |
| 1025 | VkDependencyFlags dependencyFlags, |
| 1026 | uint32_t memoryBarrierCount, |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1027 | const VkMemoryBarrier *pMemoryBarriers, |
| 1028 | uint32_t bufferMemoryBarrierCount, |
| 1029 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 1030 | uint32_t imageMemoryBarrierCount, |
| 1031 | const VkImageMemoryBarrier *pImageMemoryBarriers) |
Jeremy Hayes | 01b3889 | 2015-11-17 18:19:55 -0700 | [diff] [blame] | 1032 | { |
| 1033 | VkBool32 skipCall = VK_FALSE; |
| 1034 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 1035 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1036 | for (uint32_t i = 0; i < imageMemoryBarrierCount; ++i) |
Jeremy Hayes | 01b3889 | 2015-11-17 18:19:55 -0700 | [diff] [blame] | 1037 | { |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1038 | VkImageMemoryBarrier const*const barrier = (VkImageMemoryBarrier const*const) &pImageMemoryBarriers[i]; |
Jeremy Hayes | 01b3889 | 2015-11-17 18:19:55 -0700 | [diff] [blame] | 1039 | if (barrier->sType == VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER) |
| 1040 | { |
| 1041 | if (barrier->subresourceRange.layerCount == 0) |
| 1042 | { |
| 1043 | std::stringstream ss; |
| 1044 | ss << "vkCmdPipelineBarrier called with 0 in ppMemoryBarriers[" << i << "]->subresourceRange.layerCount."; |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1045 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, |
| 1046 | 0, __LINE__, IMAGE_INVALID_IMAGE_RESOURCE, "IMAGE", "%s", ss.str().c_str()); |
Jeremy Hayes | 01b3889 | 2015-11-17 18:19:55 -0700 | [diff] [blame] | 1047 | } |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | if (skipCall) |
| 1052 | { |
| 1053 | return; |
| 1054 | } |
| 1055 | |
| 1056 | device_data->device_dispatch_table->CmdPipelineBarrier(commandBuffer, srcStageMask, dstStageMask, dependencyFlags, |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1057 | memoryBarrierCount, pMemoryBarriers, |
| 1058 | bufferMemoryBarrierCount, pBufferMemoryBarriers, |
| 1059 | imageMemoryBarrierCount, pImageMemoryBarriers); |
Jeremy Hayes | 01b3889 | 2015-11-17 18:19:55 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1062 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1063 | VkCommandBuffer commandBuffer, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1064 | VkImage srcImage, |
| 1065 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1066 | VkImage dstImage, |
| 1067 | VkImageLayout dstImageLayout, |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1068 | uint32_t regionCount, |
| 1069 | const VkImageResolve *pRegions) |
| 1070 | { |
| 1071 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1072 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1073 | auto srcImageEntry = device_data->imageMap.find(srcImage); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1074 | auto dstImageEntry = device_data->imageMap.find(dstImage); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1075 | |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 1076 | // For each region, the number of layers in the image subresource should not be zero |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1077 | // For each region, src and dest image aspect must be color only |
| 1078 | for (uint32_t i = 0; i < regionCount; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1079 | if(pRegions[i].srcSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 1080 | { |
| 1081 | char const str[] = "vkCmdResolveImage: number of layers in source subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1082 | // TODO: Verify against Valid Use section of spec. Generally if something yield an undefined result, it's invalid/error |
| 1083 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1084 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 1085 | } |
| 1086 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1087 | if(pRegions[i].dstSubresource.layerCount == 0) |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 1088 | { |
| 1089 | char const str[] = "vkCmdResolveImage: number of layers in destination subresource is zero"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1090 | |
| 1091 | // TODO: Verify against Valid Use section of spec. Generally if something yield an undefined result, it's invalid/error |
| 1092 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARN_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1093 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
Jeremy Hayes | 148bab2 | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 1094 | } |
| 1095 | |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 1096 | if ((pRegions[i].srcSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) || |
| 1097 | (pRegions[i].dstSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT)) { |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1098 | char const str[] = "vkCmdResolveImage: src and dest aspectMasks for each region must specify only VK_IMAGE_ASPECT_COLOR_BIT"; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1099 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1100 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1101 | } |
| 1102 | } |
| 1103 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1104 | if ((srcImageEntry != device_data->imageMap.end()) && |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1105 | (dstImageEntry != device_data->imageMap.end())) { |
| 1106 | if (srcImageEntry->second.format != dstImageEntry->second.format) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1107 | char const str[] = "vkCmdResolveImage called with unmatched source and dest formats."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1108 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1109 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1110 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1111 | if (srcImageEntry->second.imageType != dstImageEntry->second.imageType) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1112 | char const str[] = "vkCmdResolveImage called with unmatched source and dest image types."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1113 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1114 | (uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_TYPE, "IMAGE", str); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1115 | } |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1116 | if (srcImageEntry->second.samples == VK_SAMPLE_COUNT_1_BIT) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1117 | char const str[] = "vkCmdResolveImage called with source sample count less than 2."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1118 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1119 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_RESOLVE_SAMPLES, "IMAGE", str); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1120 | } |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1121 | if (dstImageEntry->second.samples != VK_SAMPLE_COUNT_1_BIT) { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1122 | char const str[] = "vkCmdResolveImage called with dest sample count greater than 1."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1123 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1124 | (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_RESOLVE_SAMPLES, "IMAGE", str); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 1125 | } |
| 1126 | } |
| 1127 | |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1128 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1129 | device_data->device_dispatch_table->CmdResolveImage(commandBuffer, srcImage, |
| 1130 | srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1131 | } |
| 1132 | } |
| 1133 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1134 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout( |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1135 | VkDevice device, |
| 1136 | VkImage image, |
| 1137 | const VkImageSubresource *pSubresource, |
| 1138 | VkSubresourceLayout *pLayout) |
| 1139 | { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1140 | VkBool32 skipCall = VK_FALSE; |
| 1141 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 1142 | VkFormat format; |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1143 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1144 | auto imageEntry = device_data->imageMap.find(image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1145 | |
| 1146 | // Validate that image aspects match formats |
| 1147 | if (imageEntry != device_data->imageMap.end()) { |
Tobin Ehlis | d923d15 | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 1148 | format = imageEntry->second.format; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1149 | if (vk_format_is_color(format)) { |
Chia-I Wu | 52b07e7 | 2015-10-27 19:55:05 +0800 | [diff] [blame] | 1150 | if (pSubresource->aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1151 | std::stringstream ss; |
Chia-I Wu | 52b07e7 | 2015-10-27 19:55:05 +0800 | [diff] [blame] | 1152 | ss << "vkGetImageSubresourceLayout: For color formats, the aspectMask field of VkImageSubresource must be VK_IMAGE_ASPECT_COLOR."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1153 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1154 | (uint64_t)image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1155 | } |
| 1156 | } else if (vk_format_is_depth_or_stencil(format)) { |
Chia-I Wu | 52b07e7 | 2015-10-27 19:55:05 +0800 | [diff] [blame] | 1157 | if ((pSubresource->aspectMask != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 1158 | (pSubresource->aspectMask != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1159 | std::stringstream ss; |
Chia-I Wu | 52b07e7 | 2015-10-27 19:55:05 +0800 | [diff] [blame] | 1160 | ss << "vkGetImageSubresourceLayout: For depth/stencil formats, the aspectMask selects either the depth or stencil image aspectMask."; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1161 | skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 37a38b1 | 2016-01-04 13:32:45 -0700 | [diff] [blame] | 1162 | (uint64_t)image, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | |
| 1167 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1168 | device_data->device_dispatch_table->GetImageSubresourceLayout(device, |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 1169 | image, pSubresource, pLayout); |
| 1170 | } |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1171 | } |
| 1172 | |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 1173 | VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties) |
| 1174 | { |
| 1175 | layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1176 | phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties(physicalDevice, pProperties); |
| 1177 | } |
| 1178 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1179 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* funcName) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1180 | { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1181 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1182 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1183 | if (!strcmp(funcName, "vkDestroyDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1184 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1185 | if (!strcmp(funcName, "vkCreateImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1186 | return (PFN_vkVoidFunction) vkCreateImage; |
Mark Lobodzinski | 46fc3dd | 2015-10-29 12:58:33 -0600 | [diff] [blame] | 1187 | if (!strcmp(funcName, "vkDestroyImage")) |
| 1188 | return (PFN_vkVoidFunction) vkDestroyImage; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 1189 | if (!strcmp(funcName, "vkCreateImageView")) |
| 1190 | return (PFN_vkVoidFunction) vkCreateImageView; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1191 | if (!strcmp(funcName, "vkCreateRenderPass")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1192 | return (PFN_vkVoidFunction) vkCreateRenderPass; |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1193 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
| 1194 | return (PFN_vkVoidFunction) vkCmdClearColorImage; |
| 1195 | if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) |
| 1196 | return (PFN_vkVoidFunction) vkCmdClearDepthStencilImage; |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 1197 | if (!strcmp(funcName, "vkCmdClearAttachments")) |
| 1198 | return (PFN_vkVoidFunction) vkCmdClearAttachments; |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1199 | if (!strcmp(funcName, "vkCmdCopyImage")) |
| 1200 | return (PFN_vkVoidFunction) vkCmdCopyImage; |
| 1201 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
| 1202 | return (PFN_vkVoidFunction) vkCmdCopyImageToBuffer; |
| 1203 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
| 1204 | return (PFN_vkVoidFunction) vkCmdCopyBufferToImage; |
| 1205 | if (!strcmp(funcName, "vkCmdBlitImage")) |
| 1206 | return (PFN_vkVoidFunction) vkCmdBlitImage; |
Jeremy Hayes | 01b3889 | 2015-11-17 18:19:55 -0700 | [diff] [blame] | 1207 | if (!strcmp(funcName, "vkCmdPipelineBarrier")) |
| 1208 | return (PFN_vkVoidFunction) vkCmdPipelineBarrier; |
Mark Lobodzinski | a5eabe7 | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 1209 | if (!strcmp(funcName, "vkCmdResolveImage")) |
| 1210 | return (PFN_vkVoidFunction) vkCmdResolveImage; |
| 1211 | if (!strcmp(funcName, "vkGetImageSubresourceLayout")) |
| 1212 | return (PFN_vkVoidFunction) vkGetImageSubresourceLayout; |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1213 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1214 | if (device == NULL) { |
| 1215 | return NULL; |
| 1216 | } |
| 1217 | |
| 1218 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 1219 | |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1220 | VkLayerDispatchTable* pTable = my_data->device_dispatch_table; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1221 | { |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1222 | if (pTable->GetDeviceProcAddr == NULL) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1223 | return NULL; |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1224 | return pTable->GetDeviceProcAddr(device, funcName); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1225 | } |
| 1226 | } |
| 1227 | |
Chia-I Wu | 9ab6150 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1228 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* funcName) |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1229 | { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1230 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1231 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1232 | if (!strcmp(funcName, "vkCreateInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1233 | return (PFN_vkVoidFunction) vkCreateInstance; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1234 | if (!strcmp(funcName, "vkDestroyInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1235 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1236 | if (!strcmp(funcName, "vkCreateDevice")) |
| 1237 | return (PFN_vkVoidFunction) vkCreateDevice; |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1238 | if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) |
| 1239 | return (PFN_vkVoidFunction) vkEnumerateInstanceLayerProperties; |
| 1240 | if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) |
| 1241 | return (PFN_vkVoidFunction) vkEnumerateInstanceExtensionProperties; |
| 1242 | if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) |
| 1243 | return (PFN_vkVoidFunction) vkEnumerateDeviceLayerProperties; |
| 1244 | if (!strcmp(funcName, "vkEnumerateDeviceExtensionProperties")) |
| 1245 | return (PFN_vkVoidFunction) vkEnumerateDeviceExtensionProperties; |
Mark Lobodzinski | d5a2382 | 2015-11-12 15:14:35 -0700 | [diff] [blame] | 1246 | if (!strcmp(funcName, "vkGetPhysicalDeviceProperties")) |
| 1247 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceProperties; |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1248 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1249 | if (instance == NULL) { |
| 1250 | return NULL; |
| 1251 | } |
| 1252 | |
| 1253 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 1254 | |
Tobin Ehlis | b74f6ab | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1255 | PFN_vkVoidFunction fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1256 | if(fptr) |
| 1257 | return fptr; |
| 1258 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 1259 | VkLayerInstanceDispatchTable* pTable = my_data->instance_dispatch_table; |
| 1260 | if (pTable->GetInstanceProcAddr == NULL) |
| 1261 | return NULL; |
| 1262 | return pTable->GetInstanceProcAddr(instance, funcName); |
Jeremy Hayes | 9cc3158 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1263 | } |