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