Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2017 Valve Corporation |
| 3 | * Copyright (c) 2015-2017 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2017 Google Inc. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | * Author: Mark Lobodzinski <mark@LunarG.com> |
| 19 | */ |
| 20 | |
| 21 | #define NOMINMAX |
| 22 | |
| 23 | #include <limits.h> |
| 24 | #include <math.h> |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 28 | |
| 29 | #include <iostream> |
| 30 | #include <string> |
| 31 | #include <sstream> |
| 32 | #include <unordered_map> |
| 33 | #include <unordered_set> |
| 34 | #include <vector> |
| 35 | #include <mutex> |
| 36 | |
| 37 | #include "vk_loader_platform.h" |
| 38 | #include "vulkan/vk_layer.h" |
| 39 | #include "vk_layer_config.h" |
| 40 | #include "vk_dispatch_table_helper.h" |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 41 | #include "vk_typemap_helper.h" |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 42 | |
| 43 | #include "vk_layer_table.h" |
| 44 | #include "vk_layer_data.h" |
| 45 | #include "vk_layer_logging.h" |
| 46 | #include "vk_layer_extension_utils.h" |
| 47 | #include "vk_layer_utils.h" |
| 48 | |
| 49 | #include "parameter_name.h" |
| 50 | #include "parameter_validation.h" |
| 51 | |
Mark Lobodzinski | bfb7ab9 | 2017-10-27 13:22:23 -0600 | [diff] [blame] | 52 | #if defined __ANDROID__ |
| 53 | #include <android/log.h> |
| 54 | #define LOGCONSOLE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "DS", __VA_ARGS__)) |
| 55 | #else |
| 56 | #define LOGCONSOLE(...) \ |
| 57 | { \ |
| 58 | printf(__VA_ARGS__); \ |
| 59 | printf("\n"); \ |
| 60 | } |
| 61 | #endif |
| 62 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 63 | namespace parameter_validation { |
| 64 | |
Mark Lobodzinski | 78a12a9 | 2017-08-08 14:16:51 -0600 | [diff] [blame] | 65 | extern std::unordered_map<std::string, void *> custom_functions; |
| 66 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 67 | extern bool parameter_validation_vkCreateInstance(VkInstance instance, const VkInstanceCreateInfo *pCreateInfo, |
| 68 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance); |
| 69 | extern bool parameter_validation_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator); |
| 70 | extern bool parameter_validation_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 71 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice); |
| 72 | extern bool parameter_validation_vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator); |
| 73 | extern bool parameter_validation_vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
| 74 | const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool); |
| 75 | extern bool parameter_validation_vkCreateDebugReportCallbackEXT(VkInstance instance, |
| 76 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 77 | const VkAllocationCallbacks *pAllocator, |
| 78 | VkDebugReportCallbackEXT *pMsgCallback); |
| 79 | extern bool parameter_validation_vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 80 | const VkAllocationCallbacks *pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 81 | extern bool parameter_validation_vkCreateDebugUtilsMessengerEXT(VkInstance instance, |
| 82 | const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 83 | const VkAllocationCallbacks *pAllocator, |
| 84 | VkDebugUtilsMessengerEXT *pMessenger); |
| 85 | extern bool parameter_validation_vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 86 | const VkAllocationCallbacks *pAllocator); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 87 | extern bool parameter_validation_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, |
| 88 | const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 89 | extern bool parameter_validation_vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
| 90 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass); |
| 91 | extern bool parameter_validation_vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 92 | const VkAllocationCallbacks *pAllocator); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 93 | |
| 94 | // TODO : This can be much smarter, using separate locks for separate global data |
| 95 | std::mutex global_lock; |
| 96 | |
| 97 | static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 98 | std::unordered_map<void *, layer_data *> layer_data_map; |
| 99 | std::unordered_map<void *, instance_layer_data *> instance_layer_data_map; |
| 100 | |
| 101 | void InitializeManualParameterValidationFunctionPointers(void); |
| 102 | |
| 103 | static void init_parameter_validation(instance_layer_data *instance_data, const VkAllocationCallbacks *pAllocator) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 104 | layer_debug_report_actions(instance_data->report_data, instance_data->logging_callback, pAllocator, |
| 105 | "lunarg_parameter_validation"); |
| 106 | layer_debug_messenger_actions(instance_data->report_data, instance_data->logging_messenger, pAllocator, |
| 107 | "lunarg_parameter_validation"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 108 | } |
| 109 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 110 | static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}, |
| 111 | {VK_EXT_DEBUG_UTILS_EXTENSION_NAME, VK_EXT_DEBUG_UTILS_SPEC_VERSION}}; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 112 | |
| 113 | static const VkLayerProperties global_layer = { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 114 | "VK_LAYER_LUNARG_parameter_validation", |
| 115 | VK_LAYER_API_VERSION, |
| 116 | 1, |
| 117 | "LunarG Validation Layer", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | static const int MaxParamCheckerStringLength = 256; |
| 121 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 122 | template <typename T> |
| 123 | static inline bool in_inclusive_range(const T &value, const T &min, const T &max) { |
| 124 | // Using only < for generality and || for early abort |
| 125 | return !((value < min) || (max < value)); |
| 126 | } |
| 127 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 128 | static bool validate_string(debug_report_data *report_data, const char *apiName, const ParameterName &stringName, |
| 129 | const char *validateString) { |
| 130 | assert(apiName != nullptr); |
| 131 | assert(validateString != nullptr); |
| 132 | |
| 133 | bool skip = false; |
| 134 | |
| 135 | VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString); |
| 136 | |
| 137 | if (result == VK_STRING_ERROR_NONE) { |
| 138 | return skip; |
| 139 | } else if (result & VK_STRING_ERROR_LENGTH) { |
| 140 | skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 141 | INVALID_USAGE, LayerName, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), |
| 142 | MaxParamCheckerStringLength); |
| 143 | } else if (result & VK_STRING_ERROR_BAD_DATA) { |
| 144 | skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 145 | INVALID_USAGE, LayerName, "%s: string %s contains invalid characters or is badly formed", apiName, |
| 146 | stringName.get_name().c_str()); |
| 147 | } |
| 148 | return skip; |
| 149 | } |
| 150 | |
| 151 | static bool ValidateDeviceQueueFamily(layer_data *device_data, uint32_t queue_family, const char *cmd_name, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 152 | const char *parameter_name, int32_t error_code, bool optional = false) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 153 | bool skip = false; |
| 154 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 155 | if (!optional && queue_family == VK_QUEUE_FAMILY_IGNORED) { |
| 156 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 157 | HandleToUint64(device_data->device), __LINE__, error_code, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 158 | "%s: %s is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value.", |
| 159 | cmd_name, parameter_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 160 | } else if (device_data->queueFamilyIndexMap.find(queue_family) == device_data->queueFamilyIndexMap.end()) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 161 | skip |= |
| 162 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 163 | HandleToUint64(device_data->device), __LINE__, error_code, LayerName, |
| 164 | "%s: %s (= %" PRIu32 |
| 165 | ") is not one of the queue families given via VkDeviceQueueCreateInfo structures when the device was created.", |
| 166 | cmd_name, parameter_name, queue_family); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | return skip; |
| 170 | } |
| 171 | |
| 172 | static bool ValidateQueueFamilies(layer_data *device_data, uint32_t queue_family_count, const uint32_t *queue_families, |
| 173 | const char *cmd_name, const char *array_parameter_name, int32_t unique_error_code, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 174 | int32_t valid_error_code, bool optional = false) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 175 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 176 | if (queue_families) { |
| 177 | std::unordered_set<uint32_t> set; |
| 178 | for (uint32_t i = 0; i < queue_family_count; ++i) { |
| 179 | std::string parameter_name = std::string(array_parameter_name) + "[" + std::to_string(i) + "]"; |
| 180 | |
| 181 | if (set.count(queue_families[i])) { |
| 182 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 183 | HandleToUint64(device_data->device), __LINE__, VALIDATION_ERROR_056002e8, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 184 | "%s: %s (=%" PRIu32 ") is not unique within %s array.", cmd_name, parameter_name.c_str(), |
| 185 | queue_families[i], array_parameter_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 186 | } else { |
| 187 | set.insert(queue_families[i]); |
| 188 | skip |= ValidateDeviceQueueFamily(device_data, queue_families[i], cmd_name, parameter_name.c_str(), |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 189 | valid_error_code, optional); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | } |
| 193 | return skip; |
| 194 | } |
| 195 | |
| 196 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 197 | VkInstance *pInstance) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 198 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 199 | |
| 200 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 201 | assert(chain_info != nullptr); |
| 202 | assert(chain_info->u.pLayerInfo != nullptr); |
| 203 | |
| 204 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 205 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
| 206 | if (fpCreateInstance == NULL) { |
| 207 | return VK_ERROR_INITIALIZATION_FAILED; |
| 208 | } |
| 209 | |
| 210 | // Advance the link info for the next element on the chain |
| 211 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 212 | |
| 213 | result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 214 | |
| 215 | if (result == VK_SUCCESS) { |
| 216 | InitializeManualParameterValidationFunctionPointers(); |
| 217 | auto my_instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), instance_layer_data_map); |
| 218 | assert(my_instance_data != nullptr); |
| 219 | |
| 220 | layer_init_instance_dispatch_table(*pInstance, &my_instance_data->dispatch_table, fpGetInstanceProcAddr); |
| 221 | my_instance_data->instance = *pInstance; |
| 222 | my_instance_data->report_data = |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 223 | debug_utils_create_instance(&my_instance_data->dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, |
| 224 | pCreateInfo->ppEnabledExtensionNames); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 225 | |
| 226 | // Look for one or more debug report create info structures |
| 227 | // and setup a callback(s) for each one found. |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 228 | if (!layer_copy_tmp_debug_messengers(pCreateInfo->pNext, &my_instance_data->num_tmp_debug_messengers, |
| 229 | &my_instance_data->tmp_messenger_create_infos, |
| 230 | &my_instance_data->tmp_debug_messengers)) { |
| 231 | if (my_instance_data->num_tmp_debug_messengers > 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 232 | // Setup the temporary callback(s) here to catch early issues: |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 233 | if (layer_enable_tmp_debug_messengers(my_instance_data->report_data, my_instance_data->num_tmp_debug_messengers, |
| 234 | my_instance_data->tmp_messenger_create_infos, |
| 235 | my_instance_data->tmp_debug_messengers)) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 236 | // Failure of setting up one or more of the callback. |
| 237 | // Therefore, clean up and don't use those callbacks: |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 238 | layer_free_tmp_debug_messengers(my_instance_data->tmp_messenger_create_infos, |
| 239 | my_instance_data->tmp_debug_messengers); |
| 240 | my_instance_data->num_tmp_debug_messengers = 0; |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | if (!layer_copy_tmp_report_callbacks(pCreateInfo->pNext, &my_instance_data->num_tmp_report_callbacks, |
| 245 | &my_instance_data->tmp_report_create_infos, &my_instance_data->tmp_report_callbacks)) { |
| 246 | if (my_instance_data->num_tmp_report_callbacks > 0) { |
| 247 | // Setup the temporary callback(s) here to catch early issues: |
| 248 | if (layer_enable_tmp_report_callbacks(my_instance_data->report_data, my_instance_data->num_tmp_report_callbacks, |
| 249 | my_instance_data->tmp_report_create_infos, |
| 250 | my_instance_data->tmp_report_callbacks)) { |
| 251 | // Failure of setting up one or more of the callback. |
| 252 | // Therefore, clean up and don't use those callbacks: |
| 253 | layer_free_tmp_report_callbacks(my_instance_data->tmp_report_create_infos, |
| 254 | my_instance_data->tmp_report_callbacks); |
| 255 | my_instance_data->num_tmp_report_callbacks = 0; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | init_parameter_validation(my_instance_data, pAllocator); |
Mark Lobodzinski | bfb7ab9 | 2017-10-27 13:22:23 -0600 | [diff] [blame] | 261 | |
| 262 | uint32_t api_version = my_instance_data->extensions.InitFromInstanceCreateInfo( |
| 263 | (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0), pCreateInfo); |
| 264 | |
| 265 | if (pCreateInfo->pApplicationInfo) { |
| 266 | uint32_t specified_api_version = pCreateInfo->pApplicationInfo->apiVersion & ~VK_VERSION_PATCH(~0); |
| 267 | if (!(specified_api_version == VK_API_VERSION_1_0) && !(specified_api_version == VK_API_VERSION_1_1)) { |
| 268 | LOGCONSOLE( |
| 269 | "Warning: Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number -- (0x%08x) assuming " |
| 270 | "%s.\n", |
| 271 | pCreateInfo->pApplicationInfo->apiVersion, |
| 272 | (api_version == VK_API_VERSION_1_0) ? "VK_API_VERSION_1_0" : "VK_API_VERSION_1_1"); |
| 273 | } |
| 274 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 275 | |
| 276 | // Ordinarily we'd check these before calling down the chain, but none of the layer support is in place until now, if we |
| 277 | // survive we can report the issue now. |
| 278 | parameter_validation_vkCreateInstance(*pInstance, pCreateInfo, pAllocator, pInstance); |
| 279 | |
| 280 | if (pCreateInfo->pApplicationInfo) { |
| 281 | if (pCreateInfo->pApplicationInfo->pApplicationName) { |
| 282 | validate_string(my_instance_data->report_data, "vkCreateInstance", |
| 283 | "pCreateInfo->VkApplicationInfo->pApplicationName", |
| 284 | pCreateInfo->pApplicationInfo->pApplicationName); |
| 285 | } |
| 286 | |
| 287 | if (pCreateInfo->pApplicationInfo->pEngineName) { |
| 288 | validate_string(my_instance_data->report_data, "vkCreateInstance", "pCreateInfo->VkApplicationInfo->pEngineName", |
| 289 | pCreateInfo->pApplicationInfo->pEngineName); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | // Disable the tmp callbacks: |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 294 | if (my_instance_data->num_tmp_debug_messengers > 0) { |
| 295 | layer_disable_tmp_debug_messengers(my_instance_data->report_data, my_instance_data->num_tmp_debug_messengers, |
| 296 | my_instance_data->tmp_debug_messengers); |
| 297 | } |
| 298 | if (my_instance_data->num_tmp_report_callbacks > 0) { |
| 299 | layer_disable_tmp_report_callbacks(my_instance_data->report_data, my_instance_data->num_tmp_report_callbacks, |
| 300 | my_instance_data->tmp_report_callbacks); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 301 | } |
| 302 | } |
| 303 | |
| 304 | return result; |
| 305 | } |
| 306 | |
| 307 | VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 308 | // Grab the key before the instance is destroyed. |
| 309 | dispatch_key key = get_dispatch_key(instance); |
| 310 | bool skip = false; |
| 311 | auto instance_data = GetLayerDataPtr(key, instance_layer_data_map); |
| 312 | |
| 313 | // Enable the temporary callback(s) here to catch vkDestroyInstance issues: |
| 314 | bool callback_setup = false; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 315 | if (instance_data->num_tmp_debug_messengers > 0) { |
| 316 | if (!layer_enable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers, |
| 317 | instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers)) { |
| 318 | callback_setup = true; |
| 319 | } |
| 320 | } |
| 321 | if (instance_data->num_tmp_report_callbacks > 0) { |
| 322 | if (!layer_enable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks, |
| 323 | instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks)) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 324 | callback_setup = true; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | skip |= parameter_validation_vkDestroyInstance(instance, pAllocator); |
| 329 | |
| 330 | // Disable and cleanup the temporary callback(s): |
| 331 | if (callback_setup) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 332 | layer_disable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers, |
| 333 | instance_data->tmp_debug_messengers); |
| 334 | layer_disable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks, |
| 335 | instance_data->tmp_report_callbacks); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 336 | } |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 337 | if (instance_data->num_tmp_debug_messengers > 0) { |
| 338 | layer_free_tmp_debug_messengers(instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers); |
| 339 | instance_data->num_tmp_debug_messengers = 0; |
| 340 | } |
| 341 | if (instance_data->num_tmp_report_callbacks > 0) { |
| 342 | layer_free_tmp_report_callbacks(instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks); |
| 343 | instance_data->num_tmp_report_callbacks = 0; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | if (!skip) { |
| 347 | instance_data->dispatch_table.DestroyInstance(instance, pAllocator); |
| 348 | |
| 349 | // Clean up logging callback, if any |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 350 | while (instance_data->logging_messenger.size() > 0) { |
| 351 | VkDebugUtilsMessengerEXT messenger = instance_data->logging_messenger.back(); |
| 352 | layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator); |
| 353 | instance_data->logging_messenger.pop_back(); |
| 354 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 355 | while (instance_data->logging_callback.size() > 0) { |
| 356 | VkDebugReportCallbackEXT callback = instance_data->logging_callback.back(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 357 | layer_destroy_report_callback(instance_data->report_data, callback, pAllocator); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 358 | instance_data->logging_callback.pop_back(); |
| 359 | } |
| 360 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 361 | layer_debug_utils_destroy_instance(instance_data->report_data); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | FreeLayerDataPtr(key, instance_layer_data_map); |
| 365 | } |
| 366 | |
| 367 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, |
| 368 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 369 | const VkAllocationCallbacks *pAllocator, |
| 370 | VkDebugReportCallbackEXT *pMsgCallback) { |
| 371 | bool skip = parameter_validation_vkCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
| 372 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 373 | |
| 374 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 375 | VkResult result = instance_data->dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
| 376 | if (result == VK_SUCCESS) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 377 | result = layer_create_report_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMsgCallback); |
| 378 | // If something happened during this call, clean up the message callback that was created earlier in the lower levels |
| 379 | if (VK_SUCCESS != result) { |
| 380 | instance_data->dispatch_table.DestroyDebugReportCallbackEXT(instance, *pMsgCallback, pAllocator); |
| 381 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 382 | } |
| 383 | return result; |
| 384 | } |
| 385 | |
| 386 | VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 387 | const VkAllocationCallbacks *pAllocator) { |
| 388 | bool skip = parameter_validation_vkDestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
| 389 | if (!skip) { |
| 390 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 391 | instance_data->dispatch_table.DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 392 | layer_destroy_report_callback(instance_data->report_data, msgCallback, pAllocator); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT(VkInstance instance, |
| 397 | const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 398 | const VkAllocationCallbacks *pAllocator, |
| 399 | VkDebugUtilsMessengerEXT *pMessenger) { |
| 400 | bool skip = parameter_validation_vkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); |
| 401 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 402 | |
| 403 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 404 | VkResult result = instance_data->dispatch_table.CreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); |
| 405 | if (VK_SUCCESS == result) { |
| 406 | result = layer_create_messenger_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMessenger); |
| 407 | // If something happened during this call, clean up the message callback that was created earlier in the lower levels |
| 408 | if (VK_SUCCESS != result) { |
| 409 | instance_data->dispatch_table.DestroyDebugUtilsMessengerEXT(instance, *pMessenger, pAllocator); |
| 410 | } |
| 411 | } |
| 412 | return result; |
| 413 | } |
| 414 | |
| 415 | VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 416 | const VkAllocationCallbacks *pAllocator) { |
| 417 | bool skip = parameter_validation_vkDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); |
| 418 | if (!skip) { |
| 419 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 420 | instance_data->dispatch_table.DestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); |
| 421 | layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | |
| 425 | static bool ValidateDeviceCreateInfo(instance_layer_data *instance_data, VkPhysicalDevice physicalDevice, |
| 426 | const VkDeviceCreateInfo *pCreateInfo) { |
| 427 | bool skip = false; |
| 428 | |
| 429 | if ((pCreateInfo->enabledLayerCount > 0) && (pCreateInfo->ppEnabledLayerNames != NULL)) { |
| 430 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 431 | skip |= validate_string(instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 432 | pCreateInfo->ppEnabledLayerNames[i]); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | bool maint1 = false; |
| 437 | bool negative_viewport = false; |
| 438 | |
| 439 | if ((pCreateInfo->enabledExtensionCount > 0) && (pCreateInfo->ppEnabledExtensionNames != NULL)) { |
| 440 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 441 | skip |= validate_string(instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 442 | pCreateInfo->ppEnabledExtensionNames[i]); |
| 443 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MAINTENANCE1_EXTENSION_NAME) == 0) maint1 = true; |
| 444 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME) == 0) |
| 445 | negative_viewport = true; |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | if (maint1 && negative_viewport) { |
| 450 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 451 | __LINE__, VALIDATION_ERROR_056002ec, LayerName, |
| 452 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 453 | "VK_AMD_negative_viewport_height."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 457 | // Check for get_physical_device_properties2 struct |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 458 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext); |
| 459 | if (features2) { |
| 460 | // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures |
| 461 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 462 | __LINE__, INVALID_USAGE, LayerName, |
| 463 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when " |
| 464 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 465 | } |
| 466 | } |
| 467 | |
| 468 | // Validate pCreateInfo->pQueueCreateInfos |
| 469 | if (pCreateInfo->pQueueCreateInfos) { |
| 470 | std::unordered_set<uint32_t> set; |
| 471 | |
| 472 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
| 473 | const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex; |
| 474 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
| 475 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 476 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, |
| 477 | VALIDATION_ERROR_06c002fa, LayerName, |
| 478 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 479 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 480 | "index value.", |
| 481 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 482 | } else if (set.count(requested_queue_family)) { |
| 483 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 484 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, |
| 485 | VALIDATION_ERROR_056002e8, LayerName, |
| 486 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 487 | ") is not unique within pCreateInfo->pQueueCreateInfos array.", |
| 488 | i, requested_queue_family); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 489 | } else { |
| 490 | set.insert(requested_queue_family); |
| 491 | } |
| 492 | |
| 493 | if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) { |
| 494 | for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) { |
| 495 | const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j]; |
| 496 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
| 497 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 498 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, |
| 499 | VALIDATION_ERROR_06c002fe, LayerName, |
| 500 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 501 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 502 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | return skip; |
| 510 | } |
| 511 | |
| 512 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 513 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 514 | // NOTE: Don't validate physicalDevice or any dispatchable object as the first parameter. We couldn't get here if it was wrong! |
| 515 | |
| 516 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 517 | bool skip = false; |
| 518 | auto my_instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map); |
| 519 | assert(my_instance_data != nullptr); |
| 520 | std::unique_lock<std::mutex> lock(global_lock); |
| 521 | |
| 522 | skip |= parameter_validation_vkCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 523 | |
| 524 | if (pCreateInfo != NULL) skip |= ValidateDeviceCreateInfo(my_instance_data, physicalDevice, pCreateInfo); |
| 525 | |
| 526 | if (!skip) { |
| 527 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 528 | assert(chain_info != nullptr); |
| 529 | assert(chain_info->u.pLayerInfo != nullptr); |
| 530 | |
| 531 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 532 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 533 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(my_instance_data->instance, "vkCreateDevice"); |
| 534 | if (fpCreateDevice == NULL) { |
| 535 | return VK_ERROR_INITIALIZATION_FAILED; |
| 536 | } |
| 537 | |
| 538 | // Advance the link info for the next element on the chain |
| 539 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 540 | |
| 541 | lock.unlock(); |
| 542 | |
| 543 | result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 544 | |
| 545 | lock.lock(); |
| 546 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 547 | if (result == VK_SUCCESS) { |
| 548 | layer_data *my_device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
| 549 | assert(my_device_data != nullptr); |
| 550 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 551 | my_device_data->report_data = layer_debug_utils_create_device(my_instance_data->report_data, *pDevice); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 552 | layer_init_device_dispatch_table(*pDevice, &my_device_data->dispatch_table, fpGetDeviceProcAddr); |
| 553 | |
Mark Lobodzinski | bfb7ab9 | 2017-10-27 13:22:23 -0600 | [diff] [blame] | 554 | // Query and save physical device limits for this device |
| 555 | VkPhysicalDeviceProperties device_properties = {}; |
| 556 | my_instance_data->dispatch_table.GetPhysicalDeviceProperties(physicalDevice, &device_properties); |
| 557 | |
| 558 | my_device_data->api_version = my_device_data->extensions.InitFromDeviceCreateInfo( |
| 559 | &my_instance_data->extensions, device_properties.apiVersion, pCreateInfo); |
| 560 | |
| 561 | uint32_t specified_api_version = device_properties.apiVersion & ~VK_VERSION_PATCH(~0); |
| 562 | if (!(specified_api_version == VK_API_VERSION_1_0) && !(specified_api_version == VK_API_VERSION_1_1)) { |
| 563 | LOGCONSOLE( |
| 564 | "Warning: Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number -- (0x%8x) assuming " |
| 565 | "%s.\n", |
| 566 | device_properties.apiVersion, |
| 567 | (my_device_data->api_version == VK_API_VERSION_1_0) ? "VK_API_VERSION_1_0" : "VK_API_VERSION_1_1"); |
| 568 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 569 | |
| 570 | // Store createdevice data |
| 571 | if ((pCreateInfo != nullptr) && (pCreateInfo->pQueueCreateInfos != nullptr)) { |
| 572 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
| 573 | my_device_data->queueFamilyIndexMap.insert(std::make_pair(pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex, |
| 574 | pCreateInfo->pQueueCreateInfos[i].queueCount)); |
| 575 | } |
| 576 | } |
| 577 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 578 | memcpy(&my_device_data->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 579 | my_device_data->physical_device = physicalDevice; |
| 580 | my_device_data->device = *pDevice; |
| 581 | |
| 582 | // Save app-enabled features in this device's layer_data structure |
John Zulauf | 1bde5bb | 2017-10-18 18:21:23 -0600 | [diff] [blame] | 583 | // The enabled features can come from either pEnabledFeatures, or from the pNext chain |
| 584 | const VkPhysicalDeviceFeatures *enabled_features_found = pCreateInfo->pEnabledFeatures; |
| 585 | if ((nullptr == enabled_features_found) && my_device_data->extensions.vk_khr_get_physical_device_properties_2) { |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 586 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext); |
| 587 | if (features2) { |
| 588 | enabled_features_found = &(features2->features); |
John Zulauf | 1bde5bb | 2017-10-18 18:21:23 -0600 | [diff] [blame] | 589 | } |
| 590 | } |
| 591 | if (enabled_features_found) { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 592 | my_device_data->physical_device_features = *enabled_features_found; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 593 | } else { |
| 594 | memset(&my_device_data->physical_device_features, 0, sizeof(VkPhysicalDeviceFeatures)); |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | return result; |
| 600 | } |
| 601 | |
| 602 | VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
| 603 | dispatch_key key = get_dispatch_key(device); |
| 604 | bool skip = false; |
| 605 | layer_data *device_data = GetLayerDataPtr(key, layer_data_map); |
| 606 | { |
| 607 | std::unique_lock<std::mutex> lock(global_lock); |
| 608 | skip |= parameter_validation_vkDestroyDevice(device, pAllocator); |
| 609 | } |
| 610 | |
| 611 | if (!skip) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 612 | layer_debug_utils_destroy_device(device); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 613 | device_data->dispatch_table.DestroyDevice(device, pAllocator); |
| 614 | } |
| 615 | FreeLayerDataPtr(key, layer_data_map); |
| 616 | } |
| 617 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 618 | bool pv_vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
| 619 | bool skip = false; |
| 620 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 621 | |
| 622 | skip |= |
| 623 | ValidateDeviceQueueFamily(device_data, queueFamilyIndex, "vkGetDeviceQueue", "queueFamilyIndex", VALIDATION_ERROR_29600300); |
| 624 | const auto &queue_data = device_data->queueFamilyIndexMap.find(queueFamilyIndex); |
| 625 | if (queue_data != device_data->queueFamilyIndexMap.end() && queue_data->second <= queueIndex) { |
| 626 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 627 | HandleToUint64(device), __LINE__, VALIDATION_ERROR_29600302, LayerName, |
| 628 | "vkGetDeviceQueue: queueIndex (=%" PRIu32 |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 629 | ") is not less than the number of queues requested from queueFamilyIndex (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 630 | ") when the device was created (i.e. is not less than %" PRIu32 ").", |
| 631 | queueIndex, queueFamilyIndex, queue_data->second); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 632 | } |
| 633 | return skip; |
| 634 | } |
| 635 | |
| 636 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, |
| 637 | const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) { |
| 638 | layer_data *local_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 639 | bool skip = false; |
| 640 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 641 | std::unique_lock<std::mutex> lock(global_lock); |
| 642 | |
| 643 | skip |= ValidateDeviceQueueFamily(local_data, pCreateInfo->queueFamilyIndex, "vkCreateCommandPool", |
| 644 | "pCreateInfo->queueFamilyIndex", VALIDATION_ERROR_02c0004e); |
| 645 | |
| 646 | skip |= parameter_validation_vkCreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); |
| 647 | |
| 648 | lock.unlock(); |
| 649 | if (!skip) { |
| 650 | result = local_data->dispatch_table.CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); |
| 651 | } |
| 652 | return result; |
| 653 | } |
| 654 | |
| 655 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
| 656 | const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool) { |
| 657 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 658 | bool skip = false; |
| 659 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 660 | |
| 661 | skip |= parameter_validation_vkCreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool); |
| 662 | |
| 663 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 664 | if (pCreateInfo != nullptr) { |
| 665 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 666 | // VkQueryPipelineStatisticFlagBits values |
| 667 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 668 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
| 669 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 670 | __LINE__, VALIDATION_ERROR_11c00630, LayerName, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 671 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 672 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 673 | "values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 674 | } |
| 675 | } |
| 676 | if (!skip) { |
| 677 | result = device_data->dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool); |
| 678 | } |
| 679 | return result; |
| 680 | } |
| 681 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 682 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
| 683 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) { |
| 684 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 685 | bool skip = false; |
| 686 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 687 | |
| 688 | { |
| 689 | std::unique_lock<std::mutex> lock(global_lock); |
| 690 | skip |= parameter_validation_vkCreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); |
| 691 | |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 692 | typedef bool (*PFN_manual_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
| 693 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 694 | PFN_manual_vkCreateRenderPass custom_func = (PFN_manual_vkCreateRenderPass)custom_functions["vkCreateRenderPass"]; |
| 695 | if (custom_func != nullptr) { |
| 696 | skip |= custom_func(device, pCreateInfo, pAllocator, pRenderPass); |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | if (!skip) { |
| 701 | result = device_data->dispatch_table.CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); |
| 702 | |
| 703 | // track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments) |
| 704 | if (result == VK_SUCCESS) { |
| 705 | std::unique_lock<std::mutex> lock(global_lock); |
| 706 | const auto renderPass = *pRenderPass; |
| 707 | auto &renderpass_state = device_data->renderpasses_states[renderPass]; |
| 708 | |
| 709 | for (uint32_t subpass = 0; subpass < pCreateInfo->subpassCount; ++subpass) { |
| 710 | bool uses_color = false; |
| 711 | for (uint32_t i = 0; i < pCreateInfo->pSubpasses[subpass].colorAttachmentCount && !uses_color; ++i) |
| 712 | if (pCreateInfo->pSubpasses[subpass].pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) uses_color = true; |
| 713 | |
| 714 | bool uses_depthstencil = false; |
| 715 | if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment) |
| 716 | if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) |
| 717 | uses_depthstencil = true; |
| 718 | |
| 719 | if (uses_color) renderpass_state.subpasses_using_color_attachment.insert(subpass); |
| 720 | if (uses_depthstencil) renderpass_state.subpasses_using_depthstencil_attachment.insert(subpass); |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | return result; |
| 725 | } |
| 726 | |
| 727 | VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) { |
| 728 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 729 | bool skip = false; |
| 730 | |
| 731 | { |
| 732 | std::unique_lock<std::mutex> lock(global_lock); |
| 733 | skip |= parameter_validation_vkDestroyRenderPass(device, renderPass, pAllocator); |
| 734 | |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 735 | typedef bool (*PFN_manual_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, |
| 736 | const VkAllocationCallbacks *pAllocator); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 737 | PFN_manual_vkDestroyRenderPass custom_func = (PFN_manual_vkDestroyRenderPass)custom_functions["vkDestroyRenderPass"]; |
| 738 | if (custom_func != nullptr) { |
| 739 | skip |= custom_func(device, renderPass, pAllocator); |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | if (!skip) { |
| 744 | device_data->dispatch_table.DestroyRenderPass(device, renderPass, pAllocator); |
| 745 | |
| 746 | // track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments) |
| 747 | { |
| 748 | std::unique_lock<std::mutex> lock(global_lock); |
| 749 | device_data->renderpasses_states.erase(renderPass); |
| 750 | } |
| 751 | } |
| 752 | } |
| 753 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 754 | bool pv_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 755 | VkBuffer *pBuffer) { |
| 756 | bool skip = false; |
| 757 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 758 | debug_report_data *report_data = device_data->report_data; |
| 759 | |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 760 | const LogMiscParams log_misc{report_data, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, VK_NULL_HANDLE, LayerName, "vkCreateBuffer"}; |
| 761 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 762 | if (pCreateInfo != nullptr) { |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 763 | skip |= ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", VALIDATION_ERROR_01400720, log_misc); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 764 | |
| 765 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 766 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 767 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 768 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
| 769 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 770 | VALIDATION_ERROR_01400724, LayerName, |
| 771 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 772 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 776 | // queueFamilyIndexCount uint32_t values |
| 777 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
| 778 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 779 | VALIDATION_ERROR_01400722, LayerName, |
| 780 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 781 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 782 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 783 | } else { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 784 | skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices, |
| 785 | "vkCreateBuffer", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 786 | false); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 787 | } |
| 788 | } |
| 789 | |
| 790 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 791 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 792 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 793 | ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) { |
| 794 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 795 | VALIDATION_ERROR_0140072c, LayerName, |
| 796 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 797 | "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | |
| 801 | return skip; |
| 802 | } |
| 803 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 804 | bool pv_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 805 | VkImage *pImage) { |
| 806 | bool skip = false; |
| 807 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 808 | debug_report_data *report_data = device_data->report_data; |
| 809 | |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 810 | const LogMiscParams log_misc{report_data, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, VK_NULL_HANDLE, LayerName, "vkCreateImage"}; |
| 811 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 812 | if (pCreateInfo != nullptr) { |
| 813 | if ((device_data->physical_device_features.textureCompressionETC2 == false) && |
| 814 | FormatIsCompressed_ETC2_EAC(pCreateInfo->format)) { |
| 815 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 816 | DEVICE_FEATURE, LayerName, |
| 817 | "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionETC2 feature is " |
| 818 | "not enabled: neither ETC2 nor EAC formats can be used to create images.", |
| 819 | string_VkFormat(pCreateInfo->format)); |
| 820 | } |
| 821 | |
| 822 | if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) && |
| 823 | FormatIsCompressed_ASTC_LDR(pCreateInfo->format)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 824 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 825 | DEVICE_FEATURE, LayerName, |
| 826 | "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionASTC_LDR feature " |
| 827 | "is not enabled: ASTC formats cannot be used to create images.", |
| 828 | string_VkFormat(pCreateInfo->format)); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | if ((device_data->physical_device_features.textureCompressionBC == false) && FormatIsCompressed_BC(pCreateInfo->format)) { |
| 832 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 833 | DEVICE_FEATURE, LayerName, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 834 | "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionBC feature is not " |
| 835 | "enabled: BC compressed formats cannot be used to create images.", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 836 | string_VkFormat(pCreateInfo->format)); |
| 837 | } |
| 838 | |
| 839 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 840 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 841 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 842 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
| 843 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 844 | VALIDATION_ERROR_09e0075c, LayerName, |
| 845 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 846 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 850 | // queueFamilyIndexCount uint32_t values |
| 851 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
| 852 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 853 | VALIDATION_ERROR_09e0075a, LayerName, |
| 854 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 855 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 856 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 857 | } else { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 858 | skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices, |
| 859 | "vkCreateImage", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 860 | false); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 861 | } |
| 862 | } |
| 863 | |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 864 | skip |= |
| 865 | ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", VALIDATION_ERROR_09e00760, log_misc); |
| 866 | skip |= |
| 867 | ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", VALIDATION_ERROR_09e00762, log_misc); |
| 868 | skip |= |
| 869 | ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", VALIDATION_ERROR_09e00764, log_misc); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 870 | |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 871 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", VALIDATION_ERROR_09e00766, log_misc); |
| 872 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", VALIDATION_ERROR_09e00768, log_misc); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 873 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 874 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 875 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 876 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
| 877 | skip |= log_msg( |
| 878 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 879 | VALIDATION_ERROR_09e007c2, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 880 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 881 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 882 | } |
| 883 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 884 | // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1 |
Petr Kraus | 3ac9e81 | 2018-03-13 12:31:08 +0100 | [diff] [blame] | 885 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 886 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 887 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 888 | VALIDATION_ERROR_09e00778, LayerName, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 889 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 890 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 894 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 895 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 896 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
| 897 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_09e00774, LayerName, |
| 898 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 899 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 900 | ") are not equal.", |
| 901 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 902 | } |
| 903 | |
| 904 | if (pCreateInfo->arrayLayers < 6) { |
| 905 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
| 906 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_09e00774, LayerName, |
| 907 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 908 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 909 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 910 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 911 | } |
| 912 | |
| 913 | if (pCreateInfo->extent.depth != 1) { |
| 914 | skip |= log_msg( |
| 915 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 916 | VALIDATION_ERROR_09e0077a, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 917 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 918 | } |
| 919 | } |
| 920 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 921 | // 3D image may have only 1 layer |
| 922 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
| 923 | skip |= |
| 924 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 925 | VALIDATION_ERROR_09e00782, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 926 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 927 | } |
| 928 | |
| 929 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 930 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
| 931 | ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || |
| 932 | (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) || (pCreateInfo->mipLevels != 1))) { |
| 933 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 934 | VALIDATION_ERROR_09e00784, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 935 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 939 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 940 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 941 | // At least one of the legal attachment bits must be set |
| 942 | if (0 == (pCreateInfo->usage & legal_flags)) { |
| 943 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 944 | VALIDATION_ERROR_09e0078c, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 945 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 946 | } |
| 947 | // No flags other than the legal attachment bits may be set |
| 948 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 949 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
| 950 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 951 | VALIDATION_ERROR_09e00786, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 952 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 953 | } |
| 954 | } |
| 955 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 956 | // mipLevels must be less than or equal to floor(log2(max(extent.width,extent.height,extent.depth)))+1 |
| 957 | uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth); |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 958 | if (maxDim > 0 && pCreateInfo->mipLevels > (floor(log2(maxDim)) + 1)) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 959 | skip |= |
| 960 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 961 | VALIDATION_ERROR_09e0077c, LayerName, |
| 962 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 963 | "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 964 | } |
| 965 | |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 966 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!device_data->physical_device_features.sparseBinding)) { |
| 967 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, VK_NULL_HANDLE, |
| 968 | __LINE__, VALIDATION_ERROR_09e00792, LayerName, |
| 969 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 970 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 971 | } |
| 972 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 973 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 974 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
| 975 | if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 976 | ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) { |
| 977 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 978 | VALIDATION_ERROR_09e007b6, LayerName, |
| 979 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 980 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
| 984 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
| 985 | // Linear tiling is unsupported |
| 986 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
| 987 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 988 | INVALID_USAGE, LayerName, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 989 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 990 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | // Sparse 1D image isn't valid |
| 994 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
| 995 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 996 | VALIDATION_ERROR_09e00794, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 997 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | // Sparse 2D image when device doesn't support it |
| 1001 | if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage2D) && |
| 1002 | (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) { |
| 1003 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1004 | VALIDATION_ERROR_09e00796, LayerName, |
| 1005 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1006 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | // Sparse 3D image when device doesn't support it |
| 1010 | if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage3D) && |
| 1011 | (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) { |
| 1012 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1013 | VALIDATION_ERROR_09e00798, LayerName, |
| 1014 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1015 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | // Multi-sample 2D image when device doesn't support it |
| 1019 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
| 1020 | if ((VK_FALSE == device_data->physical_device_features.sparseResidency2Samples) && |
| 1021 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1022 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1023 | __LINE__, VALIDATION_ERROR_09e0079a, LayerName, |
| 1024 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1025 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1026 | } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency4Samples) && |
| 1027 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1028 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1029 | __LINE__, VALIDATION_ERROR_09e0079c, LayerName, |
| 1030 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1031 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1032 | } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency8Samples) && |
| 1033 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1034 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1035 | __LINE__, VALIDATION_ERROR_09e0079e, LayerName, |
| 1036 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1037 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1038 | } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency16Samples) && |
| 1039 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1040 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1041 | __LINE__, VALIDATION_ERROR_09e007a0, LayerName, |
| 1042 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1043 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1044 | } |
| 1045 | } |
| 1046 | } |
| 1047 | } |
| 1048 | return skip; |
| 1049 | } |
| 1050 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1051 | bool pv_vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1052 | VkImageView *pView) { |
| 1053 | bool skip = false; |
| 1054 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1055 | debug_report_data *report_data = device_data->report_data; |
| 1056 | |
| 1057 | if (pCreateInfo != nullptr) { |
| 1058 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) || (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D)) { |
| 1059 | if ((pCreateInfo->subresourceRange.layerCount != 1) && |
| 1060 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 1061 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 1062 | LayerName, |
| 1063 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD, " |
| 1064 | "pCreateInfo->subresourceRange.layerCount must be 1", |
| 1065 | ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) ? 1 : 2)); |
| 1066 | } |
| 1067 | } else if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) || |
| 1068 | (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY)) { |
| 1069 | if ((pCreateInfo->subresourceRange.layerCount < 1) && |
| 1070 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 1071 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 1072 | LayerName, |
| 1073 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD_ARRAY, " |
| 1074 | "pCreateInfo->subresourceRange.layerCount must be >= 1", |
| 1075 | ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ? 1 : 2)); |
| 1076 | } |
| 1077 | } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE) { |
| 1078 | if ((pCreateInfo->subresourceRange.layerCount != 6) && |
| 1079 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 1080 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 1081 | LayerName, |
| 1082 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE, " |
| 1083 | "pCreateInfo->subresourceRange.layerCount must be 6"); |
| 1084 | } |
| 1085 | } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) { |
| 1086 | if (((pCreateInfo->subresourceRange.layerCount == 0) || ((pCreateInfo->subresourceRange.layerCount % 6) != 0)) && |
| 1087 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 1088 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 1089 | LayerName, |
| 1090 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE_ARRAY, " |
| 1091 | "pCreateInfo->subresourceRange.layerCount must be a multiple of 6"); |
| 1092 | } |
| 1093 | if (!device_data->physical_device_features.imageCubeArray) { |
| 1094 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 1095 | LayerName, "vkCreateImageView: Device feature imageCubeArray not enabled."); |
| 1096 | } |
| 1097 | } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) { |
| 1098 | if (pCreateInfo->subresourceRange.baseArrayLayer != 0) { |
| 1099 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 1100 | LayerName, |
| 1101 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " |
| 1102 | "pCreateInfo->subresourceRange.baseArrayLayer must be 0"); |
| 1103 | } |
| 1104 | |
| 1105 | if ((pCreateInfo->subresourceRange.layerCount != 1) && |
| 1106 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 1107 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 1108 | LayerName, |
| 1109 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " |
| 1110 | "pCreateInfo->subresourceRange.layerCount must be 1"); |
| 1111 | } |
| 1112 | } |
| 1113 | } |
| 1114 | return skip; |
| 1115 | } |
| 1116 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1117 | bool pv_VkViewport(const layer_data *device_data, const VkViewport &viewport, const char *fn_name, const char *param_name, |
| 1118 | VkDebugReportObjectTypeEXT object_type, uint64_t object = 0) { |
| 1119 | bool skip = false; |
| 1120 | debug_report_data *report_data = device_data->report_data; |
| 1121 | |
| 1122 | // Note: for numerical correctness |
| 1123 | // - float comparisons should expect NaN (comparison always false). |
| 1124 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 1125 | |
| 1126 | const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) { |
John Zulauf | ac0876c | 2018-02-19 10:09:35 -0700 | [diff] [blame] | 1127 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1128 | if (v1_f <= 0.0f) return true; |
| 1129 | |
| 1130 | float intpart; |
| 1131 | const float fract = modff(v1_f, &intpart); |
| 1132 | |
| 1133 | assert(std::numeric_limits<float>::radix == 2); |
| 1134 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 1135 | if (intpart >= u32_max_plus1) return false; |
| 1136 | |
| 1137 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
| 1138 | if (v1_u32 < v2_u32) |
| 1139 | return true; |
| 1140 | else if (v1_u32 == v2_u32 && fract == 0.0f) |
| 1141 | return true; |
| 1142 | else |
| 1143 | return false; |
| 1144 | }; |
| 1145 | |
| 1146 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 1147 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 1148 | return (v1_f <= v2_f); |
| 1149 | }; |
| 1150 | |
| 1151 | // width |
| 1152 | bool width_healthy = true; |
| 1153 | const auto max_w = device_data->device_limits.maxViewportDimensions[0]; |
| 1154 | |
| 1155 | if (!(viewport.width > 0.0f)) { |
| 1156 | width_healthy = false; |
| 1157 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000dd4, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1158 | LayerName, "%s: %s.width (=%f) is not greater than 0.0.", fn_name, param_name, viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1159 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 1160 | width_healthy = false; |
| 1161 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000dd6, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1162 | LayerName, "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", |
| 1163 | fn_name, param_name, viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1164 | } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) { |
| 1165 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, object_type, object, __LINE__, NONE, LayerName, |
| 1166 | "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1167 | "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.", |
| 1168 | fn_name, param_name, viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1169 | } |
| 1170 | |
| 1171 | // height |
| 1172 | bool height_healthy = true; |
Petr Kraus | af9c122 | 2018-03-10 02:39:47 +0100 | [diff] [blame] | 1173 | const bool negative_height_enabled = device_data->api_version >= VK_API_VERSION_1_1 || |
| 1174 | device_data->extensions.vk_khr_maintenance1 || |
| 1175 | device_data->extensions.vk_amd_negative_viewport_height; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1176 | const auto max_h = device_data->device_limits.maxViewportDimensions[1]; |
| 1177 | |
| 1178 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1179 | height_healthy = false; |
| 1180 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000dd8, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1181 | LayerName, "%s: %s.height (=%f) is not greater 0.0.", fn_name, param_name, viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1182 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1183 | height_healthy = false; |
| 1184 | |
| 1185 | skip |= log_msg( |
| 1186 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000dda, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1187 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 ").", |
| 1188 | fn_name, param_name, viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1189 | } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) { |
| 1190 | height_healthy = false; |
| 1191 | |
| 1192 | skip |= log_msg( |
| 1193 | report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, object_type, object, __LINE__, NONE, LayerName, |
| 1194 | "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1195 | "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.", |
| 1196 | fn_name, param_name, viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | // x |
| 1200 | bool x_healthy = true; |
| 1201 | if (!(viewport.x >= device_data->device_limits.viewportBoundsRange[0])) { |
| 1202 | x_healthy = false; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1203 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000ddc, |
| 1204 | LayerName, "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1205 | param_name, viewport.x, device_data->device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1206 | } |
| 1207 | |
| 1208 | // x + width |
| 1209 | if (x_healthy && width_healthy) { |
| 1210 | const float right_bound = viewport.x + viewport.width; |
| 1211 | if (!(right_bound <= device_data->device_limits.viewportBoundsRange[1])) { |
| 1212 | skip |= log_msg( |
| 1213 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_150009a0, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1214 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1215 | fn_name, param_name, param_name, viewport.x, viewport.width, right_bound, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1216 | device_data->device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | // y |
| 1221 | bool y_healthy = true; |
| 1222 | if (!(viewport.y >= device_data->device_limits.viewportBoundsRange[0])) { |
| 1223 | y_healthy = false; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1224 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000dde, |
| 1225 | LayerName, "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1226 | param_name, viewport.y, device_data->device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1227 | } else if (negative_height_enabled && !(viewport.y <= device_data->device_limits.viewportBoundsRange[1])) { |
| 1228 | y_healthy = false; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1229 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000de0, |
| 1230 | LayerName, "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1231 | param_name, viewport.y, device_data->device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | // y + height |
| 1235 | if (y_healthy && height_healthy) { |
| 1236 | const float boundary = viewport.y + viewport.height; |
| 1237 | |
| 1238 | if (!(boundary <= device_data->device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1239 | skip |= log_msg( |
| 1240 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_150009a2, LayerName, |
| 1241 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1242 | param_name, param_name, viewport.y, viewport.height, boundary, device_data->device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1243 | } else if (negative_height_enabled && !(boundary >= device_data->device_limits.viewportBoundsRange[0])) { |
| 1244 | skip |= log_msg( |
| 1245 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_15000de2, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1246 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1247 | param_name, param_name, viewport.y, viewport.height, boundary, device_data->device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | if (!device_data->extensions.vk_ext_depth_range_unrestricted) { |
| 1252 | // minDepth |
| 1253 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
| 1254 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_150009a4, |
| 1255 | LayerName, |
| 1256 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1257 | "[0.0, 1.0] range.", |
| 1258 | fn_name, param_name, viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | // maxDepth |
| 1262 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
| 1263 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, __LINE__, VALIDATION_ERROR_150009a6, |
| 1264 | LayerName, |
| 1265 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1266 | "[0.0, 1.0] range.", |
| 1267 | fn_name, param_name, viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | return skip; |
| 1272 | } |
| 1273 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1274 | bool pv_vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 1275 | const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 1276 | VkPipeline *pPipelines) { |
| 1277 | bool skip = false; |
| 1278 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1279 | debug_report_data *report_data = device_data->report_data; |
| 1280 | |
| 1281 | if (pCreateInfos != nullptr) { |
| 1282 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1283 | bool has_dynamic_viewport = false; |
| 1284 | bool has_dynamic_scissor = false; |
| 1285 | bool has_dynamic_line_width = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1286 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1287 | bool has_dynamic_discard_rectangle_ext = false; |
| 1288 | bool has_dynamic_sample_locations_ext = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1289 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1290 | const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState; |
| 1291 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1292 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
| 1293 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true; |
| 1294 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true; |
| 1295 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) has_dynamic_line_width = true; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1296 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) has_dynamic_viewport_w_scaling_nv = true; |
| 1297 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) has_dynamic_discard_rectangle_ext = true; |
| 1298 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) has_dynamic_sample_locations_ext = true; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1299 | } |
| 1300 | } |
| 1301 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1302 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 1303 | if (pCreateInfos[i].pVertexInputState != nullptr) { |
| 1304 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
| 1305 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 1306 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
| 1307 | if (vertex_bind_desc.binding >= device_data->device_limits.maxVertexInputBindings) { |
| 1308 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1309 | __LINE__, VALIDATION_ERROR_14c004d4, LayerName, |
| 1310 | "vkCreateGraphicsPipelines: parameter " |
| 1311 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1312 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1313 | i, d, vertex_bind_desc.binding, device_data->device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1314 | } |
| 1315 | |
| 1316 | if (vertex_bind_desc.stride > device_data->device_limits.maxVertexInputBindingStride) { |
| 1317 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1318 | __LINE__, VALIDATION_ERROR_14c004d6, LayerName, |
| 1319 | "vkCreateGraphicsPipelines: parameter " |
| 1320 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1321 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).", |
| 1322 | i, d, vertex_bind_desc.stride, device_data->device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 1327 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
| 1328 | if (vertex_attrib_desc.location >= device_data->device_limits.maxVertexInputAttributes) { |
| 1329 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1330 | __LINE__, VALIDATION_ERROR_14a004d8, LayerName, |
| 1331 | "vkCreateGraphicsPipelines: parameter " |
| 1332 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1333 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1334 | i, d, vertex_attrib_desc.location, device_data->device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | if (vertex_attrib_desc.binding >= device_data->device_limits.maxVertexInputBindings) { |
| 1338 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1339 | __LINE__, VALIDATION_ERROR_14a004da, LayerName, |
| 1340 | "vkCreateGraphicsPipelines: parameter " |
| 1341 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1342 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1343 | i, d, vertex_attrib_desc.binding, device_data->device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1344 | } |
| 1345 | |
| 1346 | if (vertex_attrib_desc.offset > device_data->device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1347 | skip |= |
| 1348 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1349 | __LINE__, VALIDATION_ERROR_14a004dc, LayerName, |
| 1350 | "vkCreateGraphicsPipelines: parameter " |
| 1351 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 1352 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).", |
| 1353 | i, d, vertex_attrib_desc.offset, device_data->device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1354 | } |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | if (pCreateInfos[i].pStages != nullptr) { |
| 1359 | bool has_control = false; |
| 1360 | bool has_eval = false; |
| 1361 | |
| 1362 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 1363 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 1364 | has_control = true; |
| 1365 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 1366 | has_eval = true; |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 1371 | if (has_control && has_eval) { |
| 1372 | if (pCreateInfos[i].pTessellationState == nullptr) { |
| 1373 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1374 | __LINE__, VALIDATION_ERROR_096005b6, LayerName, |
| 1375 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 1376 | "shader stage and a tessellation evaluation shader stage, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1377 | "pCreateInfos[%d].pTessellationState must not be NULL.", |
| 1378 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1379 | } else { |
| 1380 | skip |= validate_struct_pnext( |
| 1381 | report_data, "vkCreateGraphicsPipelines", |
| 1382 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1383 | pCreateInfos[i].pTessellationState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0961c40d); |
| 1384 | |
| 1385 | skip |= validate_reserved_flags( |
| 1386 | report_data, "vkCreateGraphicsPipelines", |
| 1387 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
| 1388 | pCreateInfos[i].pTessellationState->flags, VALIDATION_ERROR_10809005); |
| 1389 | |
| 1390 | if (pCreateInfos[i].pTessellationState->sType != |
| 1391 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO) { |
| 1392 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1393 | __LINE__, VALIDATION_ERROR_1082b00b, LayerName, |
| 1394 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pTessellationState->sType must " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1395 | "be VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO.", |
| 1396 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
| 1400 | pCreateInfos[i].pTessellationState->patchControlPoints > |
| 1401 | device_data->device_limits.maxTessellationPatchSize) { |
| 1402 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1403 | __LINE__, VALIDATION_ERROR_1080097c, LayerName, |
| 1404 | "vkCreateGraphicsPipelines: invalid parameter " |
| 1405 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1406 | "should be >0 and <=%u.", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1407 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1408 | device_data->device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1409 | } |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 1415 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 1416 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 1417 | if (pCreateInfos[i].pViewportState == nullptr) { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1418 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1419 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_096005dc, LayerName, |
| 1420 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 1421 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1422 | "].pViewportState (=NULL) is not a valid pointer.", |
| 1423 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1424 | } else { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1425 | const auto &viewport_state = *pCreateInfos[i].pViewportState; |
| 1426 | |
| 1427 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
| 1428 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1429 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c2b00b, LayerName, |
| 1430 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1431 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 1432 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1433 | } |
| 1434 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1435 | const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = { |
| 1436 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
| 1437 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV}; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1438 | skip |= validate_struct_pnext( |
| 1439 | report_data, "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1440 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
| 1441 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV", |
| 1442 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo), |
| 1443 | allowed_structs_VkPipelineViewportStateCreateInfo, 65, VALIDATION_ERROR_10c1c40d); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1444 | |
| 1445 | skip |= validate_reserved_flags( |
| 1446 | report_data, "vkCreateGraphicsPipelines", |
| 1447 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1448 | viewport_state.flags, VALIDATION_ERROR_10c09005); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1449 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1450 | if (!device_data->physical_device_features.multiViewport) { |
| 1451 | if (viewport_state.viewportCount != 1) { |
| 1452 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1453 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00980, LayerName, |
| 1454 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1455 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1456 | ") is not 1.", |
| 1457 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1458 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1459 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1460 | if (viewport_state.scissorCount != 1) { |
| 1461 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1462 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00982, LayerName, |
| 1463 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1464 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1465 | ") is not 1.", |
| 1466 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1467 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1468 | } else { // multiViewport enabled |
| 1469 | if (viewport_state.viewportCount == 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1470 | skip |= log_msg( |
| 1471 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1472 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c30a1b, LayerName, |
| 1473 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1474 | } else if (viewport_state.viewportCount > device_data->device_limits.maxViewports) { |
| 1475 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1476 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00984, LayerName, |
| 1477 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1478 | "].pViewportState->viewportCount (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1479 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1480 | i, viewport_state.viewportCount, device_data->device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1481 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1482 | |
| 1483 | if (viewport_state.scissorCount == 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1484 | skip |= log_msg( |
| 1485 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1486 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c2b61b, LayerName, |
| 1487 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1488 | } else if (viewport_state.scissorCount > device_data->device_limits.maxViewports) { |
| 1489 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1490 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00986, LayerName, |
| 1491 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1492 | "].pViewportState->scissorCount (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1493 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1494 | i, viewport_state.scissorCount, device_data->device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1495 | } |
| 1496 | } |
| 1497 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1498 | if (viewport_state.scissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1499 | skip |= |
| 1500 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1501 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00988, LayerName, |
| 1502 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 1503 | ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 1504 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1505 | } |
| 1506 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1507 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
| 1508 | skip |= log_msg( |
| 1509 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE, |
| 1510 | __LINE__, VALIDATION_ERROR_096005d6, LayerName, |
| 1511 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 1512 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1513 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 1514 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
| 1518 | skip |= log_msg( |
| 1519 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE, |
| 1520 | __LINE__, VALIDATION_ERROR_096005d8, LayerName, |
| 1521 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 1522 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1523 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 1524 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1525 | } |
| 1526 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1527 | // validate the VkViewports |
| 1528 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 1529 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 1530 | const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr |
| 1531 | const char fn_name[] = "vkCreateGraphicsPipelines"; |
| 1532 | const std::string param_name = "pCreateInfos[" + std::to_string(i) + "].pViewportState->pViewports[" + |
| 1533 | std::to_string(viewport_i) + "]"; |
| 1534 | skip |= pv_VkViewport(device_data, viewport, fn_name, param_name.c_str(), |
| 1535 | VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT); |
| 1536 | } |
| 1537 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1538 | |
| 1539 | if (has_dynamic_viewport_w_scaling_nv && !device_data->extensions.vk_nv_clip_space_w_scaling) { |
| 1540 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1541 | VK_NULL_HANDLE, __LINE__, EXTENSION_NOT_ENABLED, LayerName, |
| 1542 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1543 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1544 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 1545 | i); |
| 1546 | } |
| 1547 | |
| 1548 | if (has_dynamic_discard_rectangle_ext && !device_data->extensions.vk_ext_discard_rectangles) { |
| 1549 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1550 | VK_NULL_HANDLE, __LINE__, EXTENSION_NOT_ENABLED, LayerName, |
| 1551 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1552 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1553 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 1554 | i); |
| 1555 | } |
| 1556 | |
| 1557 | if (has_dynamic_sample_locations_ext && !device_data->extensions.vk_ext_sample_locations) { |
| 1558 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, |
| 1559 | VK_NULL_HANDLE, __LINE__, EXTENSION_NOT_ENABLED, LayerName, |
| 1560 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1561 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1562 | "VK_EXT_sample_locations extension is not enabled.", |
| 1563 | i); |
| 1564 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
| 1568 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1569 | __LINE__, VALIDATION_ERROR_096005de, LayerName, |
| 1570 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1571 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.", |
| 1572 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1573 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 1574 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
| 1575 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 1576 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 1577 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1578 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 1579 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1580 | skip |= validate_struct_pnext( |
| 1581 | report_data, "vkCreateGraphicsPipelines", |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 1582 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
| 1583 | valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes, GeneratedHeaderVersion, |
| 1584 | VALIDATION_ERROR_1001c40d); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1585 | |
| 1586 | skip |= validate_reserved_flags( |
| 1587 | report_data, "vkCreateGraphicsPipelines", |
| 1588 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
| 1589 | pCreateInfos[i].pMultisampleState->flags, VALIDATION_ERROR_10009005); |
| 1590 | |
| 1591 | skip |= validate_bool32( |
| 1592 | report_data, "vkCreateGraphicsPipelines", |
| 1593 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 1594 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 1595 | |
| 1596 | skip |= validate_array( |
| 1597 | report_data, "vkCreateGraphicsPipelines", |
| 1598 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 1599 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
| 1600 | pCreateInfos[i].pMultisampleState->rasterizationSamples, pCreateInfos[i].pMultisampleState->pSampleMask, |
| 1601 | true, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 1602 | |
| 1603 | skip |= validate_bool32( |
| 1604 | report_data, "vkCreateGraphicsPipelines", |
| 1605 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 1606 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 1607 | |
| 1608 | skip |= validate_bool32( |
| 1609 | report_data, "vkCreateGraphicsPipelines", |
| 1610 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 1611 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 1612 | |
| 1613 | if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) { |
| 1614 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1615 | __LINE__, INVALID_STRUCT_STYPE, LayerName, |
| 1616 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 1617 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 1618 | i); |
| 1619 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 1620 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) { |
| 1621 | if (!device_data->physical_device_features.sampleRateShading) { |
| 1622 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1623 | __LINE__, VALIDATION_ERROR_10000620, LayerName, |
| 1624 | "vkCreateGraphicsPipelines(): parameter " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1625 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.", |
| 1626 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 1627 | } |
| 1628 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 1629 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
| 1630 | if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
| 1631 | skip |= log_msg( |
| 1632 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1633 | VALIDATION_ERROR_10000624, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1634 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", |
| 1635 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 1636 | } |
| 1637 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1638 | } |
| 1639 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 1640 | bool uses_color_attachment = false; |
| 1641 | bool uses_depthstencil_attachment = false; |
| 1642 | { |
| 1643 | const auto subpasses_uses_it = device_data->renderpasses_states.find(pCreateInfos[i].renderPass); |
| 1644 | if (subpasses_uses_it != device_data->renderpasses_states.end()) { |
| 1645 | const auto &subpasses_uses = subpasses_uses_it->second; |
| 1646 | if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) |
| 1647 | uses_color_attachment = true; |
| 1648 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) |
| 1649 | uses_depthstencil_attachment = true; |
| 1650 | } |
| 1651 | } |
| 1652 | |
| 1653 | if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1654 | skip |= validate_struct_pnext( |
| 1655 | report_data, "vkCreateGraphicsPipelines", |
| 1656 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1657 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f61c40d); |
| 1658 | |
| 1659 | skip |= validate_reserved_flags( |
| 1660 | report_data, "vkCreateGraphicsPipelines", |
| 1661 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
| 1662 | pCreateInfos[i].pDepthStencilState->flags, VALIDATION_ERROR_0f609005); |
| 1663 | |
| 1664 | skip |= validate_bool32( |
| 1665 | report_data, "vkCreateGraphicsPipelines", |
| 1666 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 1667 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 1668 | |
| 1669 | skip |= validate_bool32( |
| 1670 | report_data, "vkCreateGraphicsPipelines", |
| 1671 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 1672 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 1673 | |
| 1674 | skip |= validate_ranged_enum( |
| 1675 | report_data, "vkCreateGraphicsPipelines", |
| 1676 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 1677 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
| 1678 | VALIDATION_ERROR_0f604001); |
| 1679 | |
| 1680 | skip |= validate_bool32( |
| 1681 | report_data, "vkCreateGraphicsPipelines", |
| 1682 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 1683 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 1684 | |
| 1685 | skip |= validate_bool32( |
| 1686 | report_data, "vkCreateGraphicsPipelines", |
| 1687 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 1688 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 1689 | |
| 1690 | skip |= validate_ranged_enum( |
| 1691 | report_data, "vkCreateGraphicsPipelines", |
| 1692 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 1693 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
| 1694 | VALIDATION_ERROR_13a08601); |
| 1695 | |
| 1696 | skip |= validate_ranged_enum( |
| 1697 | report_data, "vkCreateGraphicsPipelines", |
| 1698 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 1699 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
| 1700 | VALIDATION_ERROR_13a27801); |
| 1701 | |
| 1702 | skip |= validate_ranged_enum( |
| 1703 | report_data, "vkCreateGraphicsPipelines", |
| 1704 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 1705 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
| 1706 | VALIDATION_ERROR_13a04201); |
| 1707 | |
| 1708 | skip |= validate_ranged_enum( |
| 1709 | report_data, "vkCreateGraphicsPipelines", |
| 1710 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 1711 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
| 1712 | VALIDATION_ERROR_0f604001); |
| 1713 | |
| 1714 | skip |= validate_ranged_enum( |
| 1715 | report_data, "vkCreateGraphicsPipelines", |
| 1716 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
| 1717 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
| 1718 | VALIDATION_ERROR_13a08601); |
| 1719 | |
| 1720 | skip |= validate_ranged_enum( |
| 1721 | report_data, "vkCreateGraphicsPipelines", |
| 1722 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
| 1723 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
| 1724 | VALIDATION_ERROR_13a27801); |
| 1725 | |
| 1726 | skip |= validate_ranged_enum( |
| 1727 | report_data, "vkCreateGraphicsPipelines", |
| 1728 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 1729 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
| 1730 | VALIDATION_ERROR_13a04201); |
| 1731 | |
| 1732 | skip |= validate_ranged_enum( |
| 1733 | report_data, "vkCreateGraphicsPipelines", |
| 1734 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 1735 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
| 1736 | VALIDATION_ERROR_0f604001); |
| 1737 | |
| 1738 | if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) { |
| 1739 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1740 | __LINE__, INVALID_STRUCT_STYPE, LayerName, |
| 1741 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 1742 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 1743 | i); |
| 1744 | } |
| 1745 | } |
| 1746 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 1747 | if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1748 | skip |= validate_struct_pnext( |
| 1749 | report_data, "vkCreateGraphicsPipelines", |
| 1750 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1751 | pCreateInfos[i].pColorBlendState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f41c40d); |
| 1752 | |
| 1753 | skip |= validate_reserved_flags( |
| 1754 | report_data, "vkCreateGraphicsPipelines", |
| 1755 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
| 1756 | pCreateInfos[i].pColorBlendState->flags, VALIDATION_ERROR_0f409005); |
| 1757 | |
| 1758 | skip |= validate_bool32( |
| 1759 | report_data, "vkCreateGraphicsPipelines", |
| 1760 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 1761 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 1762 | |
| 1763 | skip |= validate_array( |
| 1764 | report_data, "vkCreateGraphicsPipelines", |
| 1765 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 1766 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
| 1767 | pCreateInfos[i].pColorBlendState->attachmentCount, pCreateInfos[i].pColorBlendState->pAttachments, false, |
| 1768 | true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 1769 | |
| 1770 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
| 1771 | for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 1772 | ++attachmentIndex) { |
| 1773 | skip |= validate_bool32(report_data, "vkCreateGraphicsPipelines", |
| 1774 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
| 1775 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1776 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable); |
| 1777 | |
| 1778 | skip |= validate_ranged_enum( |
| 1779 | report_data, "vkCreateGraphicsPipelines", |
| 1780 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
| 1781 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1782 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1783 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor, |
| 1784 | VALIDATION_ERROR_0f22cc01); |
| 1785 | |
| 1786 | skip |= validate_ranged_enum( |
| 1787 | report_data, "vkCreateGraphicsPipelines", |
| 1788 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
| 1789 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1790 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1791 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor, |
| 1792 | VALIDATION_ERROR_0f207001); |
| 1793 | |
| 1794 | skip |= validate_ranged_enum( |
| 1795 | report_data, "vkCreateGraphicsPipelines", |
| 1796 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
| 1797 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1798 | "VkBlendOp", AllVkBlendOpEnums, |
| 1799 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp, |
| 1800 | VALIDATION_ERROR_0f202001); |
| 1801 | |
| 1802 | skip |= validate_ranged_enum( |
| 1803 | report_data, "vkCreateGraphicsPipelines", |
| 1804 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
| 1805 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1806 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1807 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor, |
| 1808 | VALIDATION_ERROR_0f22c601); |
| 1809 | |
| 1810 | skip |= validate_ranged_enum( |
| 1811 | report_data, "vkCreateGraphicsPipelines", |
| 1812 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
| 1813 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1814 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1815 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor, |
| 1816 | VALIDATION_ERROR_0f206a01); |
| 1817 | |
| 1818 | skip |= validate_ranged_enum( |
| 1819 | report_data, "vkCreateGraphicsPipelines", |
| 1820 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
| 1821 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1822 | "VkBlendOp", AllVkBlendOpEnums, |
| 1823 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp, |
| 1824 | VALIDATION_ERROR_0f200801); |
| 1825 | |
| 1826 | skip |= |
| 1827 | validate_flags(report_data, "vkCreateGraphicsPipelines", |
| 1828 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
| 1829 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1830 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
| 1831 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask, |
| 1832 | false, false, VALIDATION_ERROR_0f202201); |
| 1833 | } |
| 1834 | } |
| 1835 | |
| 1836 | if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) { |
| 1837 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1838 | __LINE__, INVALID_STRUCT_STYPE, LayerName, |
| 1839 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 1840 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 1841 | i); |
| 1842 | } |
| 1843 | |
| 1844 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 1845 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 1846 | skip |= validate_ranged_enum( |
| 1847 | report_data, "vkCreateGraphicsPipelines", |
| 1848 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
| 1849 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, VALIDATION_ERROR_0f4004be); |
| 1850 | } |
| 1851 | } |
| 1852 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1853 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 1854 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 1855 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 1856 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1857 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1858 | __LINE__, VALIDATION_ERROR_096005a8, LayerName, |
| 1859 | "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be " |
| 1860 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1861 | "and pCreateInfos->basePipelineIndex is not -1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1862 | } |
| 1863 | } |
| 1864 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 1865 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 1866 | if (pCreateInfos[i].basePipelineIndex != -1) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1867 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1868 | __LINE__, VALIDATION_ERROR_096005aa, LayerName, |
| 1869 | "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if " |
| 1870 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1871 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1872 | } |
| 1873 | } |
| 1874 | } |
| 1875 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 1876 | if (pCreateInfos[i].pRasterizationState) { |
| 1877 | if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1878 | (device_data->physical_device_features.fillModeNonSolid == false)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1879 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1880 | __LINE__, DEVICE_FEATURE, LayerName, |
| 1881 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 1882 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
| 1883 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1884 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1885 | |
| 1886 | if (!has_dynamic_line_width && !device_data->physical_device_features.wideLines && |
| 1887 | (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) { |
| 1888 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1889 | VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, 0, __LINE__, VALIDATION_ERROR_096005da, LayerName, |
| 1890 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 1891 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 1892 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1893 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
| 1894 | i, i, pCreateInfos[i].pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1895 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1896 | } |
| 1897 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1898 | for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) { |
| 1899 | skip |= validate_string(device_data->report_data, "vkCreateGraphicsPipelines", |
| 1900 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}), |
| 1901 | pCreateInfos[i].pStages[j].pName); |
| 1902 | } |
| 1903 | } |
| 1904 | } |
| 1905 | |
| 1906 | return skip; |
| 1907 | } |
| 1908 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1909 | bool pv_vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 1910 | const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 1911 | VkPipeline *pPipelines) { |
| 1912 | bool skip = false; |
| 1913 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1914 | |
| 1915 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 1916 | skip |= validate_string(device_data->report_data, "vkCreateComputePipelines", |
| 1917 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
| 1918 | pCreateInfos[i].stage.pName); |
| 1919 | } |
| 1920 | |
| 1921 | return skip; |
| 1922 | } |
| 1923 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1924 | bool pv_vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1925 | VkSampler *pSampler) { |
| 1926 | bool skip = false; |
| 1927 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1928 | debug_report_data *report_data = device_data->report_data; |
| 1929 | |
| 1930 | if (pCreateInfo != nullptr) { |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 1931 | const auto &features = device_data->physical_device_features; |
| 1932 | const auto &limits = device_data->device_limits; |
| 1933 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 1934 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
| 1935 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1936 | VALIDATION_ERROR_1260085e, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1937 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 1938 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1939 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 1940 | } |
| 1941 | |
| 1942 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 1943 | if (features.samplerAnisotropy == VK_FALSE) { |
| 1944 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1945 | VALIDATION_ERROR_1260085c, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1946 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 1947 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | // Anistropy and unnormalized coordinates cannot be enabled simultaneously |
| 1951 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 1952 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1953 | VALIDATION_ERROR_12600868, LayerName, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1954 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1955 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 1956 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1957 | } |
| 1958 | |
| 1959 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 1960 | if (pCreateInfo->compareEnable == VK_TRUE) { |
| 1961 | skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", |
| 1962 | AllVkCompareOpEnums, pCreateInfo->compareOp, VALIDATION_ERROR_12600870); |
| 1963 | } |
| 1964 | |
| 1965 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 1966 | // valid VkBorderColor value |
| 1967 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 1968 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 1969 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
| 1970 | skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", |
| 1971 | AllVkBorderColorEnums, pCreateInfo->borderColor, VALIDATION_ERROR_1260086c); |
| 1972 | } |
| 1973 | |
| 1974 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the |
| 1975 | // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled |
| 1976 | if (!device_data->extensions.vk_khr_sampler_mirror_clamp_to_edge && |
| 1977 | ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 1978 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 1979 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) { |
| 1980 | skip |= |
| 1981 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1982 | VALIDATION_ERROR_1260086e, LayerName, |
| 1983 | "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1984 | "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1985 | } |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 1986 | |
| 1987 | // Checks for the IMG cubic filtering extension |
| 1988 | if (device_data->extensions.vk_img_filter_cubic) { |
| 1989 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 1990 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1991 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1992 | VALIDATION_ERROR_12600872, LayerName, |
| 1993 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 1994 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 1995 | } |
| 1996 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1997 | } |
| 1998 | |
| 1999 | return skip; |
| 2000 | } |
| 2001 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2002 | bool pv_vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 2003 | const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) { |
| 2004 | bool skip = false; |
| 2005 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2006 | debug_report_data *report_data = device_data->report_data; |
| 2007 | |
| 2008 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2009 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 2010 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 2011 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
| 2012 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount |
| 2013 | // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount |
| 2014 | // valid VkSampler handles |
| 2015 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 2016 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 2017 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 2018 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 2019 | ++descriptor_index) { |
| 2020 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
| 2021 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2022 | __LINE__, REQUIRED_PARAMETER, LayerName, |
| 2023 | "vkCreateDescriptorSetLayout: required parameter " |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2024 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2025 | i, descriptor_index); |
| 2026 | } |
| 2027 | } |
| 2028 | } |
| 2029 | |
| 2030 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 2031 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 2032 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2033 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2034 | __LINE__, VALIDATION_ERROR_04e00236, LayerName, |
| 2035 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 2036 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2037 | "values.", |
| 2038 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2039 | } |
| 2040 | } |
| 2041 | } |
| 2042 | } |
| 2043 | |
| 2044 | return skip; |
| 2045 | } |
| 2046 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2047 | bool pv_vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 2048 | const VkDescriptorSet *pDescriptorSets) { |
| 2049 | bool skip = false; |
| 2050 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2051 | debug_report_data *report_data = device_data->report_data; |
| 2052 | |
| 2053 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2054 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 2055 | // validate_array() |
| 2056 | skip |= validate_array(report_data, "vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, |
| 2057 | pDescriptorSets, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 2058 | return skip; |
| 2059 | } |
| 2060 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2061 | bool pv_vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, |
| 2062 | uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) { |
| 2063 | bool skip = false; |
| 2064 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2065 | debug_report_data *report_data = device_data->report_data; |
| 2066 | |
| 2067 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2068 | if (pDescriptorWrites != NULL) { |
| 2069 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 2070 | // descriptorCount must be greater than 0 |
| 2071 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 2072 | skip |= |
| 2073 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2074 | VALIDATION_ERROR_15c0441b, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2075 | "vkUpdateDescriptorSets(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2076 | } |
| 2077 | |
| 2078 | // dstSet must be a valid VkDescriptorSet handle |
| 2079 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 2080 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 2081 | pDescriptorWrites[i].dstSet); |
| 2082 | |
| 2083 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 2084 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 2085 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 2086 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 2087 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 2088 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 2089 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, |
| 2090 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures |
| 2091 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
| 2092 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2093 | __LINE__, VALIDATION_ERROR_15c00284, LayerName, |
| 2094 | "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is " |
| 2095 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 2096 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2097 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.", |
| 2098 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2099 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 2100 | // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, |
| 2101 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout |
| 2102 | // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively |
| 2103 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 2104 | ++descriptor_index) { |
| 2105 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 2106 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView", |
| 2107 | ParameterName::IndexVector{i, descriptor_index}), |
| 2108 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageView); |
| 2109 | skip |= validate_ranged_enum(report_data, "vkUpdateDescriptorSets", |
| 2110 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 2111 | ParameterName::IndexVector{i, descriptor_index}), |
| 2112 | "VkImageLayout", AllVkImageLayoutEnums, |
| 2113 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, |
| 2114 | VALIDATION_ERROR_UNDEFINED); |
| 2115 | } |
| 2116 | } |
| 2117 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 2118 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 2119 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 2120 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 2121 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 2122 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 2123 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
| 2124 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
| 2125 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2126 | __LINE__, VALIDATION_ERROR_15c00288, LayerName, |
| 2127 | "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is " |
| 2128 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 2129 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2130 | "pDescriptorWrites[%d].pBufferInfo must not be NULL.", |
| 2131 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2132 | } else { |
| 2133 | for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) { |
| 2134 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 2135 | ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer", |
| 2136 | ParameterName::IndexVector{i, descriptorIndex}), |
| 2137 | pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer); |
| 2138 | } |
| 2139 | } |
| 2140 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 2141 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
| 2142 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, |
| 2143 | // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles |
| 2144 | if (pDescriptorWrites[i].pTexelBufferView == nullptr) { |
| 2145 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2146 | __LINE__, VALIDATION_ERROR_15c00286, LayerName, |
| 2147 | "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is " |
| 2148 | "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2149 | "pDescriptorWrites[%d].pTexelBufferView must not be NULL.", |
| 2150 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2151 | } else { |
| 2152 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 2153 | ++descriptor_index) { |
| 2154 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 2155 | ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]", |
| 2156 | ParameterName::IndexVector{i, descriptor_index}), |
| 2157 | pDescriptorWrites[i].pTexelBufferView[descriptor_index]); |
| 2158 | } |
| 2159 | } |
| 2160 | } |
| 2161 | |
| 2162 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 2163 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
| 2164 | VkDeviceSize uniformAlignment = device_data->device_limits.minUniformBufferOffsetAlignment; |
| 2165 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 2166 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 2167 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { |
| 2168 | skip |= log_msg( |
| 2169 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2170 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c0028e, LayerName, |
| 2171 | "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2172 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 2173 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2174 | } |
| 2175 | } |
| 2176 | } |
| 2177 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 2178 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 2179 | VkDeviceSize storageAlignment = device_data->device_limits.minStorageBufferOffsetAlignment; |
| 2180 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 2181 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 2182 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { |
| 2183 | skip |= log_msg( |
| 2184 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2185 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c00290, LayerName, |
| 2186 | "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2187 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 2188 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2189 | } |
| 2190 | } |
| 2191 | } |
| 2192 | } |
| 2193 | } |
| 2194 | } |
| 2195 | return skip; |
| 2196 | } |
| 2197 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2198 | bool pv_vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 2199 | VkRenderPass *pRenderPass) { |
| 2200 | bool skip = false; |
| 2201 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2202 | uint32_t max_color_attachments = device_data->device_limits.maxColorAttachments; |
| 2203 | |
| 2204 | for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) { |
| 2205 | if (pCreateInfo->pAttachments[i].format == VK_FORMAT_UNDEFINED) { |
| 2206 | std::stringstream ss; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2207 | ss << "vkCreateRenderPass: pCreateInfo->pAttachments[" << i << "].format is VK_FORMAT_UNDEFINED. "; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2208 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2209 | __LINE__, VALIDATION_ERROR_00809201, "IMAGE", "%s", ss.str().c_str()); |
| 2210 | } |
| 2211 | if (pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_UNDEFINED || |
| 2212 | pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) { |
| 2213 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2214 | __LINE__, VALIDATION_ERROR_00800696, "DL", |
| 2215 | "pCreateInfo->pAttachments[%d].finalLayout must not be VK_IMAGE_LAYOUT_UNDEFINED or " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2216 | "VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 2217 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2218 | } |
| 2219 | } |
| 2220 | |
| 2221 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 2222 | if (pCreateInfo->pSubpasses[i].colorAttachmentCount > max_color_attachments) { |
| 2223 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2224 | __LINE__, VALIDATION_ERROR_1400069a, "DL", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2225 | "Cannot create a render pass with %d color attachments. Max is %d.", |
| 2226 | pCreateInfo->pSubpasses[i].colorAttachmentCount, max_color_attachments); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2227 | } |
| 2228 | } |
| 2229 | return skip; |
| 2230 | } |
| 2231 | |
| 2232 | bool pv_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 2233 | const VkCommandBuffer *pCommandBuffers) { |
| 2234 | bool skip = false; |
| 2235 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2236 | debug_report_data *report_data = device_data->report_data; |
| 2237 | |
| 2238 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2239 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 2240 | // validate_array() |
| 2241 | skip |= validate_array(report_data, "vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, |
| 2242 | pCommandBuffers, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 2243 | return skip; |
| 2244 | } |
| 2245 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2246 | bool pv_vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo) { |
| 2247 | bool skip = false; |
| 2248 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2249 | debug_report_data *report_data = device_data->report_data; |
| 2250 | const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo; |
| 2251 | |
| 2252 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2253 | // TODO: pBeginInfo->pInheritanceInfo must not be NULL if commandBuffer is a secondary command buffer |
| 2254 | skip |= validate_struct_type(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo", |
| 2255 | "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", pBeginInfo->pInheritanceInfo, |
| 2256 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, false, VALIDATION_ERROR_UNDEFINED); |
| 2257 | |
| 2258 | if (pBeginInfo->pInheritanceInfo != NULL) { |
| 2259 | skip |= |
| 2260 | validate_struct_pnext(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pNext", NULL, |
| 2261 | pBeginInfo->pInheritanceInfo->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0281c40d); |
| 2262 | |
| 2263 | skip |= validate_bool32(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", |
| 2264 | pBeginInfo->pInheritanceInfo->occlusionQueryEnable); |
| 2265 | |
| 2266 | // TODO: This only needs to be validated when the inherited queries feature is enabled |
| 2267 | // skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags", |
| 2268 | // "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pBeginInfo->pInheritanceInfo->queryFlags, false); |
| 2269 | |
| 2270 | // TODO: This must be 0 if the pipeline statistics queries feature is not enabled |
| 2271 | skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pipelineStatistics", |
| 2272 | "VkQueryPipelineStatisticFlagBits", AllVkQueryPipelineStatisticFlagBits, |
| 2273 | pBeginInfo->pInheritanceInfo->pipelineStatistics, false, false, VALIDATION_ERROR_UNDEFINED); |
| 2274 | } |
| 2275 | |
| 2276 | if (pInfo != NULL) { |
| 2277 | if ((device_data->physical_device_features.inheritedQueries == VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) { |
| 2278 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2279 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_02a00070, LayerName, |
| 2280 | "Cannot set inherited occlusionQueryEnable in vkBeginCommandBuffer() when device does not support " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2281 | "inheritedQueries."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2282 | } |
| 2283 | if ((device_data->physical_device_features.inheritedQueries != VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) { |
| 2284 | skip |= validate_flags(device_data->report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags", |
| 2285 | "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pInfo->queryFlags, false, false, |
| 2286 | VALIDATION_ERROR_02a00072); |
| 2287 | } |
| 2288 | } |
| 2289 | |
| 2290 | return skip; |
| 2291 | } |
| 2292 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2293 | bool pv_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
| 2294 | const VkViewport *pViewports) { |
| 2295 | bool skip = false; |
| 2296 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2297 | |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 2298 | if (!device_data->physical_device_features.multiViewport) { |
| 2299 | if (firstViewport != 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2300 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2301 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1e000990, LayerName, |
| 2302 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 2303 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 2304 | } |
| 2305 | if (viewportCount > 1) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2306 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2307 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1e000992, LayerName, |
| 2308 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 2309 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 2310 | } |
| 2311 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 2312 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 2313 | if (sum > device_data->device_limits.maxViewports) { |
| 2314 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2315 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1e00098e, LayerName, |
| 2316 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2317 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2318 | firstViewport, viewportCount, sum, device_data->device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2319 | } |
| 2320 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2321 | |
| 2322 | if (pViewports) { |
| 2323 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 2324 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
| 2325 | const char fn_name[] = "vkCmdSetViewport"; |
| 2326 | const std::string param_name = "pViewports[" + std::to_string(viewport_i) + "]"; |
| 2327 | skip |= pv_VkViewport(device_data, viewport, fn_name, param_name.c_str(), |
| 2328 | VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer)); |
| 2329 | } |
| 2330 | } |
| 2331 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2332 | return skip; |
| 2333 | } |
| 2334 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2335 | bool pv_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors) { |
| 2336 | bool skip = false; |
| 2337 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2338 | debug_report_data *report_data = device_data->report_data; |
| 2339 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2340 | if (!device_data->physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2341 | if (firstScissor != 0) { |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2342 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2343 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a2, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2344 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 2345 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2346 | } |
| 2347 | if (scissorCount > 1) { |
| 2348 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2349 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a4, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2350 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 2351 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2352 | } |
| 2353 | } else { // multiViewport enabled |
| 2354 | const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount); |
| 2355 | if (sum > device_data->device_limits.maxViewports) { |
| 2356 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2357 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a0, LayerName, |
| 2358 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2359 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2360 | firstScissor, scissorCount, sum, device_data->device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2361 | } |
| 2362 | } |
| 2363 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2364 | if (pScissors) { |
| 2365 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 2366 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2367 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2368 | if (scissor.offset.x < 0) { |
| 2369 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2370 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a6, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2371 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 2372 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2373 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2374 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2375 | if (scissor.offset.y < 0) { |
| 2376 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2377 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a6, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2378 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 2379 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2380 | } |
| 2381 | |
| 2382 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 2383 | if (x_sum > INT32_MAX) { |
| 2384 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2385 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004a8, LayerName, |
| 2386 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2387 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 2388 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2389 | } |
| 2390 | |
| 2391 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 2392 | if (y_sum > INT32_MAX) { |
| 2393 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2394 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d8004aa, LayerName, |
| 2395 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2396 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 2397 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2398 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2399 | } |
| 2400 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2401 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2402 | return skip; |
| 2403 | } |
| 2404 | |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2405 | bool pv_vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) { |
| 2406 | bool skip = false; |
| 2407 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2408 | debug_report_data *report_data = device_data->report_data; |
| 2409 | |
| 2410 | if (!device_data->physical_device_features.wideLines && (lineWidth != 1.0f)) { |
| 2411 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2412 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d600628, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2413 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2414 | } |
| 2415 | |
| 2416 | return skip; |
| 2417 | } |
| 2418 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2419 | bool pv_vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
| 2420 | uint32_t firstInstance) { |
| 2421 | bool skip = false; |
| 2422 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2423 | if (vertexCount == 0) { |
| 2424 | // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make |
| 2425 | // this an error or leave as is. |
| 2426 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2427 | __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t vertexCount, is 0"); |
| 2428 | } |
| 2429 | |
| 2430 | if (instanceCount == 0) { |
| 2431 | // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make |
| 2432 | // this an error or leave as is. |
| 2433 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2434 | __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t instanceCount, is 0"); |
| 2435 | } |
| 2436 | return skip; |
| 2437 | } |
| 2438 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2439 | bool pv_vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) { |
| 2440 | bool skip = false; |
| 2441 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2442 | |
| 2443 | if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) { |
| 2444 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2445 | __LINE__, DEVICE_FEATURE, LayerName, |
| 2446 | "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count); |
| 2447 | } |
| 2448 | return skip; |
| 2449 | } |
| 2450 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2451 | bool pv_vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, |
| 2452 | uint32_t stride) { |
| 2453 | bool skip = false; |
| 2454 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2455 | if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) { |
| 2456 | skip |= |
| 2457 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2458 | DEVICE_FEATURE, LayerName, |
| 2459 | "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count); |
| 2460 | } |
| 2461 | return skip; |
| 2462 | } |
| 2463 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2464 | bool pv_vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 2465 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) { |
| 2466 | bool skip = false; |
| 2467 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2468 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2469 | VkImageAspectFlags legal_aspect_flags = |
| 2470 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
| 2471 | if (device_data->extensions.vk_khr_sampler_ycbcr_conversion) { |
| 2472 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2473 | } |
| 2474 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2475 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2476 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2477 | skip |= log_msg( |
| 2478 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2479 | VALIDATION_ERROR_0a600c01, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2480 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2481 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2482 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2483 | skip |= log_msg( |
| 2484 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2485 | VALIDATION_ERROR_0a600c01, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2486 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2487 | } |
| 2488 | } |
| 2489 | return skip; |
| 2490 | } |
| 2491 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2492 | bool pv_vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 2493 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) { |
| 2494 | bool skip = false; |
| 2495 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2496 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2497 | VkImageAspectFlags legal_aspect_flags = |
| 2498 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
| 2499 | if (device_data->extensions.vk_khr_sampler_ycbcr_conversion) { |
| 2500 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2501 | } |
| 2502 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2503 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2504 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2505 | skip |= log_msg( |
| 2506 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2507 | UNRECOGNIZED_VALUE, LayerName, |
| 2508 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator"); |
| 2509 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2510 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2511 | skip |= log_msg( |
| 2512 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2513 | UNRECOGNIZED_VALUE, LayerName, |
| 2514 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator"); |
| 2515 | } |
| 2516 | } |
| 2517 | return skip; |
| 2518 | } |
| 2519 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2520 | bool pv_vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, |
| 2521 | uint32_t regionCount, const VkBufferImageCopy *pRegions) { |
| 2522 | bool skip = false; |
| 2523 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2524 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2525 | VkImageAspectFlags legal_aspect_flags = |
| 2526 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
| 2527 | if (device_data->extensions.vk_khr_sampler_ycbcr_conversion) { |
| 2528 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2529 | } |
| 2530 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2531 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2532 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2533 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2534 | __LINE__, UNRECOGNIZED_VALUE, LayerName, |
| 2535 | "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an " |
| 2536 | "unrecognized enumerator"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2537 | } |
| 2538 | } |
| 2539 | return skip; |
| 2540 | } |
| 2541 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2542 | bool pv_vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, |
| 2543 | uint32_t regionCount, const VkBufferImageCopy *pRegions) { |
| 2544 | bool skip = false; |
| 2545 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2546 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2547 | VkImageAspectFlags legal_aspect_flags = |
| 2548 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
| 2549 | if (device_data->extensions.vk_khr_sampler_ycbcr_conversion) { |
| 2550 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2551 | } |
| 2552 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2553 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2554 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2555 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2556 | UNRECOGNIZED_VALUE, LayerName, |
| 2557 | "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized " |
| 2558 | "enumerator"); |
| 2559 | } |
| 2560 | } |
| 2561 | return skip; |
| 2562 | } |
| 2563 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2564 | bool pv_vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 2565 | const void *pData) { |
| 2566 | bool skip = false; |
| 2567 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2568 | |
| 2569 | if (dstOffset & 3) { |
| 2570 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2571 | __LINE__, VALIDATION_ERROR_1e400048, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2572 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 2573 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2574 | } |
| 2575 | |
| 2576 | if ((dataSize <= 0) || (dataSize > 65536)) { |
| 2577 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2578 | __LINE__, VALIDATION_ERROR_1e40004a, LayerName, |
| 2579 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2580 | "), must be greater than zero and less than or equal to 65536.", |
| 2581 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2582 | } else if (dataSize & 3) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2583 | skip |= |
| 2584 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2585 | VALIDATION_ERROR_1e40004c, LayerName, |
| 2586 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2587 | } |
| 2588 | return skip; |
| 2589 | } |
| 2590 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2591 | bool pv_vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
| 2592 | uint32_t data) { |
| 2593 | bool skip = false; |
| 2594 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2595 | |
| 2596 | if (dstOffset & 3) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2597 | skip |= |
| 2598 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2599 | VALIDATION_ERROR_1b400032, LayerName, |
| 2600 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2601 | } |
| 2602 | |
| 2603 | if (size != VK_WHOLE_SIZE) { |
| 2604 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2605 | skip |= |
| 2606 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2607 | __LINE__, VALIDATION_ERROR_1b400034, LayerName, |
| 2608 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2609 | } else if (size & 3) { |
| 2610 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2611 | __LINE__, VALIDATION_ERROR_1b400038, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2612 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2613 | } |
| 2614 | } |
| 2615 | return skip; |
| 2616 | } |
| 2617 | |
| 2618 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { |
| 2619 | return util_GetLayerProperties(1, &global_layer, pCount, pProperties); |
| 2620 | } |
| 2621 | |
| 2622 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 2623 | VkLayerProperties *pProperties) { |
| 2624 | return util_GetLayerProperties(1, &global_layer, pCount, pProperties); |
| 2625 | } |
| 2626 | |
| 2627 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 2628 | VkExtensionProperties *pProperties) { |
| 2629 | if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) |
| 2630 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
| 2631 | |
| 2632 | return VK_ERROR_LAYER_NOT_PRESENT; |
| 2633 | } |
| 2634 | |
| 2635 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, |
| 2636 | uint32_t *pPropertyCount, VkExtensionProperties *pProperties) { |
| 2637 | // Parameter_validation does not have any physical device extensions |
| 2638 | if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) |
| 2639 | return util_GetExtensionProperties(0, NULL, pPropertyCount, pProperties); |
| 2640 | |
| 2641 | instance_layer_data *local_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map); |
| 2642 | bool skip = |
| 2643 | validate_array(local_data->report_data, "vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", |
| 2644 | pPropertyCount, pProperties, true, false, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_2761f401); |
| 2645 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 2646 | |
| 2647 | return local_data->dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pPropertyCount, pProperties); |
| 2648 | } |
| 2649 | |
| 2650 | static bool require_device_extension(layer_data *device_data, bool flag, char const *function_name, char const *extension_name) { |
| 2651 | if (!flag) { |
| 2652 | return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2653 | __LINE__, EXTENSION_NOT_ENABLED, LayerName, |
| 2654 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 2655 | extension_name); |
| 2656 | } |
| 2657 | |
| 2658 | return false; |
| 2659 | } |
| 2660 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2661 | bool pv_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 2662 | VkSwapchainKHR *pSwapchain) { |
| 2663 | bool skip = false; |
| 2664 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2665 | debug_report_data *report_data = device_data->report_data; |
| 2666 | |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 2667 | const LogMiscParams log_misc{report_data, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, VK_NULL_HANDLE, LayerName, |
| 2668 | "vkCreateSwapchainKHR"}; |
| 2669 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2670 | if (pCreateInfo != nullptr) { |
| 2671 | if ((device_data->physical_device_features.textureCompressionETC2 == false) && |
| 2672 | FormatIsCompressed_ETC2_EAC(pCreateInfo->imageFormat)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2673 | skip |= |
| 2674 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2675 | DEVICE_FEATURE, LayerName, |
| 2676 | "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The textureCompressionETC2 " |
| 2677 | "feature is not enabled: neither ETC2 nor EAC formats can be used to create images.", |
| 2678 | string_VkFormat(pCreateInfo->imageFormat)); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2679 | } |
| 2680 | |
| 2681 | if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) && |
| 2682 | FormatIsCompressed_ASTC_LDR(pCreateInfo->imageFormat)) { |
| 2683 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2684 | DEVICE_FEATURE, LayerName, |
| 2685 | "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The " |
| 2686 | "textureCompressionASTC_LDR feature is not enabled: ASTC formats cannot be used to create images.", |
| 2687 | string_VkFormat(pCreateInfo->imageFormat)); |
| 2688 | } |
| 2689 | |
| 2690 | if ((device_data->physical_device_features.textureCompressionBC == false) && |
| 2691 | FormatIsCompressed_BC(pCreateInfo->imageFormat)) { |
| 2692 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2693 | DEVICE_FEATURE, LayerName, |
| 2694 | "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The " |
| 2695 | "textureCompressionBC feature is not enabled: BC compressed formats cannot be used to create images.", |
| 2696 | string_VkFormat(pCreateInfo->imageFormat)); |
| 2697 | } |
| 2698 | |
| 2699 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2700 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 2701 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 2702 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
| 2703 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2704 | VALIDATION_ERROR_146009fc, LayerName, |
| 2705 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2706 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2707 | } |
| 2708 | |
| 2709 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 2710 | // queueFamilyIndexCount uint32_t values |
| 2711 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
| 2712 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2713 | VALIDATION_ERROR_146009fa, LayerName, |
| 2714 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 2715 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2716 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2717 | } else { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2718 | skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices, |
| 2719 | "vkCreateSwapchainKHR", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2720 | INVALID_USAGE, false); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2721 | } |
| 2722 | } |
| 2723 | |
Petr Kraus | e5c3765 | 2018-01-05 04:05:12 +0100 | [diff] [blame] | 2724 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", VALIDATION_ERROR_146009f6, |
| 2725 | log_misc); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2726 | } |
| 2727 | |
| 2728 | return skip; |
| 2729 | } |
| 2730 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2731 | bool pv_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { |
| 2732 | bool skip = false; |
| 2733 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 2734 | |
| 2735 | if (pPresentInfo && pPresentInfo->pNext) { |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 2736 | const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
| 2737 | if (present_regions) { |
| 2738 | // TODO: This and all other pNext extension dependencies should be added to code-generation |
| 2739 | skip |= require_device_extension(device_data, device_data->extensions.vk_khr_incremental_present, "vkQueuePresentKHR", |
| 2740 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 2741 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
| 2742 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2743 | __LINE__, INVALID_USAGE, LayerName, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2744 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 2745 | "extension swapchainCount is %i. These values must be equal.", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 2746 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
| 2747 | } |
| 2748 | skip |= validate_struct_pnext(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, |
| 2749 | present_regions->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_1121c40d); |
| 2750 | skip |= validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", |
| 2751 | "pCreateInfo->pNext->pRegions", present_regions->swapchainCount, present_regions->pRegions, true, |
| 2752 | false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 2753 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
| 2754 | skip |= validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2755 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
| 2756 | present_regions->pRegions[i].pRectangles, true, false, VALIDATION_ERROR_UNDEFINED, |
| 2757 | VALIDATION_ERROR_UNDEFINED); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2758 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2759 | } |
| 2760 | } |
| 2761 | |
| 2762 | return skip; |
| 2763 | } |
| 2764 | |
| 2765 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2766 | bool pv_vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 2767 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
| 2768 | auto device_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 2769 | bool skip = false; |
| 2770 | |
| 2771 | if (pCreateInfo->hwnd == nullptr) { |
| 2772 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2773 | __LINE__, VALIDATION_ERROR_15a00a38, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2774 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2775 | } |
| 2776 | |
| 2777 | return skip; |
| 2778 | } |
| 2779 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 2780 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2781 | bool pv_vkDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
| 2782 | auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2783 | if (pNameInfo->pObjectName) { |
| 2784 | device_data->report_data->debugObjectNameMap->insert( |
| 2785 | std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName)); |
| 2786 | } else { |
| 2787 | device_data->report_data->debugObjectNameMap->erase(pNameInfo->object); |
| 2788 | } |
| 2789 | return false; |
| 2790 | } |
| 2791 | |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2792 | bool pv_vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
| 2793 | const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool) { |
| 2794 | auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2795 | bool skip = false; |
| 2796 | |
| 2797 | if (pCreateInfo) { |
| 2798 | if (pCreateInfo->maxSets <= 0) { |
| 2799 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2800 | VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_0480025a, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2801 | LayerName, "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2802 | } |
| 2803 | |
| 2804 | if (pCreateInfo->pPoolSizes) { |
| 2805 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 2806 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
| 2807 | skip |= log_msg( |
| 2808 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, |
| 2809 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_04a0025c, LayerName, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2810 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2811 | } |
| 2812 | } |
| 2813 | } |
| 2814 | } |
| 2815 | |
| 2816 | return skip; |
| 2817 | } |
| 2818 | |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2819 | bool pv_vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) { |
| 2820 | bool skip = false; |
| 2821 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2822 | |
| 2823 | if (groupCountX > device_data->device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2824 | skip |= |
| 2825 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2826 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19c00304, LayerName, |
| 2827 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 2828 | groupCountX, device_data->device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2829 | } |
| 2830 | |
| 2831 | if (groupCountY > device_data->device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2832 | skip |= |
| 2833 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2834 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19c00306, LayerName, |
| 2835 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 2836 | groupCountY, device_data->device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2837 | } |
| 2838 | |
| 2839 | if (groupCountZ > device_data->device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2840 | skip |= |
| 2841 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2842 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19c00308, LayerName, |
| 2843 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 2844 | groupCountZ, device_data->device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2845 | } |
| 2846 | |
| 2847 | return skip; |
| 2848 | } |
| 2849 | |
Mark Lobodzinski | bf973a1 | 2018-03-01 08:50:21 -0700 | [diff] [blame] | 2850 | bool pv_vkCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2851 | uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) { |
| 2852 | bool skip = false; |
| 2853 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2854 | |
| 2855 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
| 2856 | uint32_t limit = device_data->device_limits.maxComputeWorkGroupCount[0]; |
| 2857 | if (baseGroupX >= limit) { |
| 2858 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2859 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19e0034a, LayerName, |
| 2860 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2861 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 2862 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2863 | } else if (groupCountX > (limit - baseGroupX)) { |
| 2864 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2865 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19e00350, LayerName, |
Mark Lobodzinski | bf973a1 | 2018-03-01 08:50:21 -0700 | [diff] [blame] | 2866 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2867 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 2868 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2869 | } |
| 2870 | |
| 2871 | limit = device_data->device_limits.maxComputeWorkGroupCount[1]; |
| 2872 | if (baseGroupY >= limit) { |
| 2873 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2874 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19e0034c, LayerName, |
| 2875 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2876 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 2877 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2878 | } else if (groupCountY > (limit - baseGroupY)) { |
| 2879 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2880 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19e00352, LayerName, |
Mark Lobodzinski | bf973a1 | 2018-03-01 08:50:21 -0700 | [diff] [blame] | 2881 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2882 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 2883 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2884 | } |
| 2885 | |
| 2886 | limit = device_data->device_limits.maxComputeWorkGroupCount[2]; |
| 2887 | if (baseGroupZ >= limit) { |
| 2888 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2889 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19e0034e, LayerName, |
| 2890 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2891 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 2892 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2893 | } else if (groupCountZ > (limit - baseGroupZ)) { |
| 2894 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2895 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_19e00354, LayerName, |
Mark Lobodzinski | bf973a1 | 2018-03-01 08:50:21 -0700 | [diff] [blame] | 2896 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame^] | 2897 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 2898 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 2899 | } |
| 2900 | |
| 2901 | return skip; |
| 2902 | } |
| 2903 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2904 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *funcName) { |
| 2905 | const auto item = name_to_funcptr_map.find(funcName); |
| 2906 | if (item != name_to_funcptr_map.end()) { |
| 2907 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 2908 | } |
| 2909 | |
| 2910 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2911 | const auto &table = device_data->dispatch_table; |
| 2912 | if (!table.GetDeviceProcAddr) return nullptr; |
| 2913 | return table.GetDeviceProcAddr(device, funcName); |
| 2914 | } |
| 2915 | |
| 2916 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 2917 | const auto item = name_to_funcptr_map.find(funcName); |
| 2918 | if (item != name_to_funcptr_map.end()) { |
| 2919 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 2920 | } |
| 2921 | |
| 2922 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 2923 | auto &table = instance_data->dispatch_table; |
| 2924 | if (!table.GetInstanceProcAddr) return nullptr; |
| 2925 | return table.GetInstanceProcAddr(instance, funcName); |
| 2926 | } |
| 2927 | |
| 2928 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { |
| 2929 | assert(instance); |
| 2930 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 2931 | |
| 2932 | if (!instance_data->dispatch_table.GetPhysicalDeviceProcAddr) return nullptr; |
| 2933 | return instance_data->dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); |
| 2934 | } |
| 2935 | |
| 2936 | // If additional validation is needed outside of the generated checks, a manual routine can be added to this file |
| 2937 | // and the address filled in here. The autogenerated source will call these routines if the pointers are not NULL. |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2938 | void InitializeManualParameterValidationFunctionPointers() { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2939 | custom_functions["vkGetDeviceQueue"] = (void *)pv_vkGetDeviceQueue; |
| 2940 | custom_functions["vkCreateBuffer"] = (void *)pv_vkCreateBuffer; |
| 2941 | custom_functions["vkCreateImage"] = (void *)pv_vkCreateImage; |
| 2942 | custom_functions["vkCreateImageView"] = (void *)pv_vkCreateImageView; |
| 2943 | custom_functions["vkCreateGraphicsPipelines"] = (void *)pv_vkCreateGraphicsPipelines; |
| 2944 | custom_functions["vkCreateComputePipelines"] = (void *)pv_vkCreateComputePipelines; |
| 2945 | custom_functions["vkCreateSampler"] = (void *)pv_vkCreateSampler; |
| 2946 | custom_functions["vkCreateDescriptorSetLayout"] = (void *)pv_vkCreateDescriptorSetLayout; |
| 2947 | custom_functions["vkFreeDescriptorSets"] = (void *)pv_vkFreeDescriptorSets; |
| 2948 | custom_functions["vkUpdateDescriptorSets"] = (void *)pv_vkUpdateDescriptorSets; |
| 2949 | custom_functions["vkCreateRenderPass"] = (void *)pv_vkCreateRenderPass; |
| 2950 | custom_functions["vkBeginCommandBuffer"] = (void *)pv_vkBeginCommandBuffer; |
| 2951 | custom_functions["vkCmdSetViewport"] = (void *)pv_vkCmdSetViewport; |
| 2952 | custom_functions["vkCmdSetScissor"] = (void *)pv_vkCmdSetScissor; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2953 | custom_functions["vkCmdSetLineWidth"] = (void *)pv_vkCmdSetLineWidth; |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2954 | custom_functions["vkCmdDraw"] = (void *)pv_vkCmdDraw; |
| 2955 | custom_functions["vkCmdDrawIndirect"] = (void *)pv_vkCmdDrawIndirect; |
| 2956 | custom_functions["vkCmdDrawIndexedIndirect"] = (void *)pv_vkCmdDrawIndexedIndirect; |
| 2957 | custom_functions["vkCmdCopyImage"] = (void *)pv_vkCmdCopyImage; |
| 2958 | custom_functions["vkCmdBlitImage"] = (void *)pv_vkCmdBlitImage; |
| 2959 | custom_functions["vkCmdCopyBufferToImage"] = (void *)pv_vkCmdCopyBufferToImage; |
| 2960 | custom_functions["vkCmdCopyImageToBuffer"] = (void *)pv_vkCmdCopyImageToBuffer; |
| 2961 | custom_functions["vkCmdUpdateBuffer"] = (void *)pv_vkCmdUpdateBuffer; |
| 2962 | custom_functions["vkCmdFillBuffer"] = (void *)pv_vkCmdFillBuffer; |
| 2963 | custom_functions["vkCreateSwapchainKHR"] = (void *)pv_vkCreateSwapchainKHR; |
| 2964 | custom_functions["vkQueuePresentKHR"] = (void *)pv_vkQueuePresentKHR; |
| 2965 | custom_functions["vkCreateDescriptorPool"] = (void *)pv_vkCreateDescriptorPool; |
| 2966 | custom_functions["vkCmdDispatch"] = (void *)pv_vkCmdDispatch; |
Mark Lobodzinski | bf973a1 | 2018-03-01 08:50:21 -0700 | [diff] [blame] | 2967 | custom_functions["vkCmdDispatchBaseKHR"] = (void *)pv_vkCmdDispatchBaseKHR; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2968 | } |
| 2969 | |
| 2970 | } // namespace parameter_validation |
| 2971 | |
| 2972 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 2973 | VkExtensionProperties *pProperties) { |
| 2974 | return parameter_validation::vkEnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties); |
| 2975 | } |
| 2976 | |
| 2977 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, |
| 2978 | VkLayerProperties *pProperties) { |
| 2979 | return parameter_validation::vkEnumerateInstanceLayerProperties(pCount, pProperties); |
| 2980 | } |
| 2981 | |
| 2982 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 2983 | VkLayerProperties *pProperties) { |
| 2984 | // the layer command handles VK_NULL_HANDLE just fine internally |
| 2985 | assert(physicalDevice == VK_NULL_HANDLE); |
| 2986 | return parameter_validation::vkEnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties); |
| 2987 | } |
| 2988 | |
| 2989 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 2990 | const char *pLayerName, uint32_t *pCount, |
| 2991 | VkExtensionProperties *pProperties) { |
| 2992 | // the layer command handles VK_NULL_HANDLE just fine internally |
| 2993 | assert(physicalDevice == VK_NULL_HANDLE); |
| 2994 | return parameter_validation::vkEnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties); |
| 2995 | } |
| 2996 | |
| 2997 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { |
| 2998 | return parameter_validation::vkGetDeviceProcAddr(dev, funcName); |
| 2999 | } |
| 3000 | |
| 3001 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 3002 | return parameter_validation::vkGetInstanceProcAddr(instance, funcName); |
| 3003 | } |
| 3004 | |
| 3005 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, |
| 3006 | const char *funcName) { |
| 3007 | return parameter_validation::vkGetPhysicalDeviceProcAddr(instance, funcName); |
| 3008 | } |
| 3009 | |
| 3010 | VK_LAYER_EXPORT bool pv_vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) { |
| 3011 | assert(pVersionStruct != NULL); |
| 3012 | assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT); |
| 3013 | |
| 3014 | // Fill in the function pointers if our version is at least capable of having the structure contain them. |
| 3015 | if (pVersionStruct->loaderLayerInterfaceVersion >= 2) { |
| 3016 | pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr; |
| 3017 | pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr; |
| 3018 | pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr; |
| 3019 | } |
| 3020 | |
| 3021 | if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 3022 | parameter_validation::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion; |
| 3023 | } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 3024 | pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 3025 | } |
| 3026 | |
| 3027 | return VK_SUCCESS; |
| 3028 | } |