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