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