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