Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Vulkan |
| 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
Courtney Goeltzenleuchter | 6ff9373 | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 25 | #include <inttypes.h> |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
Courtney Goeltzenleuchter | 6ff9373 | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 29 | #include <assert.h> |
| 30 | #include <vector> |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 31 | #include <unordered_map> |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 32 | #include <memory> |
Courtney Goeltzenleuchter | 6ff9373 | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 33 | using namespace std; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 34 | |
Tobin Ehlis | 7a51d90 | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 35 | #include "vk_loader_platform.h" |
Courtney Goeltzenleuchter | 6ff9373 | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 36 | #include "vk_dispatch_table_helper.h" |
| 37 | #include "vk_struct_string_helper_cpp.h" |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 38 | #include "vk_enum_validate_helper.h" |
Courtney Goeltzenleuchter | 6ff9373 | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 39 | #include "image.h" |
| 40 | #include "vk_layer_config.h" |
| 41 | #include "vk_layer_extension_utils.h" |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 42 | #include "vk_layer_table.h" |
| 43 | #include "vk_layer_data.h" |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 44 | #include "vk_layer_extension_utils.h" |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 45 | #include "vk_layer_utils.h" |
Courtney Goeltzenleuchter | 6ff9373 | 2015-10-07 08:38:30 -0600 | [diff] [blame] | 46 | #include "vk_layer_logging.h" |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 47 | |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 48 | using namespace std; |
| 49 | |
Cody Northrop | 73bb657 | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 50 | struct layer_data { |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 51 | debug_report_data *report_data; |
Courtney Goeltzenleuchter | 9fac157 | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 52 | std::vector<VkDbgMsgCallback> logging_callback; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 53 | VkLayerDispatchTable* device_dispatch_table; |
| 54 | VkLayerInstanceDispatchTable* instance_dispatch_table; |
Chris Forbes | d757630 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 55 | VkPhysicalDevice physicalDevice; |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 56 | unordered_map<VkImage, IMAGE_STATE> imageMap; |
Cody Northrop | 73bb657 | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 57 | |
| 58 | layer_data() : |
| 59 | report_data(nullptr), |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 60 | device_dispatch_table(nullptr), |
| 61 | instance_dispatch_table(nullptr), |
Cody Northrop | 73bb657 | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 62 | physicalDevice(0) |
| 63 | {}; |
| 64 | }; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 65 | |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 66 | static unordered_map<void*, layer_data*> layer_data_map; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 67 | |
| 68 | static void InitImage(layer_data *data) |
| 69 | { |
Courtney Goeltzenleuchter | 9fac157 | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 70 | VkDbgMsgCallback callback; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 71 | uint32_t report_flags = getLayerOptionFlags("ImageReportFlags", 0); |
| 72 | |
| 73 | uint32_t debug_action = 0; |
| 74 | getLayerOptionEnum("ImageDebugAction", (uint32_t *) &debug_action); |
| 75 | if(debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 76 | { |
| 77 | FILE *log_output = NULL; |
| 78 | const char* option_str = getLayerOption("ImageLogFilename"); |
Tobin Ehlis | b4b6e7c | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 79 | log_output = getLayerLogOutput(option_str, "Image"); |
Courtney Goeltzenleuchter | 9fac157 | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 80 | layer_create_msg_callback(data->report_data, report_flags, log_callback, (void *) log_output, &callback); |
| 81 | data->logging_callback.push_back(callback); |
| 82 | } |
| 83 | |
| 84 | if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { |
| 85 | layer_create_msg_callback(data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); |
| 86 | data->logging_callback.push_back(callback); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 87 | } |
| 88 | } |
| 89 | |
| 90 | VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 91 | VkInstance instance, |
| 92 | VkFlags msgFlags, |
| 93 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 94 | void* pUserData, |
| 95 | VkDbgMsgCallback* pMsgCallback) |
| 96 | { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 97 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 98 | VkResult res = my_data->instance_dispatch_table->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 99 | if (res == VK_SUCCESS) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 100 | res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 101 | } |
| 102 | return res; |
| 103 | } |
| 104 | |
| 105 | VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 106 | VkInstance instance, |
| 107 | VkDbgMsgCallback msgCallback) |
| 108 | { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 109 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 110 | VkResult res = my_data->instance_dispatch_table->DbgDestroyMsgCallback(instance, msgCallback); |
| 111 | layer_destroy_msg_callback(my_data->report_data, msgCallback); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 112 | return res; |
| 113 | } |
| 114 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 115 | VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocCallbacks* pAllocator, VkInstance* pInstance) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 116 | { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 117 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 118 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 119 | VkResult result = pTable->CreateInstance(pCreateInfo, pAllocator, pInstance); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 120 | |
| 121 | if (result == VK_SUCCESS) { |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 122 | my_data->report_data = debug_report_create_instance(pTable, *pInstance, pCreateInfo->enabledExtensionNameCount, |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 123 | pCreateInfo->ppEnabledExtensionNames); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 124 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 125 | InitImage(my_data); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 126 | } |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 127 | return result; |
| 128 | } |
| 129 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 130 | VK_LAYER_EXPORT void VKAPI vkDestroyInstance(VkInstance instance, const VkAllocCallbacks* pAllocator) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 131 | { |
| 132 | // Grab the key before the instance is destroyed. |
| 133 | dispatch_key key = get_dispatch_key(instance); |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 134 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 135 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 136 | pTable->DestroyInstance(instance, pAllocator); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 137 | |
| 138 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | 9fac157 | 2015-10-05 15:59:11 -0600 | [diff] [blame] | 139 | while (my_data->logging_callback.size() > 0) { |
| 140 | VkDbgMsgCallback callback = my_data->logging_callback.back(); |
| 141 | layer_destroy_msg_callback(my_data->report_data, callback); |
| 142 | my_data->logging_callback.pop_back(); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 143 | } |
| 144 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 145 | layer_debug_report_destroy_instance(my_data->report_data); |
| 146 | delete my_data->instance_dispatch_table; |
| 147 | layer_data_map.erase(key); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 148 | |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 149 | } |
| 150 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 151 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocCallbacks* pAllocator, VkDevice* pDevice) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 152 | { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 153 | layer_data *instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); |
| 154 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 155 | VkResult result = device_data->device_dispatch_table->CreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 156 | if(result == VK_SUCCESS) |
| 157 | { |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 158 | device_data->report_data = layer_debug_report_create_device(instance_data->report_data, *pDevice); |
Chris Forbes | d757630 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 159 | device_data->physicalDevice = physicalDevice; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | return result; |
| 163 | } |
| 164 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 165 | VK_LAYER_EXPORT void VKAPI vkDestroyDevice(VkDevice device, const VkAllocCallbacks* pAllocator) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 166 | { |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 167 | dispatch_key key = get_dispatch_key(device); |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 168 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 169 | my_data->device_dispatch_table->DestroyDevice(device, pAllocator); |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 170 | delete my_data->device_dispatch_table; |
| 171 | layer_data_map.erase(key); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 172 | } |
| 173 | |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 174 | static const VkLayerProperties pc_global_layers[] = { |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 175 | { |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 176 | "Image", |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 177 | VK_API_VERSION, |
| 178 | VK_MAKE_VERSION(0, 1, 0), |
| 179 | "Validation layer: Image ParamChecker", |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 180 | } |
| 181 | }; |
| 182 | |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 183 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateInstanceExtensionProperties( |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 184 | const char *pLayerName, |
| 185 | uint32_t *pCount, |
| 186 | VkExtensionProperties* pProperties) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 187 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 188 | // ParamChecker does not have any global extensions |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 189 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 190 | } |
| 191 | |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 192 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateInstanceLayerProperties( |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 193 | uint32_t *pCount, |
| 194 | VkLayerProperties* pProperties) |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 195 | { |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 196 | return util_GetLayerProperties(ARRAY_SIZE(pc_global_layers), |
| 197 | pc_global_layers, |
| 198 | pCount, pProperties); |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 199 | } |
| 200 | |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 201 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateDeviceExtensionProperties( |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 202 | VkPhysicalDevice physicalDevice, |
| 203 | const char* pLayerName, |
| 204 | uint32_t* pCount, |
| 205 | VkExtensionProperties* pProperties) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 206 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 207 | // ParamChecker does not have any physical device extensions |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 208 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
| 209 | } |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 210 | |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 211 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateDeviceLayerProperties( |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 212 | VkPhysicalDevice physicalDevice, |
| 213 | uint32_t* pCount, |
| 214 | VkLayerProperties* pProperties) |
| 215 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 216 | // ParamChecker's physical device layers are the same as global |
Courtney Goeltzenleuchter | eb1ddb0 | 2015-07-07 11:18:30 -0600 | [diff] [blame] | 217 | return util_GetLayerProperties(ARRAY_SIZE(pc_global_layers), pc_global_layers, |
| 218 | pCount, pProperties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 219 | } |
| 220 | |
Mark Lobodzinski | 9cce783 | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 221 | // Start of the Image layer proper |
| 222 | |
| 223 | // Returns TRUE if a format is a depth-compatible format |
| 224 | bool is_depth_format(VkFormat format) |
| 225 | { |
| 226 | bool result = VK_FALSE; |
| 227 | switch (format) { |
| 228 | case VK_FORMAT_D16_UNORM: |
Courtney Goeltzenleuchter | 7ed1059 | 2015-09-10 17:17:43 -0600 | [diff] [blame] | 229 | case VK_FORMAT_D24_UNORM_X8: |
Mark Lobodzinski | 9cce783 | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 230 | case VK_FORMAT_D32_SFLOAT: |
| 231 | case VK_FORMAT_S8_UINT: |
| 232 | case VK_FORMAT_D16_UNORM_S8_UINT: |
| 233 | case VK_FORMAT_D24_UNORM_S8_UINT: |
| 234 | case VK_FORMAT_D32_SFLOAT_S8_UINT: |
| 235 | result = VK_TRUE; |
| 236 | break; |
| 237 | default: |
| 238 | break; |
| 239 | } |
| 240 | return result; |
| 241 | } |
| 242 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 243 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocCallbacks* pAllocator, VkImage* pImage) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 244 | { |
Tobin Ehlis | 3561380 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 245 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 246 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 247 | if(pCreateInfo->format != VK_FORMAT_UNDEFINED) |
| 248 | { |
| 249 | VkFormatProperties properties; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 250 | get_my_data_ptr(get_dispatch_key(device_data->physicalDevice), layer_data_map)->instance_dispatch_table->GetPhysicalDeviceFormatProperties( |
Chris Forbes | d757630 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 251 | device_data->physicalDevice, pCreateInfo->format, &properties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 252 | |
| 253 | if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0)) |
| 254 | { |
| 255 | char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, contains unsupported format"; |
Tobin Ehlis | 3561380 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 256 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_FORMAT_UNSUPPORTED, "IMAGE", str); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 257 | } |
| 258 | } |
Tobin Ehlis | 3561380 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 259 | if (skipCall) |
| 260 | return VK_ERROR_VALIDATION_FAILED; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 261 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 262 | VkResult result = device_data->device_dispatch_table->CreateImage(device, pCreateInfo, pAllocator, pImage); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 263 | |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 264 | if(result == VK_SUCCESS) { |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 265 | device_data->imageMap[*pImage] = IMAGE_STATE(pCreateInfo); |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 266 | } |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 267 | return result; |
| 268 | } |
| 269 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 270 | VK_LAYER_EXPORT void VKAPI vkDestroyImage(VkDevice device, VkImage image, const VkAllocCallbacks* pAllocator) |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 271 | { |
| 272 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 273 | device_data->imageMap.erase(image); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 274 | device_data->device_dispatch_table->DestroyImage(device, image, pAllocator); |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 275 | } |
| 276 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 277 | VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocCallbacks* pAllocator, VkRenderPass* pRenderPass) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 278 | { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 279 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 3561380 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 280 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 281 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 282 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 283 | if(pCreateInfo->pAttachments[i].format != VK_FORMAT_UNDEFINED) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 284 | { |
| 285 | VkFormatProperties properties; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 286 | get_my_data_ptr(get_dispatch_key(my_data->physicalDevice), layer_data_map)->instance_dispatch_table->GetPhysicalDeviceFormatProperties( |
| 287 | my_data->physicalDevice, pCreateInfo->pAttachments[i].format, &properties); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 288 | |
| 289 | if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0)) |
| 290 | { |
| 291 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 292 | ss << "vkCreateRenderPass parameter, VkFormat in pCreateInfo->pAttachments[" << i << "], contains unsupported format"; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 293 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_FORMAT_UNSUPPORTED, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 298 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 299 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 300 | if(!validate_VkImageLayout(pCreateInfo->pAttachments[i].initialLayout) || |
| 301 | !validate_VkImageLayout(pCreateInfo->pAttachments[i].finalLayout)) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 302 | { |
| 303 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 304 | ss << "vkCreateRenderPass parameter, VkImageLayout in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 305 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_RENDERPASS_INVALID_ATTACHMENT, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 306 | } |
| 307 | } |
| 308 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 309 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 310 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 311 | if(!validate_VkAttachmentLoadOp(pCreateInfo->pAttachments[i].loadOp)) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 312 | { |
| 313 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 314 | ss << "vkCreateRenderPass parameter, VkAttachmentLoadOp in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 315 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_RENDERPASS_INVALID_ATTACHMENT, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 316 | } |
| 317 | } |
| 318 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 319 | for(uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 320 | { |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 321 | if(!validate_VkAttachmentStoreOp(pCreateInfo->pAttachments[i].storeOp)) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 322 | { |
| 323 | std::stringstream ss; |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 324 | ss << "vkCreateRenderPass parameter, VkAttachmentStoreOp in pCreateInfo->pAttachments[" << i << "], is unrecognized"; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 325 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_RENDERPASS_INVALID_ATTACHMENT, "IMAGE", ss.str().c_str()); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | |
Mark Lobodzinski | 9cce783 | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 329 | // Any depth buffers specified as attachments? |
| 330 | bool depthFormatPresent = VK_FALSE; |
| 331 | for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) |
| 332 | { |
| 333 | depthFormatPresent |= is_depth_format(pCreateInfo->pAttachments[i].format); |
| 334 | } |
| 335 | |
| 336 | if (depthFormatPresent == VK_FALSE) { |
| 337 | // No depth attachment is present, validate that subpasses set depthStencilAttachment to VK_ATTACHMENT_UNUSED; |
| 338 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { |
| 339 | if (pCreateInfo->pSubpasses[i].depthStencilAttachment.attachment != VK_ATTACHMENT_UNUSED) { |
| 340 | std::stringstream ss; |
| 341 | ss << "vkCreateRenderPass has no depth/stencil attachment, yet subpass[" << i << "] has VkSubpassDescription::depthStencilAttachment value that is not VK_ATTACHMENT_UNUSED"; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 342 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_RENDERPASS_INVALID_DS_ATTACHMENT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | 9cce783 | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 343 | } |
| 344 | } |
| 345 | } |
Tobin Ehlis | 3561380 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 346 | if (skipCall) |
| 347 | return VK_ERROR_VALIDATION_FAILED; |
Mark Lobodzinski | 9cce783 | 2015-07-29 09:21:22 -0600 | [diff] [blame] | 348 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 349 | VkResult result = my_data->device_dispatch_table->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 350 | |
| 351 | return result; |
| 352 | } |
| 353 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 354 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocCallbacks* pAllocator, VkImageView* pView) |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 355 | { |
| 356 | VkBool32 skipCall = VK_FALSE; |
| 357 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 358 | auto imageEntry = device_data->imageMap.find(pCreateInfo->image); |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 359 | if (imageEntry != device_data->imageMap.end()) { |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 360 | if (pCreateInfo->subresourceRange.baseMipLevel >= imageEntry->second.mipLevels) { |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 361 | std::stringstream ss; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 362 | ss << "vkCreateImageView called with baseMipLevel " << pCreateInfo->subresourceRange.baseMipLevel |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 363 | << " for image " << pCreateInfo->image << " that only has " << imageEntry->second.mipLevels << " mip levels."; |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 364 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_VIEW_CREATE_ERROR, "IMAGE", ss.str().c_str()); |
| 365 | } |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 366 | if (pCreateInfo->subresourceRange.baseArrayLayer >= imageEntry->second.arraySize) { |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 367 | std::stringstream ss; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 368 | ss << "vkCreateImageView called with baseArrayLayer " << pCreateInfo->subresourceRange.baseArrayLayer << " for image " |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 369 | << pCreateInfo->image << " that only has " << imageEntry->second.arraySize << " mip levels."; |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 370 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_VIEW_CREATE_ERROR, "IMAGE", ss.str().c_str()); |
| 371 | } |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 372 | if (!pCreateInfo->subresourceRange.numLevels) { |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 373 | std::stringstream ss; |
| 374 | ss << "vkCreateImageView called with 0 in pCreateInfo->subresourceRange.mipLevels."; |
| 375 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_VIEW_CREATE_ERROR, "IMAGE", ss.str().c_str()); |
| 376 | } |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 377 | if (!pCreateInfo->subresourceRange.numLayers) { |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 378 | std::stringstream ss; |
| 379 | ss << "vkCreateImageView called with 0 in pCreateInfo->subresourceRange.arraySize."; |
| 380 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, IMAGE_VIEW_CREATE_ERROR, "IMAGE", ss.str().c_str()); |
| 381 | } |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 382 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 383 | // Validate correct image aspect bits for desired formats and format consistency |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 384 | VkFormat imageFormat = imageEntry->second.format; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 385 | VkFormat ivciFormat = pCreateInfo->format; |
| 386 | VkImageAspectFlags aspectMask = pCreateInfo->subresourceRange.aspectMask; |
| 387 | |
| 388 | if (vk_format_is_color(imageFormat)) { |
| 389 | if ((aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != VK_IMAGE_ASPECT_COLOR_BIT) { |
| 390 | std::stringstream ss; |
| 391 | ss << "vkCreateImageView: Color image formats must have the VK_IMAGE_ASPECT_COLOR_BIT set"; |
| 392 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 393 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 394 | } |
| 395 | if ((aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != aspectMask) { |
| 396 | std::stringstream ss; |
| 397 | ss << "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"; |
| 398 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 399 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 400 | } |
| 401 | if (VK_FALSE == vk_format_is_color(ivciFormat)) { |
| 402 | std::stringstream ss; |
| 403 | ss << "vkCreateImageView: The image view's format can differ from the parent image's format, but both must be " |
| 404 | << "color formats. ImageFormat is " << string_VkFormat(imageFormat) << " ImageViewFormat is " << string_VkFormat(ivciFormat); |
| 405 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 406 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_FORMAT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 407 | } |
| 408 | // TODO: Uncompressed formats are compatible if they occupy they same number of bits per pixel. |
| 409 | // Compressed formats are compatible if the only difference between them is the numerical type of |
| 410 | // the uncompressed pixels (e.g. signed vs. unsigned, or sRGB vs. UNORM encoding). |
| 411 | } else if (vk_format_is_depth_and_stencil(imageFormat)) { |
| 412 | if ((aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != |
| 413 | (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 414 | std::stringstream ss; |
| 415 | ss << "vkCreateImageView: Combination depth/stencil image formats must have both VK_IMAGE_ASPECT_DEPTH_BIT and VK_IMAGE_ASPECT_STENCIL_BIT set"; |
| 416 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 417 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 418 | } |
| 419 | if ((aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != aspectMask) { |
| 420 | std::stringstream ss; |
| 421 | ss << "vkCreateImageView: Combination depth/stencil image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT and VK_IMAGE_ASPECT_STENCIL_BIT set"; |
| 422 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 423 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 424 | } |
| 425 | } else if (vk_format_is_depth_only(imageFormat)) { |
| 426 | if ((aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) { |
| 427 | std::stringstream ss; |
| 428 | ss << "vkCreateImageView: Depth-only image formats must have the VK_IMAGE_ASPECT_DEPTH_BIT set"; |
| 429 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 430 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 431 | } |
| 432 | if ((aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != aspectMask) { |
| 433 | std::stringstream ss; |
| 434 | ss << "vkCreateImageView: Depth-only image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT set"; |
| 435 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 436 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 437 | } |
| 438 | } else if (vk_format_is_stencil_only(imageFormat)) { |
| 439 | if ((aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT) { |
| 440 | std::stringstream ss; |
| 441 | ss << "vkCreateImageView: Stencil-only image formats must have the VK_IMAGE_ASPECT_STENCIL_BIT set"; |
| 442 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 443 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 444 | } |
| 445 | if ((aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != aspectMask) { |
| 446 | std::stringstream ss; |
| 447 | ss << "vkCreateImageView: Stencil-only image formats can have only the VK_IMAGE_ASPECT_STENCIL_BIT set"; |
| 448 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 449 | (uint64_t)pCreateInfo->image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | } |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 453 | |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 454 | if (skipCall) |
| 455 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 3561380 | 2015-09-22 08:40:52 -0600 | [diff] [blame] | 456 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame^] | 457 | VkResult result = device_data->device_dispatch_table->CreateImageView(device, pCreateInfo, pAllocator, pView); |
Tobin Ehlis | 6538053 | 2015-09-21 15:20:28 -0600 | [diff] [blame] | 458 | return result; |
| 459 | } |
| 460 | |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 461 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage( |
| 462 | VkCmdBuffer cmdBuffer, |
| 463 | VkImage image, |
| 464 | VkImageLayout imageLayout, |
| 465 | const VkClearColorValue *pColor, |
| 466 | uint32_t rangeCount, |
| 467 | const VkImageSubresourceRange *pRanges) |
| 468 | { |
| 469 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 470 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 471 | // For each range, image aspect must be color only |
| 472 | for (uint32_t i = 0; i < rangeCount; i++) { |
| 473 | if (pRanges[i].aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 474 | char const str[] = "vkCmdClearColorImage aspectMasks for all subresource ranges must be set to VK_IMAGE_ASPECT_COLOR_BIT"; |
| 475 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 476 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 481 | device_data->device_dispatch_table->CmdClearColorImage(cmdBuffer, image, imageLayout, |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 482 | pColor, rangeCount, pRanges); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencilImage( |
| 487 | VkCmdBuffer cmdBuffer, |
| 488 | VkImage image, |
| 489 | VkImageLayout imageLayout, |
| 490 | const VkClearDepthStencilValue *pDepthStencil, |
| 491 | uint32_t rangeCount, |
| 492 | const VkImageSubresourceRange *pRanges) |
| 493 | { |
| 494 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 495 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 496 | // For each range, Image aspect must be depth or stencil or both |
| 497 | for (uint32_t i = 0; i < rangeCount; i++) { |
| 498 | if (((pRanges[i].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 499 | ((pRanges[i].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) |
| 500 | { |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 501 | char const str[] = "vkCmdClearDepthStencilImage aspectMasks for all subresource ranges must be " |
| 502 | "set to VK_IMAGE_ASPECT_DEPTH_BIT and/or VK_IMAGE_ASPECT_STENCIL_BIT"; |
| 503 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 504 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 509 | device_data->device_dispatch_table->CmdClearDepthStencilImage(cmdBuffer, |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 510 | image, imageLayout, pDepthStencil, rangeCount, pRanges); |
| 511 | } |
| 512 | } |
| 513 | |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 514 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage( |
| 515 | VkCmdBuffer cmdBuffer, |
| 516 | VkImage srcImage, |
| 517 | VkImageLayout srcImageLayout, |
| 518 | VkImage destImage, |
| 519 | VkImageLayout destImageLayout, |
| 520 | uint32_t regionCount, |
| 521 | const VkImageCopy *pRegions) |
| 522 | { |
| 523 | VkBool32 skipCall = VK_FALSE; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 524 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 525 | auto srcImageEntry = device_data->imageMap.find(srcImage); |
| 526 | auto destImageEntry = device_data->imageMap.find(destImage); |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 527 | |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 528 | // For each region, src and dst number of layers should not be zero |
| 529 | // For each region, src and dst number of layers must match |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 530 | // For each region, src aspect mask must match dest aspect mask |
| 531 | // For each region, color aspects cannot be mixed with depth/stencil aspects |
| 532 | for (uint32_t i = 0; i < regionCount; i++) { |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 533 | if(pRegions[i].srcSubresource.numLayers == 0) |
| 534 | { |
| 535 | char const str[] = "vkCmdCopyImage: number of layers in source subresource is zero"; |
| 536 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 537 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 538 | } |
| 539 | |
| 540 | if(pRegions[i].destSubresource.numLayers == 0) |
| 541 | { |
| 542 | char const str[] = "vkCmdCopyImage: number of layers in destination subresource is zero"; |
| 543 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 544 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 545 | } |
| 546 | |
| 547 | if(pRegions[i].srcSubresource.numLayers != pRegions[i].destSubresource.numLayers) |
| 548 | { |
| 549 | char const str[] = "vkCmdCopyImage: number of layers in source and destination subresources must match"; |
| 550 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 551 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 552 | } |
| 553 | |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 554 | if (pRegions[i].srcSubresource.aspect != pRegions[i].destSubresource.aspect) { |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 555 | char const str[] = "vkCmdCopyImage: Src and dest aspectMasks for each region must match"; |
| 556 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 557 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 558 | } |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 559 | if ((pRegions[i].srcSubresource.aspect & VK_IMAGE_ASPECT_COLOR_BIT) && |
| 560 | (pRegions[i].srcSubresource.aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))) { |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 561 | char const str[] = "vkCmdCopyImage aspectMask cannot specify both COLOR and DEPTH/STENCIL aspects"; |
| 562 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 563 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
| 564 | } |
| 565 | } |
| 566 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 567 | if ((srcImageEntry != device_data->imageMap.end()) |
| 568 | && (destImageEntry != device_data->imageMap.end())) { |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 569 | if (srcImageEntry->second.imageType != destImageEntry->second.imageType) { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 570 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image types."; |
| 571 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 572 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_TYPE, "IMAGE", str); |
| 573 | } |
| 574 | // Check that format is same size or exact stencil/depth |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 575 | if (is_depth_format(srcImageEntry->second.format)) { |
| 576 | if (srcImageEntry->second.format != destImageEntry->second.format) { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 577 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image depth/stencil formats."; |
| 578 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 579 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); |
| 580 | } |
| 581 | } else { |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 582 | size_t srcSize = vk_format_get_size(srcImageEntry->second.format); |
| 583 | size_t destSize = vk_format_get_size(destImageEntry->second.format); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 584 | if (srcSize != destSize) { |
| 585 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image format sizes."; |
| 586 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 587 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 592 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 593 | device_data->device_dispatch_table->CmdCopyImage(cmdBuffer, srcImage, |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 594 | srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
| 595 | } |
| 596 | } |
| 597 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 598 | void VKAPI vkCmdClearAttachments( |
| 599 | VkCmdBuffer cmdBuffer, |
| 600 | uint32_t attachmentCount, |
| 601 | const VkClearAttachment* pAttachments, |
| 602 | uint32_t rectCount, |
Courtney Goeltzenleuchter | a12e291 | 2015-10-15 18:22:08 -0600 | [diff] [blame] | 603 | const VkClearRect* pRects) |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 604 | { |
| 605 | VkBool32 skipCall = VK_FALSE; |
| 606 | VkImageAspectFlags aspectMask; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 607 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 608 | for (uint32_t i = 0; i < attachmentCount; i++) { |
| 609 | aspectMask = pAttachments[i].aspectMask; |
| 610 | if (aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { |
| 611 | if (aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { |
| 612 | // VK_IMAGE_ASPECT_COLOR_BIT is not the only bit set for this attachment |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 613 | char const str[] = "vkCmdClearAttachments aspectMask [%d] must set only VK_IMAGE_ASPECT_COLOR_BIT of a color attachment."; |
| 614 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 615 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str, i); |
| 616 | } |
| 617 | } else { |
| 618 | // Image aspect must be depth or stencil or both |
| 619 | if (((aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 620 | ((aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) |
| 621 | { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 622 | char const str[] = "vkCmdClearAttachments aspectMask [%d] must be set to VK_IMAGE_ASPECT_DEPTH_BIT and/or VK_IMAGE_ASPECT_STENCIL_BIT"; |
| 623 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 624 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str, i); |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 630 | device_data->device_dispatch_table->CmdClearAttachments(cmdBuffer, |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 631 | attachmentCount, pAttachments, rectCount, pRects); |
| 632 | } |
| 633 | } |
| 634 | |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 635 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer( |
| 636 | VkCmdBuffer cmdBuffer, |
| 637 | VkImage srcImage, |
| 638 | VkImageLayout srcImageLayout, |
| 639 | VkBuffer destBuffer, |
| 640 | uint32_t regionCount, |
| 641 | const VkBufferImageCopy *pRegions) |
| 642 | { |
| 643 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 644 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 645 | // For each region, the number of layers in the image subresource should not be zero |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 646 | // Image aspect must be ONE OF color, depth, stencil |
| 647 | for (uint32_t i = 0; i < regionCount; i++) { |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 648 | if(pRegions[i].imageSubresource.numLayers == 0) |
| 649 | { |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 650 | char const str[] = "vkCmdCopyImageToBuffer: number of layers in image subresource is zero"; |
| 651 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 652 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 653 | } |
| 654 | |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 655 | VkImageAspectFlags aspect = pRegions[i].imageSubresource.aspect; |
| 656 | if ((aspect != VK_IMAGE_ASPECT_COLOR_BIT) && |
| 657 | (aspect != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 658 | (aspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 659 | char const str[] = "vkCmdCopyImageToBuffer: aspectMasks for each region must specify only COLOR or DEPTH or STENCIL"; |
| 660 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 661 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 666 | device_data->device_dispatch_table->CmdCopyImageToBuffer(cmdBuffer, |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 667 | srcImage, srcImageLayout, destBuffer, regionCount, pRegions); |
| 668 | } |
| 669 | } |
| 670 | |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 671 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage( |
| 672 | VkCmdBuffer cmdBuffer, |
| 673 | VkBuffer srcBuffer, |
| 674 | VkImage destImage, |
| 675 | VkImageLayout destImageLayout, |
| 676 | uint32_t regionCount, |
| 677 | const VkBufferImageCopy *pRegions) |
| 678 | { |
| 679 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 680 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 681 | // For each region, the number of layers in the image subresource should not be zero |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 682 | // Image aspect must be ONE OF color, depth, stencil |
| 683 | for (uint32_t i = 0; i < regionCount; i++) { |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 684 | if(pRegions[i].imageSubresource.numLayers == 0) |
| 685 | { |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 686 | char const str[] = "vkCmdCopyBufferToImage: number of layers in image subresource is zero"; |
| 687 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 688 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 689 | } |
| 690 | |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 691 | VkImageAspectFlags aspect = pRegions[i].imageSubresource.aspect; |
| 692 | if ((aspect != VK_IMAGE_ASPECT_COLOR_BIT) && |
| 693 | (aspect != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 694 | (aspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 695 | char const str[] = "vkCmdCopyBufferToImage: aspectMasks for each region must specify only COLOR or DEPTH or STENCIL"; |
| 696 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 697 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 702 | device_data->device_dispatch_table->CmdCopyBufferToImage(cmdBuffer, |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 703 | srcBuffer, destImage, destImageLayout, regionCount, pRegions); |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage( |
| 708 | VkCmdBuffer cmdBuffer, |
| 709 | VkImage srcImage, |
| 710 | VkImageLayout srcImageLayout, |
| 711 | VkImage destImage, |
| 712 | VkImageLayout destImageLayout, |
| 713 | uint32_t regionCount, |
| 714 | const VkImageBlit *pRegions, |
| 715 | VkTexFilter filter) |
| 716 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 717 | VkBool32 skipCall = VK_FALSE; |
| 718 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
| 719 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 720 | auto srcImageEntry = device_data->imageMap.find(srcImage); |
| 721 | auto destImageEntry = device_data->imageMap.find(destImage); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 722 | |
| 723 | if ((srcImageEntry != device_data->imageMap.end()) && |
| 724 | (destImageEntry != device_data->imageMap.end())) { |
| 725 | |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 726 | VkFormat srcFormat = srcImageEntry->second.format; |
| 727 | VkFormat dstFormat = destImageEntry->second.format; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 728 | |
| 729 | // Validate consistency for signed and unsigned formats |
| 730 | if ((vk_format_is_sint(srcFormat) && !vk_format_is_sint(dstFormat)) || |
| 731 | (vk_format_is_uint(srcFormat) && !vk_format_is_uint(dstFormat))) { |
| 732 | std::stringstream ss; |
| 733 | ss << "vkCmdBlitImage: If one of srcImage and destImage images has signed/unsigned integer format, " |
| 734 | << "the other one must also have signed/unsigned integer format. " |
| 735 | << "Source format is " << string_VkFormat(srcFormat) << " Destinatino format is " << string_VkFormat(dstFormat); |
| 736 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 737 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_FORMAT, "IMAGE", ss.str().c_str()); |
| 738 | } |
| 739 | |
| 740 | // Validate aspect bits and formats for depth/stencil images |
| 741 | if (vk_format_is_depth_or_stencil(srcFormat) || |
| 742 | vk_format_is_depth_or_stencil(dstFormat)) { |
| 743 | if (srcFormat != dstFormat) { |
| 744 | std::stringstream ss; |
| 745 | ss << "vkCmdBlitImage: If one of srcImage and destImage images has a format of depth, stencil or depth " |
| 746 | << "stencil, the other one must have exactly the same format. " |
| 747 | << "Source format is " << string_VkFormat(srcFormat) << " Destinatino format is " << string_VkFormat(dstFormat); |
| 748 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 749 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_FORMAT, "IMAGE", ss.str().c_str()); |
| 750 | } |
| 751 | |
| 752 | for (uint32_t i = 0; i < regionCount; i++) { |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 753 | if(pRegions[i].srcSubresource.numLayers == 0) |
| 754 | { |
| 755 | char const str[] = "vkCmdBlitImage: number of layers in source subresource is zero"; |
| 756 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 757 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 758 | } |
| 759 | |
| 760 | if(pRegions[i].destSubresource.numLayers == 0) |
| 761 | { |
| 762 | char const str[] = "vkCmdBlitImage: number of layers in destination subresource is zero"; |
| 763 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 764 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 765 | } |
| 766 | |
| 767 | if(pRegions[i].srcSubresource.numLayers != pRegions[i].destSubresource.numLayers) |
| 768 | { |
| 769 | char const str[] = "vkCmdBlitImage: number of layers in source and destination subresources must match"; |
| 770 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 771 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 772 | } |
| 773 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 774 | VkImageAspectFlags srcAspect = pRegions[i].srcSubresource.aspect; |
| 775 | VkImageAspectFlags dstAspect = pRegions[i].destSubresource.aspect; |
| 776 | |
| 777 | if (srcAspect != dstAspect) { |
| 778 | std::stringstream ss; |
| 779 | ss << "vkCmdBlitImage: Image aspects of depth/stencil images should match"; |
| 780 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 781 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
| 782 | } |
| 783 | if (vk_format_is_depth_and_stencil(srcFormat)) { |
| 784 | if (srcAspect != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 785 | std::stringstream ss; |
| 786 | ss << "vkCmdBlitImage: Combination depth/stencil image formats must have both VK_IMAGE_ASPECT_DEPTH_BIT " |
| 787 | << "and VK_IMAGE_ASPECT_STENCIL_BIT set in both the srcImage and destImage"; |
| 788 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 789 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
| 790 | } |
| 791 | } else if (vk_format_is_stencil_only(srcFormat)) { |
| 792 | if (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT) { |
| 793 | std::stringstream ss; |
| 794 | ss << "vkCmdBlitImage: Stencil-only image formats must have only the VK_IMAGE_ASPECT_STENCIL_BIT " |
| 795 | << "set in both the srcImage and destImage"; |
| 796 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 797 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
| 798 | } |
| 799 | } else if (vk_format_is_depth_only(srcFormat)) { |
| 800 | if (srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) { |
| 801 | std::stringstream ss; |
| 802 | ss << "vkCmdBlitImage: Depth-only image formats must have only the VK_IMAGE_ASPECT_DEPTH " |
| 803 | << "set in both the srcImage and destImage"; |
| 804 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 805 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
| 806 | } |
| 807 | } |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | // Validate filter |
| 812 | if (vk_format_is_depth_or_stencil(srcFormat) || |
| 813 | vk_format_is_int(srcFormat)) { |
| 814 | if (filter != VK_TEX_FILTER_NEAREST) { |
| 815 | std::stringstream ss; |
| 816 | ss << "vkCmdBlitImage: If the format of srcImage is a depth, stencil, depth stencil or integer-based format " |
| 817 | << "then filter must be VK_TEX_FILTER_NEAREST."; |
| 818 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 819 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_FILTER, "IMAGE", ss.str().c_str()); |
| 820 | } |
| 821 | } |
| 822 | } |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 823 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 824 | device_data->device_dispatch_table->CmdBlitImage(cmdBuffer, srcImage, |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 825 | srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter); |
| 826 | } |
| 827 | |
| 828 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage( |
| 829 | VkCmdBuffer cmdBuffer, |
| 830 | VkImage srcImage, |
| 831 | VkImageLayout srcImageLayout, |
| 832 | VkImage destImage, |
| 833 | VkImageLayout destImageLayout, |
| 834 | uint32_t regionCount, |
| 835 | const VkImageResolve *pRegions) |
| 836 | { |
| 837 | VkBool32 skipCall = VK_FALSE; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 838 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 839 | auto srcImageEntry = device_data->imageMap.find(srcImage); |
| 840 | auto destImageEntry = device_data->imageMap.find(destImage); |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 841 | |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 842 | // For each region, the number of layers in the image subresource should not be zero |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 843 | // For each region, src and dest image aspect must be color only |
| 844 | for (uint32_t i = 0; i < regionCount; i++) { |
Jeremy Hayes | ac8ed0b | 2015-10-28 13:01:39 -0600 | [diff] [blame] | 845 | if(pRegions[i].srcSubresource.numLayers == 0) |
| 846 | { |
| 847 | char const str[] = "vkCmdResolveImage: number of layers in source subresource is zero"; |
| 848 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 849 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 850 | } |
| 851 | |
| 852 | if(pRegions[i].destSubresource.numLayers == 0) |
| 853 | { |
| 854 | char const str[] = "vkCmdResolveImage: number of layers in destination subresource is zero"; |
| 855 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 856 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); |
| 857 | } |
| 858 | |
Courtney Goeltzenleuchter | ba11ebe | 2015-10-21 17:00:51 -0600 | [diff] [blame] | 859 | if ((pRegions[i].srcSubresource.aspect != VK_IMAGE_ASPECT_COLOR_BIT) || |
| 860 | (pRegions[i].destSubresource.aspect != VK_IMAGE_ASPECT_COLOR_BIT)) { |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 861 | char const str[] = "vkCmdResolveImage: src and dest aspectMasks for each region must specify only VK_IMAGE_ASPECT_COLOR_BIT"; |
| 862 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 863 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); |
| 864 | } |
| 865 | } |
| 866 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 867 | if ((srcImageEntry != device_data->imageMap.end()) && |
| 868 | (destImageEntry != device_data->imageMap.end())) { |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 869 | if (srcImageEntry->second.format != destImageEntry->second.format) { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 870 | char const str[] = "vkCmdResolveImage called with unmatched source and dest formats."; |
| 871 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 872 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); |
| 873 | } |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 874 | if (srcImageEntry->second.imageType != destImageEntry->second.imageType) { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 875 | char const str[] = "vkCmdResolveImage called with unmatched source and dest image types."; |
| 876 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 877 | (uint64_t)cmdBuffer, 0, IMAGE_MISMATCHED_IMAGE_TYPE, "IMAGE", str); |
| 878 | } |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 879 | if (srcImageEntry->second.samples <= 1) { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 880 | char const str[] = "vkCmdResolveImage called with source sample count less than 2."; |
| 881 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 882 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_RESOLVE_SAMPLES, "IMAGE", str); |
| 883 | } |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 884 | if (destImageEntry->second.samples > 1) { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 885 | char const str[] = "vkCmdResolveImage called with dest sample count greater than 1."; |
| 886 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
| 887 | (uint64_t)cmdBuffer, 0, IMAGE_INVALID_RESOLVE_SAMPLES, "IMAGE", str); |
| 888 | } |
| 889 | } |
| 890 | |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 891 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 892 | device_data->device_dispatch_table->CmdResolveImage(cmdBuffer, srcImage, |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 893 | srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
| 894 | } |
| 895 | } |
| 896 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 897 | VK_LAYER_EXPORT void VKAPI vkGetImageSubresourceLayout( |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 898 | VkDevice device, |
| 899 | VkImage image, |
| 900 | const VkImageSubresource *pSubresource, |
| 901 | VkSubresourceLayout *pLayout) |
| 902 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 903 | VkBool32 skipCall = VK_FALSE; |
| 904 | layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 905 | VkFormat format; |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 906 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 907 | auto imageEntry = device_data->imageMap.find(image); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 908 | |
| 909 | // Validate that image aspects match formats |
| 910 | if (imageEntry != device_data->imageMap.end()) { |
Tobin Ehlis | 6fa437d | 2015-09-25 14:49:43 -0600 | [diff] [blame] | 911 | format = imageEntry->second.format; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 912 | if (vk_format_is_color(format)) { |
| 913 | if (pSubresource->aspect != VK_IMAGE_ASPECT_COLOR_BIT) { |
| 914 | std::stringstream ss; |
| 915 | ss << "vkGetImageSubresourceLayout: For color formats, the aspect field of VkImageSubresource must be VK_IMAGE_ASPECT_COLOR."; |
| 916 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 917 | (uint64_t)image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 918 | } |
| 919 | } else if (vk_format_is_depth_or_stencil(format)) { |
| 920 | if ((pSubresource->aspect != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 921 | (pSubresource->aspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 922 | std::stringstream ss; |
| 923 | ss << "vkGetImageSubresourceLayout: For depth/stencil formats, the aspect selects either the depth or stencil image aspect."; |
| 924 | skipCall |= log_msg(device_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 925 | (uint64_t)image, 0, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", ss.str().c_str()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 926 | } |
| 927 | } |
| 928 | } |
| 929 | |
| 930 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 931 | device_data->device_dispatch_table->GetImageSubresourceLayout(device, |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 932 | image, pSubresource, pLayout); |
| 933 | } |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 934 | } |
| 935 | |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 936 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, const char* funcName) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 937 | { |
| 938 | if (device == NULL) { |
| 939 | return NULL; |
| 940 | } |
| 941 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 942 | layer_data *my_data; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 943 | // loader uses this to force layer initialization; device object is wrapped |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 944 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 945 | VkBaseLayerObject* wrapped_dev = (VkBaseLayerObject*) device; |
| 946 | my_data = get_my_data_ptr(get_dispatch_key(wrapped_dev->baseObject), layer_data_map); |
| 947 | my_data->device_dispatch_table = new VkLayerDispatchTable; |
| 948 | layer_initialize_dispatch_table(my_data->device_dispatch_table, wrapped_dev); |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 949 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 950 | } |
| 951 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 952 | my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Courtney Goeltzenleuchter | be63799 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 953 | if (!strcmp(funcName, "vkCreateDevice")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 954 | return (PFN_vkVoidFunction) vkCreateDevice; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 955 | if (!strcmp(funcName, "vkDestroyDevice")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 956 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 957 | if (!strcmp(funcName, "vkCreateImage")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 958 | return (PFN_vkVoidFunction) vkCreateImage; |
Mark Lobodzinski | 9eb1ce4 | 2015-10-29 12:58:33 -0600 | [diff] [blame] | 959 | if (!strcmp(funcName, "vkDestroyImage")) |
| 960 | return (PFN_vkVoidFunction) vkDestroyImage; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 961 | if (!strcmp(funcName, "vkCreateImageView")) |
| 962 | return (PFN_vkVoidFunction) vkCreateImageView; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 963 | if (!strcmp(funcName, "vkCreateRenderPass")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 964 | return (PFN_vkVoidFunction) vkCreateRenderPass; |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 965 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
| 966 | return (PFN_vkVoidFunction) vkCmdClearColorImage; |
| 967 | if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) |
| 968 | return (PFN_vkVoidFunction) vkCmdClearDepthStencilImage; |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 969 | if (!strcmp(funcName, "vkCmdClearAttachments")) |
| 970 | return (PFN_vkVoidFunction) vkCmdClearAttachments; |
Mark Lobodzinski | 6f3403c | 2015-10-05 17:16:05 -0600 | [diff] [blame] | 971 | if (!strcmp(funcName, "vkCmdCopyImage")) |
| 972 | return (PFN_vkVoidFunction) vkCmdCopyImage; |
| 973 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
| 974 | return (PFN_vkVoidFunction) vkCmdCopyImageToBuffer; |
| 975 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
| 976 | return (PFN_vkVoidFunction) vkCmdCopyBufferToImage; |
| 977 | if (!strcmp(funcName, "vkCmdBlitImage")) |
| 978 | return (PFN_vkVoidFunction) vkCmdBlitImage; |
| 979 | if (!strcmp(funcName, "vkCmdResolveImage")) |
| 980 | return (PFN_vkVoidFunction) vkCmdResolveImage; |
| 981 | if (!strcmp(funcName, "vkGetImageSubresourceLayout")) |
| 982 | return (PFN_vkVoidFunction) vkGetImageSubresourceLayout; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 983 | |
| 984 | VkLayerDispatchTable* pTable = my_data->device_dispatch_table; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 985 | { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 986 | if (pTable->GetDeviceProcAddr == NULL) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 987 | return NULL; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 988 | return pTable->GetDeviceProcAddr(device, funcName); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 989 | } |
| 990 | } |
| 991 | |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 992 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance, const char* funcName) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 993 | { |
| 994 | if (instance == NULL) { |
| 995 | return NULL; |
| 996 | } |
| 997 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 998 | layer_data *my_data; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 999 | // loader uses this to force layer initialization; instance object is wrapped |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1000 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1001 | VkBaseLayerObject* wrapped_inst = (VkBaseLayerObject*) instance; |
| 1002 | my_data = get_my_data_ptr(get_dispatch_key(wrapped_inst->baseObject), layer_data_map); |
| 1003 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
| 1004 | layer_init_instance_dispatch_table(my_data->instance_dispatch_table, wrapped_inst); |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1005 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1006 | } |
| 1007 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1008 | my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1009 | if (!strcmp(funcName, "vkCreateInstance")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1010 | return (PFN_vkVoidFunction) vkCreateInstance; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1011 | if (!strcmp(funcName, "vkDestroyInstance")) |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 1012 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1013 | if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) |
| 1014 | return (PFN_vkVoidFunction) vkEnumerateInstanceLayerProperties; |
| 1015 | if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) |
| 1016 | return (PFN_vkVoidFunction) vkEnumerateInstanceExtensionProperties; |
| 1017 | if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) |
| 1018 | return (PFN_vkVoidFunction) vkEnumerateDeviceLayerProperties; |
| 1019 | if (!strcmp(funcName, "vkEnumerateDeviceExtensionProperties")) |
| 1020 | return (PFN_vkVoidFunction) vkEnumerateDeviceExtensionProperties; |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1021 | |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1022 | PFN_vkVoidFunction fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1023 | if(fptr) |
| 1024 | return fptr; |
| 1025 | |
| 1026 | { |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1027 | VkLayerInstanceDispatchTable* pTable = my_data->instance_dispatch_table; |
| 1028 | if (pTable->GetInstanceProcAddr == NULL) |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1029 | return NULL; |
Tobin Ehlis | 049f178 | 2015-10-29 14:19:18 -0600 | [diff] [blame] | 1030 | return pTable->GetInstanceProcAddr(instance, funcName); |
Jeremy Hayes | b707aa5 | 2015-06-18 10:12:39 -0600 | [diff] [blame] | 1031 | } |
| 1032 | } |