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> |
| 28 | #include <inttypes.h> |
| 29 | |
| 30 | #include <iostream> |
| 31 | #include <string> |
| 32 | #include <sstream> |
| 33 | #include <unordered_map> |
| 34 | #include <unordered_set> |
| 35 | #include <vector> |
| 36 | #include <mutex> |
| 37 | |
| 38 | #include "vk_loader_platform.h" |
| 39 | #include "vulkan/vk_layer.h" |
| 40 | #include "vk_layer_config.h" |
| 41 | #include "vk_dispatch_table_helper.h" |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 42 | #include "vk_typemap_helper.h" |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 43 | |
| 44 | #include "vk_layer_table.h" |
| 45 | #include "vk_layer_data.h" |
| 46 | #include "vk_layer_logging.h" |
| 47 | #include "vk_layer_extension_utils.h" |
| 48 | #include "vk_layer_utils.h" |
| 49 | |
| 50 | #include "parameter_name.h" |
| 51 | #include "parameter_validation.h" |
| 52 | |
| 53 | // TODO: remove on NDK update (r15 will probably have proper STL impl) |
| 54 | #ifdef __ANDROID__ |
| 55 | namespace std { |
| 56 | |
| 57 | template <typename T> |
| 58 | std::string to_string(T var) { |
| 59 | std::ostringstream ss; |
| 60 | ss << var; |
| 61 | return ss.str(); |
| 62 | } |
| 63 | } // namespace std |
| 64 | #endif |
| 65 | |
| 66 | namespace parameter_validation { |
| 67 | |
Mark Lobodzinski | 78a12a9 | 2017-08-08 14:16:51 -0600 | [diff] [blame] | 68 | extern std::unordered_map<std::string, void *> custom_functions; |
| 69 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 70 | extern bool parameter_validation_vkCreateInstance(VkInstance instance, const VkInstanceCreateInfo *pCreateInfo, |
| 71 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance); |
| 72 | extern bool parameter_validation_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator); |
| 73 | extern bool parameter_validation_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 74 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice); |
| 75 | extern bool parameter_validation_vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator); |
| 76 | extern bool parameter_validation_vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
| 77 | const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool); |
| 78 | extern bool parameter_validation_vkCreateDebugReportCallbackEXT(VkInstance instance, |
| 79 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 80 | const VkAllocationCallbacks *pAllocator, |
| 81 | VkDebugReportCallbackEXT *pMsgCallback); |
| 82 | extern bool parameter_validation_vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 83 | const VkAllocationCallbacks *pAllocator); |
| 84 | extern bool parameter_validation_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, |
| 85 | const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool); |
| 86 | |
| 87 | // TODO : This can be much smarter, using separate locks for separate global data |
| 88 | std::mutex global_lock; |
| 89 | |
| 90 | static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 91 | std::unordered_map<void *, layer_data *> layer_data_map; |
| 92 | std::unordered_map<void *, instance_layer_data *> instance_layer_data_map; |
| 93 | |
| 94 | void InitializeManualParameterValidationFunctionPointers(void); |
| 95 | |
| 96 | static void init_parameter_validation(instance_layer_data *instance_data, const VkAllocationCallbacks *pAllocator) { |
| 97 | layer_debug_actions(instance_data->report_data, instance_data->logging_callback, pAllocator, "lunarg_parameter_validation"); |
| 98 | } |
| 99 | |
| 100 | static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}}; |
| 101 | |
| 102 | static const VkLayerProperties global_layer = { |
| 103 | "VK_LAYER_LUNARG_parameter_validation", VK_LAYER_API_VERSION, 1, "LunarG Validation Layer", |
| 104 | }; |
| 105 | |
| 106 | static const int MaxParamCheckerStringLength = 256; |
| 107 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 108 | template <typename T> |
| 109 | static inline bool in_inclusive_range(const T &value, const T &min, const T &max) { |
| 110 | // Using only < for generality and || for early abort |
| 111 | return !((value < min) || (max < value)); |
| 112 | } |
| 113 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 114 | static bool validate_string(debug_report_data *report_data, const char *apiName, const ParameterName &stringName, |
| 115 | const char *validateString) { |
| 116 | assert(apiName != nullptr); |
| 117 | assert(validateString != nullptr); |
| 118 | |
| 119 | bool skip = false; |
| 120 | |
| 121 | VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString); |
| 122 | |
| 123 | if (result == VK_STRING_ERROR_NONE) { |
| 124 | return skip; |
| 125 | } else if (result & VK_STRING_ERROR_LENGTH) { |
| 126 | skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 127 | INVALID_USAGE, LayerName, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), |
| 128 | MaxParamCheckerStringLength); |
| 129 | } else if (result & VK_STRING_ERROR_BAD_DATA) { |
| 130 | skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 131 | INVALID_USAGE, LayerName, "%s: string %s contains invalid characters or is badly formed", apiName, |
| 132 | stringName.get_name().c_str()); |
| 133 | } |
| 134 | return skip; |
| 135 | } |
| 136 | |
| 137 | static bool ValidateDeviceQueueFamily(layer_data *device_data, uint32_t queue_family, const char *cmd_name, |
| 138 | const char *parameter_name, int32_t error_code, bool optional = false, |
| 139 | const char *vu_note = nullptr) { |
| 140 | bool skip = false; |
| 141 | |
| 142 | if (!vu_note) vu_note = validation_error_map[error_code]; |
| 143 | if (!optional && queue_family == VK_QUEUE_FAMILY_IGNORED) { |
| 144 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 145 | HandleToUint64(device_data->device), __LINE__, error_code, LayerName, |
| 146 | "%s: %s is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value. %s", |
| 147 | cmd_name, parameter_name, vu_note); |
| 148 | } else if (device_data->queueFamilyIndexMap.find(queue_family) == device_data->queueFamilyIndexMap.end()) { |
| 149 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 150 | HandleToUint64(device_data->device), __LINE__, error_code, LayerName, |
| 151 | "%s: %s (= %" PRIu32 |
| 152 | ") is not one of the queue families given via VkDeviceQueueCreateInfo structures when " |
| 153 | "the device was created. %s", |
| 154 | cmd_name, parameter_name, queue_family, vu_note); |
| 155 | } |
| 156 | |
| 157 | return skip; |
| 158 | } |
| 159 | |
| 160 | static bool ValidateQueueFamilies(layer_data *device_data, uint32_t queue_family_count, const uint32_t *queue_families, |
| 161 | const char *cmd_name, const char *array_parameter_name, int32_t unique_error_code, |
| 162 | int32_t valid_error_code, bool optional = false, const char *unique_vu_note = nullptr, |
| 163 | const char *valid_vu_note = nullptr) { |
| 164 | bool skip = false; |
| 165 | if (!unique_vu_note) unique_vu_note = validation_error_map[unique_error_code]; |
| 166 | if (!valid_vu_note) valid_vu_note = validation_error_map[valid_error_code]; |
| 167 | if (queue_families) { |
| 168 | std::unordered_set<uint32_t> set; |
| 169 | for (uint32_t i = 0; i < queue_family_count; ++i) { |
| 170 | std::string parameter_name = std::string(array_parameter_name) + "[" + std::to_string(i) + "]"; |
| 171 | |
| 172 | if (set.count(queue_families[i])) { |
| 173 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 174 | HandleToUint64(device_data->device), __LINE__, VALIDATION_ERROR_056002e8, LayerName, |
| 175 | "%s: %s (=%" PRIu32 ") is not unique within %s array. %s", cmd_name, parameter_name.c_str(), |
| 176 | queue_families[i], array_parameter_name, unique_vu_note); |
| 177 | } else { |
| 178 | set.insert(queue_families[i]); |
| 179 | skip |= ValidateDeviceQueueFamily(device_data, queue_families[i], cmd_name, parameter_name.c_str(), |
| 180 | valid_error_code, optional, valid_vu_note); |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | return skip; |
| 185 | } |
| 186 | |
| 187 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 188 | VkInstance *pInstance) { |
| 189 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 190 | |
| 191 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 192 | assert(chain_info != nullptr); |
| 193 | assert(chain_info->u.pLayerInfo != nullptr); |
| 194 | |
| 195 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 196 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
| 197 | if (fpCreateInstance == NULL) { |
| 198 | return VK_ERROR_INITIALIZATION_FAILED; |
| 199 | } |
| 200 | |
| 201 | // Advance the link info for the next element on the chain |
| 202 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 203 | |
| 204 | result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 205 | |
| 206 | if (result == VK_SUCCESS) { |
| 207 | InitializeManualParameterValidationFunctionPointers(); |
| 208 | auto my_instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), instance_layer_data_map); |
| 209 | assert(my_instance_data != nullptr); |
| 210 | |
| 211 | layer_init_instance_dispatch_table(*pInstance, &my_instance_data->dispatch_table, fpGetInstanceProcAddr); |
| 212 | my_instance_data->instance = *pInstance; |
| 213 | my_instance_data->report_data = |
| 214 | debug_report_create_instance(&my_instance_data->dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, |
| 215 | pCreateInfo->ppEnabledExtensionNames); |
| 216 | |
| 217 | // Look for one or more debug report create info structures |
| 218 | // and setup a callback(s) for each one found. |
| 219 | if (!layer_copy_tmp_callbacks(pCreateInfo->pNext, &my_instance_data->num_tmp_callbacks, |
| 220 | &my_instance_data->tmp_dbg_create_infos, &my_instance_data->tmp_callbacks)) { |
| 221 | if (my_instance_data->num_tmp_callbacks > 0) { |
| 222 | // Setup the temporary callback(s) here to catch early issues: |
| 223 | if (layer_enable_tmp_callbacks(my_instance_data->report_data, my_instance_data->num_tmp_callbacks, |
| 224 | my_instance_data->tmp_dbg_create_infos, my_instance_data->tmp_callbacks)) { |
| 225 | // Failure of setting up one or more of the callback. |
| 226 | // Therefore, clean up and don't use those callbacks: |
| 227 | layer_free_tmp_callbacks(my_instance_data->tmp_dbg_create_infos, my_instance_data->tmp_callbacks); |
| 228 | my_instance_data->num_tmp_callbacks = 0; |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | init_parameter_validation(my_instance_data, pAllocator); |
| 234 | my_instance_data->extensions.InitFromInstanceCreateInfo(pCreateInfo); |
| 235 | |
| 236 | // Ordinarily we'd check these before calling down the chain, but none of the layer support is in place until now, if we |
| 237 | // survive we can report the issue now. |
| 238 | parameter_validation_vkCreateInstance(*pInstance, pCreateInfo, pAllocator, pInstance); |
| 239 | |
| 240 | if (pCreateInfo->pApplicationInfo) { |
| 241 | if (pCreateInfo->pApplicationInfo->pApplicationName) { |
| 242 | validate_string(my_instance_data->report_data, "vkCreateInstance", |
| 243 | "pCreateInfo->VkApplicationInfo->pApplicationName", |
| 244 | pCreateInfo->pApplicationInfo->pApplicationName); |
| 245 | } |
| 246 | |
| 247 | if (pCreateInfo->pApplicationInfo->pEngineName) { |
| 248 | validate_string(my_instance_data->report_data, "vkCreateInstance", "pCreateInfo->VkApplicationInfo->pEngineName", |
| 249 | pCreateInfo->pApplicationInfo->pEngineName); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // Disable the tmp callbacks: |
| 254 | if (my_instance_data->num_tmp_callbacks > 0) { |
| 255 | layer_disable_tmp_callbacks(my_instance_data->report_data, my_instance_data->num_tmp_callbacks, |
| 256 | my_instance_data->tmp_callbacks); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return result; |
| 261 | } |
| 262 | |
| 263 | VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 264 | // Grab the key before the instance is destroyed. |
| 265 | dispatch_key key = get_dispatch_key(instance); |
| 266 | bool skip = false; |
| 267 | auto instance_data = GetLayerDataPtr(key, instance_layer_data_map); |
| 268 | |
| 269 | // Enable the temporary callback(s) here to catch vkDestroyInstance issues: |
| 270 | bool callback_setup = false; |
| 271 | if (instance_data->num_tmp_callbacks > 0) { |
| 272 | if (!layer_enable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks, |
| 273 | instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks)) { |
| 274 | callback_setup = true; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | skip |= parameter_validation_vkDestroyInstance(instance, pAllocator); |
| 279 | |
| 280 | // Disable and cleanup the temporary callback(s): |
| 281 | if (callback_setup) { |
| 282 | layer_disable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks, instance_data->tmp_callbacks); |
| 283 | } |
| 284 | if (instance_data->num_tmp_callbacks > 0) { |
| 285 | layer_free_tmp_callbacks(instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks); |
| 286 | instance_data->num_tmp_callbacks = 0; |
| 287 | } |
| 288 | |
| 289 | if (!skip) { |
| 290 | instance_data->dispatch_table.DestroyInstance(instance, pAllocator); |
| 291 | |
| 292 | // Clean up logging callback, if any |
| 293 | while (instance_data->logging_callback.size() > 0) { |
| 294 | VkDebugReportCallbackEXT callback = instance_data->logging_callback.back(); |
| 295 | layer_destroy_msg_callback(instance_data->report_data, callback, pAllocator); |
| 296 | instance_data->logging_callback.pop_back(); |
| 297 | } |
| 298 | |
| 299 | layer_debug_report_destroy_instance(instance_data->report_data); |
| 300 | } |
| 301 | |
| 302 | FreeLayerDataPtr(key, instance_layer_data_map); |
| 303 | } |
| 304 | |
| 305 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, |
| 306 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 307 | const VkAllocationCallbacks *pAllocator, |
| 308 | VkDebugReportCallbackEXT *pMsgCallback) { |
| 309 | bool skip = parameter_validation_vkCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
| 310 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 311 | |
| 312 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 313 | VkResult result = instance_data->dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); |
| 314 | if (result == VK_SUCCESS) { |
| 315 | result = layer_create_msg_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMsgCallback); |
| 316 | } |
| 317 | return result; |
| 318 | } |
| 319 | |
| 320 | VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 321 | const VkAllocationCallbacks *pAllocator) { |
| 322 | bool skip = parameter_validation_vkDestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
| 323 | if (!skip) { |
| 324 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 325 | instance_data->dispatch_table.DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
| 326 | layer_destroy_msg_callback(instance_data->report_data, msgCallback, pAllocator); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | static bool ValidateDeviceCreateInfo(instance_layer_data *instance_data, VkPhysicalDevice physicalDevice, |
| 331 | const VkDeviceCreateInfo *pCreateInfo) { |
| 332 | bool skip = false; |
| 333 | |
| 334 | if ((pCreateInfo->enabledLayerCount > 0) && (pCreateInfo->ppEnabledLayerNames != NULL)) { |
| 335 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 336 | skip |= validate_string(instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 337 | pCreateInfo->ppEnabledLayerNames[i]); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | bool maint1 = false; |
| 342 | bool negative_viewport = false; |
| 343 | |
| 344 | if ((pCreateInfo->enabledExtensionCount > 0) && (pCreateInfo->ppEnabledExtensionNames != NULL)) { |
| 345 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 346 | skip |= validate_string(instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 347 | pCreateInfo->ppEnabledExtensionNames[i]); |
| 348 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MAINTENANCE1_EXTENSION_NAME) == 0) maint1 = true; |
| 349 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME) == 0) |
| 350 | negative_viewport = true; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | if (maint1 && negative_viewport) { |
| 355 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 356 | __LINE__, VALIDATION_ERROR_056002ec, LayerName, |
| 357 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
| 358 | "VK_AMD_negative_viewport_height. %s", |
| 359 | validation_error_map[VALIDATION_ERROR_056002ec]); |
| 360 | } |
| 361 | |
| 362 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 363 | // Check for get_physical_device_properties2 struct |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 364 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext); |
| 365 | if (features2) { |
| 366 | // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures |
| 367 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 368 | __LINE__, INVALID_USAGE, LayerName, |
| 369 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when " |
| 370 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 371 | } |
| 372 | } |
| 373 | |
| 374 | // Validate pCreateInfo->pQueueCreateInfos |
| 375 | if (pCreateInfo->pQueueCreateInfos) { |
| 376 | std::unordered_set<uint32_t> set; |
| 377 | |
| 378 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
| 379 | const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex; |
| 380 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
| 381 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 382 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, |
| 383 | VALIDATION_ERROR_06c002fa, LayerName, |
| 384 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 385 | "].queueFamilyIndex is " |
| 386 | "VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value. %s", |
| 387 | i, validation_error_map[VALIDATION_ERROR_06c002fa]); |
| 388 | } else if (set.count(requested_queue_family)) { |
| 389 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 390 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, |
| 391 | VALIDATION_ERROR_056002e8, LayerName, |
| 392 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 |
| 393 | ") is " |
| 394 | "not unique within pCreateInfo->pQueueCreateInfos array. %s", |
| 395 | i, requested_queue_family, validation_error_map[VALIDATION_ERROR_056002e8]); |
| 396 | } else { |
| 397 | set.insert(requested_queue_family); |
| 398 | } |
| 399 | |
| 400 | if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) { |
| 401 | for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) { |
| 402 | const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j]; |
| 403 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
| 404 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 405 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, |
| 406 | VALIDATION_ERROR_06c002fe, LayerName, |
| 407 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 408 | "] (=%f) is not between 0 and 1 (inclusive). %s", |
| 409 | i, j, queue_priority, validation_error_map[VALIDATION_ERROR_06c002fe]); |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | return skip; |
| 417 | } |
| 418 | |
| 419 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 420 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 421 | // NOTE: Don't validate physicalDevice or any dispatchable object as the first parameter. We couldn't get here if it was wrong! |
| 422 | |
| 423 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 424 | bool skip = false; |
| 425 | auto my_instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map); |
| 426 | assert(my_instance_data != nullptr); |
| 427 | std::unique_lock<std::mutex> lock(global_lock); |
| 428 | |
| 429 | skip |= parameter_validation_vkCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 430 | |
| 431 | if (pCreateInfo != NULL) skip |= ValidateDeviceCreateInfo(my_instance_data, physicalDevice, pCreateInfo); |
| 432 | |
| 433 | if (!skip) { |
| 434 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 435 | assert(chain_info != nullptr); |
| 436 | assert(chain_info->u.pLayerInfo != nullptr); |
| 437 | |
| 438 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 439 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 440 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(my_instance_data->instance, "vkCreateDevice"); |
| 441 | if (fpCreateDevice == NULL) { |
| 442 | return VK_ERROR_INITIALIZATION_FAILED; |
| 443 | } |
| 444 | |
| 445 | // Advance the link info for the next element on the chain |
| 446 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 447 | |
| 448 | lock.unlock(); |
| 449 | |
| 450 | result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 451 | |
| 452 | lock.lock(); |
| 453 | |
| 454 | validate_result(my_instance_data->report_data, "vkCreateDevice", {}, result); |
| 455 | |
| 456 | if (result == VK_SUCCESS) { |
| 457 | layer_data *my_device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
| 458 | assert(my_device_data != nullptr); |
| 459 | |
| 460 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
| 461 | layer_init_device_dispatch_table(*pDevice, &my_device_data->dispatch_table, fpGetDeviceProcAddr); |
| 462 | |
| 463 | my_device_data->extensions.InitFromDeviceCreateInfo(&my_instance_data->extensions, pCreateInfo); |
| 464 | |
| 465 | // Store createdevice data |
| 466 | if ((pCreateInfo != nullptr) && (pCreateInfo->pQueueCreateInfos != nullptr)) { |
| 467 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
| 468 | my_device_data->queueFamilyIndexMap.insert(std::make_pair(pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex, |
| 469 | pCreateInfo->pQueueCreateInfos[i].queueCount)); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | // Query and save physical device limits for this device |
| 474 | VkPhysicalDeviceProperties device_properties = {}; |
| 475 | my_instance_data->dispatch_table.GetPhysicalDeviceProperties(physicalDevice, &device_properties); |
| 476 | memcpy(&my_device_data->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 477 | my_device_data->physical_device = physicalDevice; |
| 478 | my_device_data->device = *pDevice; |
| 479 | |
| 480 | // Save app-enabled features in this device's layer_data structure |
John Zulauf | 1bde5bb | 2017-10-18 18:21:23 -0600 | [diff] [blame] | 481 | // The enabled features can come from either pEnabledFeatures, or from the pNext chain |
| 482 | const VkPhysicalDeviceFeatures *enabled_features_found = pCreateInfo->pEnabledFeatures; |
| 483 | 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] | 484 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext); |
| 485 | if (features2) { |
| 486 | enabled_features_found = &(features2->features); |
John Zulauf | 1bde5bb | 2017-10-18 18:21:23 -0600 | [diff] [blame] | 487 | } |
| 488 | } |
| 489 | if (enabled_features_found) { |
| 490 | my_device_data->physical_device_features = *enabled_features_found; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 491 | } else { |
| 492 | memset(&my_device_data->physical_device_features, 0, sizeof(VkPhysicalDeviceFeatures)); |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | return result; |
| 498 | } |
| 499 | |
| 500 | VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
| 501 | dispatch_key key = get_dispatch_key(device); |
| 502 | bool skip = false; |
| 503 | layer_data *device_data = GetLayerDataPtr(key, layer_data_map); |
| 504 | { |
| 505 | std::unique_lock<std::mutex> lock(global_lock); |
| 506 | skip |= parameter_validation_vkDestroyDevice(device, pAllocator); |
| 507 | } |
| 508 | |
| 509 | if (!skip) { |
| 510 | layer_debug_report_destroy_device(device); |
| 511 | device_data->dispatch_table.DestroyDevice(device, pAllocator); |
| 512 | } |
| 513 | FreeLayerDataPtr(key, layer_data_map); |
| 514 | } |
| 515 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 516 | bool pv_vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
| 517 | bool skip = false; |
| 518 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 519 | |
| 520 | skip |= |
| 521 | ValidateDeviceQueueFamily(device_data, queueFamilyIndex, "vkGetDeviceQueue", "queueFamilyIndex", VALIDATION_ERROR_29600300); |
| 522 | const auto &queue_data = device_data->queueFamilyIndexMap.find(queueFamilyIndex); |
| 523 | if (queue_data != device_data->queueFamilyIndexMap.end() && queue_data->second <= queueIndex) { |
| 524 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, |
| 525 | HandleToUint64(device), __LINE__, VALIDATION_ERROR_29600302, LayerName, |
| 526 | "vkGetDeviceQueue: queueIndex (=%" PRIu32 |
| 527 | ") is not less than the number of queues requested from " |
| 528 | "queueFamilyIndex (=%" PRIu32 ") when the device was created (i.e. is not less than %" PRIu32 "). %s", |
| 529 | queueIndex, queueFamilyIndex, queue_data->second, validation_error_map[VALIDATION_ERROR_29600302]); |
| 530 | } |
| 531 | return skip; |
| 532 | } |
| 533 | |
| 534 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, |
| 535 | const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) { |
| 536 | layer_data *local_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 537 | bool skip = false; |
| 538 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 539 | std::unique_lock<std::mutex> lock(global_lock); |
| 540 | |
| 541 | skip |= ValidateDeviceQueueFamily(local_data, pCreateInfo->queueFamilyIndex, "vkCreateCommandPool", |
| 542 | "pCreateInfo->queueFamilyIndex", VALIDATION_ERROR_02c0004e); |
| 543 | |
| 544 | skip |= parameter_validation_vkCreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); |
| 545 | |
| 546 | lock.unlock(); |
| 547 | if (!skip) { |
| 548 | result = local_data->dispatch_table.CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); |
| 549 | } |
| 550 | return result; |
| 551 | } |
| 552 | |
| 553 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
| 554 | const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool) { |
| 555 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 556 | bool skip = false; |
| 557 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 558 | |
| 559 | skip |= parameter_validation_vkCreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool); |
| 560 | |
| 561 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 562 | if (pCreateInfo != nullptr) { |
| 563 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 564 | // VkQueryPipelineStatisticFlagBits values |
| 565 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 566 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
| 567 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 568 | __LINE__, VALIDATION_ERROR_11c00630, LayerName, |
| 569 | "vkCreateQueryPool(): if pCreateInfo->queryType is " |
| 570 | "VK_QUERY_TYPE_PIPELINE_STATISTICS, pCreateInfo->pipelineStatistics must be " |
| 571 | "a valid combination of VkQueryPipelineStatisticFlagBits values. %s", |
| 572 | validation_error_map[VALIDATION_ERROR_11c00630]); |
| 573 | } |
| 574 | } |
| 575 | if (!skip) { |
| 576 | result = device_data->dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool); |
| 577 | } |
| 578 | return result; |
| 579 | } |
| 580 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 581 | bool pv_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 582 | VkBuffer *pBuffer) { |
| 583 | bool skip = false; |
| 584 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 585 | debug_report_data *report_data = device_data->report_data; |
| 586 | |
| 587 | if (pCreateInfo != nullptr) { |
| 588 | // Buffer size must be greater than 0 (error 00663) |
| 589 | skip |= |
| 590 | ValidateGreaterThan(report_data, "vkCreateBuffer", "pCreateInfo->size", static_cast<uint32_t>(pCreateInfo->size), 0u); |
| 591 | |
| 592 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 593 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 594 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 595 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
| 596 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 597 | VALIDATION_ERROR_01400724, LayerName, |
| 598 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 599 | "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s", |
| 600 | validation_error_map[VALIDATION_ERROR_01400724]); |
| 601 | } |
| 602 | |
| 603 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 604 | // queueFamilyIndexCount uint32_t values |
| 605 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
| 606 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 607 | VALIDATION_ERROR_01400722, LayerName, |
| 608 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 609 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 610 | "pCreateInfo->queueFamilyIndexCount uint32_t values. %s", |
| 611 | validation_error_map[VALIDATION_ERROR_01400722]); |
| 612 | } else { |
| 613 | // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved. |
| 614 | skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices, |
| 615 | "vkCreateBuffer", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE, |
| 616 | false, "", ""); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 621 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 622 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 623 | ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) { |
| 624 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 625 | VALIDATION_ERROR_0140072c, LayerName, |
| 626 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 627 | "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT. %s", |
| 628 | validation_error_map[VALIDATION_ERROR_0140072c]); |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | return skip; |
| 633 | } |
| 634 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 635 | bool pv_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 636 | VkImage *pImage) { |
| 637 | bool skip = false; |
| 638 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 639 | debug_report_data *report_data = device_data->report_data; |
| 640 | |
| 641 | if (pCreateInfo != nullptr) { |
| 642 | if ((device_data->physical_device_features.textureCompressionETC2 == false) && |
| 643 | FormatIsCompressed_ETC2_EAC(pCreateInfo->format)) { |
| 644 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 645 | DEVICE_FEATURE, LayerName, |
| 646 | "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionETC2 feature is " |
| 647 | "not enabled: neither ETC2 nor EAC formats can be used to create images.", |
| 648 | string_VkFormat(pCreateInfo->format)); |
| 649 | } |
| 650 | |
| 651 | if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) && |
| 652 | FormatIsCompressed_ASTC_LDR(pCreateInfo->format)) { |
| 653 | skip |= |
| 654 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 655 | DEVICE_FEATURE, LayerName, |
| 656 | "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionASTC_LDR feature is " |
| 657 | "not enabled: ASTC formats cannot be used to create images.", |
| 658 | string_VkFormat(pCreateInfo->format)); |
| 659 | } |
| 660 | |
| 661 | if ((device_data->physical_device_features.textureCompressionBC == false) && FormatIsCompressed_BC(pCreateInfo->format)) { |
| 662 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 663 | DEVICE_FEATURE, LayerName, |
| 664 | "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionBC feature is " |
| 665 | "not enabled: BC compressed formats cannot be used to create images.", |
| 666 | string_VkFormat(pCreateInfo->format)); |
| 667 | } |
| 668 | |
| 669 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 670 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 671 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 672 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
| 673 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 674 | VALIDATION_ERROR_09e0075c, LayerName, |
| 675 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 676 | "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s", |
| 677 | validation_error_map[VALIDATION_ERROR_09e0075c]); |
| 678 | } |
| 679 | |
| 680 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 681 | // queueFamilyIndexCount uint32_t values |
| 682 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
| 683 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 684 | VALIDATION_ERROR_09e0075a, LayerName, |
| 685 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 686 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 687 | "pCreateInfo->queueFamilyIndexCount uint32_t values. %s", |
| 688 | validation_error_map[VALIDATION_ERROR_09e0075a]); |
| 689 | } else { |
| 690 | // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved. |
| 691 | skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices, |
| 692 | "vkCreateImage", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE, |
| 693 | false, "", ""); |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | // width, height, and depth members of extent must be greater than 0 |
| 698 | skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.width", pCreateInfo->extent.width, 0u); |
| 699 | skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.height", pCreateInfo->extent.height, 0u); |
| 700 | skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.depth", pCreateInfo->extent.depth, 0u); |
| 701 | |
| 702 | // mipLevels must be greater than 0 |
| 703 | skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->mipLevels", pCreateInfo->mipLevels, 0u); |
| 704 | |
| 705 | // arrayLayers must be greater than 0 |
| 706 | skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->arrayLayers", pCreateInfo->arrayLayers, 0u); |
| 707 | |
| 708 | // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1 |
| 709 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && (pCreateInfo->extent.height != 1) && (pCreateInfo->extent.depth != 1)) { |
| 710 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 711 | VALIDATION_ERROR_09e00778, LayerName, |
| 712 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both " |
| 713 | "pCreateInfo->extent.height and pCreateInfo->extent.depth must be 1. %s", |
| 714 | validation_error_map[VALIDATION_ERROR_09e00778]); |
| 715 | } |
| 716 | |
| 717 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
| 718 | // If imageType is VK_IMAGE_TYPE_2D and flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, extent.width and |
| 719 | // extent.height must be equal |
| 720 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) && |
| 721 | (pCreateInfo->extent.width != pCreateInfo->extent.height)) { |
| 722 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 723 | VALIDATION_ERROR_09e00774, LayerName, |
| 724 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D and " |
| 725 | "pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, " |
| 726 | "pCreateInfo->extent.width and pCreateInfo->extent.height must be equal. %s", |
| 727 | validation_error_map[VALIDATION_ERROR_09e00774]); |
| 728 | } |
| 729 | |
| 730 | if (pCreateInfo->extent.depth != 1) { |
| 731 | skip |= log_msg( |
| 732 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 733 | VALIDATION_ERROR_09e0077a, LayerName, |
| 734 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1. %s", |
| 735 | validation_error_map[VALIDATION_ERROR_09e0077a]); |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | // mipLevels must be less than or equal to floor(log2(max(extent.width,extent.height,extent.depth)))+1 |
| 740 | uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth); |
| 741 | if (pCreateInfo->mipLevels > (floor(log2(maxDim)) + 1)) { |
| 742 | skip |= |
| 743 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 744 | VALIDATION_ERROR_09e0077c, LayerName, |
| 745 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 746 | "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1. %s", |
| 747 | validation_error_map[VALIDATION_ERROR_09e0077c]); |
| 748 | } |
| 749 | |
| 750 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 751 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
| 752 | if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 753 | ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) { |
| 754 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 755 | VALIDATION_ERROR_09e007b6, LayerName, |
| 756 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 757 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT. %s", |
| 758 | validation_error_map[VALIDATION_ERROR_09e007b6]); |
| 759 | } |
| 760 | |
| 761 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
| 762 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
| 763 | // Linear tiling is unsupported |
| 764 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
| 765 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 766 | INVALID_USAGE, LayerName, |
| 767 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT " |
| 768 | "then image tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
| 769 | } |
| 770 | |
| 771 | // Sparse 1D image isn't valid |
| 772 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
| 773 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 774 | VALIDATION_ERROR_09e00794, LayerName, |
| 775 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image. %s", |
| 776 | validation_error_map[VALIDATION_ERROR_09e00794]); |
| 777 | } |
| 778 | |
| 779 | // Sparse 2D image when device doesn't support it |
| 780 | if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage2D) && |
| 781 | (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) { |
| 782 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 783 | VALIDATION_ERROR_09e00796, LayerName, |
| 784 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 785 | "feature is not enabled on the device. %s", |
| 786 | validation_error_map[VALIDATION_ERROR_09e00796]); |
| 787 | } |
| 788 | |
| 789 | // Sparse 3D image when device doesn't support it |
| 790 | if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage3D) && |
| 791 | (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) { |
| 792 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 793 | VALIDATION_ERROR_09e00798, LayerName, |
| 794 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 795 | "feature is not enabled on the device. %s", |
| 796 | validation_error_map[VALIDATION_ERROR_09e00798]); |
| 797 | } |
| 798 | |
| 799 | // Multi-sample 2D image when device doesn't support it |
| 800 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
| 801 | if ((VK_FALSE == device_data->physical_device_features.sparseResidency2Samples) && |
| 802 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
| 803 | skip |= log_msg( |
| 804 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 805 | VALIDATION_ERROR_09e0079a, LayerName, |
| 806 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if corresponding " |
| 807 | "feature is not enabled on the device. %s", |
| 808 | validation_error_map[VALIDATION_ERROR_09e0079a]); |
| 809 | } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency4Samples) && |
| 810 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
| 811 | skip |= log_msg( |
| 812 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 813 | VALIDATION_ERROR_09e0079c, LayerName, |
| 814 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if corresponding " |
| 815 | "feature is not enabled on the device. %s", |
| 816 | validation_error_map[VALIDATION_ERROR_09e0079c]); |
| 817 | } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency8Samples) && |
| 818 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
| 819 | skip |= log_msg( |
| 820 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 821 | VALIDATION_ERROR_09e0079e, LayerName, |
| 822 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if corresponding " |
| 823 | "feature is not enabled on the device. %s", |
| 824 | validation_error_map[VALIDATION_ERROR_09e0079e]); |
| 825 | } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency16Samples) && |
| 826 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
| 827 | skip |= log_msg( |
| 828 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 829 | VALIDATION_ERROR_09e007a0, LayerName, |
| 830 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if corresponding " |
| 831 | "feature is not enabled on the device. %s", |
| 832 | validation_error_map[VALIDATION_ERROR_09e007a0]); |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | } |
| 837 | return skip; |
| 838 | } |
| 839 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 840 | bool pv_vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 841 | VkImageView *pView) { |
| 842 | bool skip = false; |
| 843 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 844 | debug_report_data *report_data = device_data->report_data; |
| 845 | |
| 846 | if (pCreateInfo != nullptr) { |
| 847 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) || (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D)) { |
| 848 | if ((pCreateInfo->subresourceRange.layerCount != 1) && |
| 849 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 850 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 851 | LayerName, |
| 852 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD, " |
| 853 | "pCreateInfo->subresourceRange.layerCount must be 1", |
| 854 | ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) ? 1 : 2)); |
| 855 | } |
| 856 | } else if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) || |
| 857 | (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY)) { |
| 858 | if ((pCreateInfo->subresourceRange.layerCount < 1) && |
| 859 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 860 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 861 | LayerName, |
| 862 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD_ARRAY, " |
| 863 | "pCreateInfo->subresourceRange.layerCount must be >= 1", |
| 864 | ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ? 1 : 2)); |
| 865 | } |
| 866 | } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE) { |
| 867 | if ((pCreateInfo->subresourceRange.layerCount != 6) && |
| 868 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 869 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 870 | LayerName, |
| 871 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE, " |
| 872 | "pCreateInfo->subresourceRange.layerCount must be 6"); |
| 873 | } |
| 874 | } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) { |
| 875 | if (((pCreateInfo->subresourceRange.layerCount == 0) || ((pCreateInfo->subresourceRange.layerCount % 6) != 0)) && |
| 876 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 877 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 878 | LayerName, |
| 879 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE_ARRAY, " |
| 880 | "pCreateInfo->subresourceRange.layerCount must be a multiple of 6"); |
| 881 | } |
| 882 | if (!device_data->physical_device_features.imageCubeArray) { |
| 883 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 884 | LayerName, "vkCreateImageView: Device feature imageCubeArray not enabled."); |
| 885 | } |
| 886 | } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) { |
| 887 | if (pCreateInfo->subresourceRange.baseArrayLayer != 0) { |
| 888 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 889 | LayerName, |
| 890 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " |
| 891 | "pCreateInfo->subresourceRange.baseArrayLayer must be 0"); |
| 892 | } |
| 893 | |
| 894 | if ((pCreateInfo->subresourceRange.layerCount != 1) && |
| 895 | (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { |
| 896 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, |
| 897 | LayerName, |
| 898 | "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " |
| 899 | "pCreateInfo->subresourceRange.layerCount must be 1"); |
| 900 | } |
| 901 | } |
| 902 | } |
| 903 | return skip; |
| 904 | } |
| 905 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 906 | bool pv_vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 907 | const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 908 | VkPipeline *pPipelines) { |
| 909 | bool skip = false; |
| 910 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 911 | debug_report_data *report_data = device_data->report_data; |
| 912 | |
| 913 | if (pCreateInfos != nullptr) { |
| 914 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
| 915 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 916 | if (pCreateInfos[i].pVertexInputState != nullptr) { |
| 917 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
| 918 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 919 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
| 920 | if (vertex_bind_desc.binding >= device_data->device_limits.maxVertexInputBindings) { |
| 921 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 922 | __LINE__, VALIDATION_ERROR_14c004d4, LayerName, |
| 923 | "vkCreateGraphicsPipelines: parameter " |
| 924 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
| 925 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u). %s", |
| 926 | i, d, vertex_bind_desc.binding, device_data->device_limits.maxVertexInputBindings, |
| 927 | validation_error_map[VALIDATION_ERROR_14c004d4]); |
| 928 | } |
| 929 | |
| 930 | if (vertex_bind_desc.stride > device_data->device_limits.maxVertexInputBindingStride) { |
| 931 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 932 | __LINE__, VALIDATION_ERROR_14c004d6, LayerName, |
| 933 | "vkCreateGraphicsPipelines: parameter " |
| 934 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
| 935 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u). %s", |
| 936 | i, d, vertex_bind_desc.stride, device_data->device_limits.maxVertexInputBindingStride, |
| 937 | validation_error_map[VALIDATION_ERROR_14c004d6]); |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 942 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
| 943 | if (vertex_attrib_desc.location >= device_data->device_limits.maxVertexInputAttributes) { |
| 944 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 945 | __LINE__, VALIDATION_ERROR_14a004d8, LayerName, |
| 946 | "vkCreateGraphicsPipelines: parameter " |
| 947 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
| 948 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u). %s", |
| 949 | i, d, vertex_attrib_desc.location, device_data->device_limits.maxVertexInputAttributes, |
| 950 | validation_error_map[VALIDATION_ERROR_14a004d8]); |
| 951 | } |
| 952 | |
| 953 | if (vertex_attrib_desc.binding >= device_data->device_limits.maxVertexInputBindings) { |
| 954 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 955 | __LINE__, VALIDATION_ERROR_14a004da, LayerName, |
| 956 | "vkCreateGraphicsPipelines: parameter " |
| 957 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
| 958 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u). %s", |
| 959 | i, d, vertex_attrib_desc.binding, device_data->device_limits.maxVertexInputBindings, |
| 960 | validation_error_map[VALIDATION_ERROR_14a004da]); |
| 961 | } |
| 962 | |
| 963 | if (vertex_attrib_desc.offset > device_data->device_limits.maxVertexInputAttributeOffset) { |
| 964 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 965 | __LINE__, VALIDATION_ERROR_14a004dc, LayerName, |
| 966 | "vkCreateGraphicsPipelines: parameter " |
| 967 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 968 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u). %s", |
| 969 | i, d, vertex_attrib_desc.offset, device_data->device_limits.maxVertexInputAttributeOffset, |
| 970 | validation_error_map[VALIDATION_ERROR_14a004dc]); |
| 971 | } |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | if (pCreateInfos[i].pStages != nullptr) { |
| 976 | bool has_control = false; |
| 977 | bool has_eval = false; |
| 978 | |
| 979 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 980 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 981 | has_control = true; |
| 982 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 983 | has_eval = true; |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 988 | if (has_control && has_eval) { |
| 989 | if (pCreateInfos[i].pTessellationState == nullptr) { |
| 990 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 991 | __LINE__, VALIDATION_ERROR_096005b6, LayerName, |
| 992 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 993 | "shader stage and a tessellation evaluation shader stage, " |
| 994 | "pCreateInfos[%d].pTessellationState must not be NULL. %s", |
| 995 | i, i, validation_error_map[VALIDATION_ERROR_096005b6]); |
| 996 | } else { |
| 997 | skip |= validate_struct_pnext( |
| 998 | report_data, "vkCreateGraphicsPipelines", |
| 999 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1000 | pCreateInfos[i].pTessellationState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0961c40d); |
| 1001 | |
| 1002 | skip |= validate_reserved_flags( |
| 1003 | report_data, "vkCreateGraphicsPipelines", |
| 1004 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
| 1005 | pCreateInfos[i].pTessellationState->flags, VALIDATION_ERROR_10809005); |
| 1006 | |
| 1007 | if (pCreateInfos[i].pTessellationState->sType != |
| 1008 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO) { |
| 1009 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1010 | __LINE__, VALIDATION_ERROR_1082b00b, LayerName, |
| 1011 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pTessellationState->sType must " |
| 1012 | "be VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO. %s", |
| 1013 | i, validation_error_map[VALIDATION_ERROR_1082b00b]); |
| 1014 | } |
| 1015 | |
| 1016 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
| 1017 | pCreateInfos[i].pTessellationState->patchControlPoints > |
| 1018 | device_data->device_limits.maxTessellationPatchSize) { |
| 1019 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1020 | __LINE__, VALIDATION_ERROR_1080097c, LayerName, |
| 1021 | "vkCreateGraphicsPipelines: invalid parameter " |
| 1022 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
| 1023 | "should be >0 and <=%u. %s", |
| 1024 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
| 1025 | device_data->device_limits.maxTessellationPatchSize, |
| 1026 | validation_error_map[VALIDATION_ERROR_1080097c]); |
| 1027 | } |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 1033 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 1034 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 1035 | if (pCreateInfos[i].pViewportState == nullptr) { |
| 1036 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1037 | __LINE__, VALIDATION_ERROR_096005dc, LayerName, |
| 1038 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 1039 | "is VK_FALSE, pCreateInfos[%d].pViewportState must be a pointer to a valid " |
| 1040 | "VkPipelineViewportStateCreateInfo structure. %s", |
| 1041 | i, i, validation_error_map[VALIDATION_ERROR_096005dc]); |
| 1042 | } else { |
| 1043 | if (pCreateInfos[i].pViewportState->scissorCount != pCreateInfos[i].pViewportState->viewportCount) { |
| 1044 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1045 | __LINE__, VALIDATION_ERROR_10c00988, LayerName, |
| 1046 | "Graphics Pipeline viewport count (%u) must match scissor count (%u). %s", |
| 1047 | pCreateInfos[i].pViewportState->viewportCount, pCreateInfos[i].pViewportState->scissorCount, |
| 1048 | validation_error_map[VALIDATION_ERROR_10c00988]); |
| 1049 | } |
| 1050 | |
| 1051 | skip |= validate_struct_pnext( |
| 1052 | report_data, "vkCreateGraphicsPipelines", |
| 1053 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1054 | pCreateInfos[i].pViewportState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_10c1c40d); |
| 1055 | |
| 1056 | skip |= validate_reserved_flags( |
| 1057 | report_data, "vkCreateGraphicsPipelines", |
| 1058 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
| 1059 | pCreateInfos[i].pViewportState->flags, VALIDATION_ERROR_10c09005); |
| 1060 | |
| 1061 | if (pCreateInfos[i].pViewportState->sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
| 1062 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1063 | __LINE__, INVALID_STRUCT_STYPE, LayerName, |
| 1064 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pViewportState->sType must be " |
| 1065 | "VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO", |
| 1066 | i); |
| 1067 | } |
| 1068 | |
| 1069 | if (device_data->physical_device_features.multiViewport == false) { |
| 1070 | if (pCreateInfos[i].pViewportState->viewportCount != 1) { |
| 1071 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1072 | __LINE__, VALIDATION_ERROR_10c00980, LayerName, |
| 1073 | "vkCreateGraphicsPipelines: The multiViewport feature is not enabled, so " |
| 1074 | "pCreateInfos[%d].pViewportState->viewportCount must be 1 but is %d. %s", |
| 1075 | i, pCreateInfos[i].pViewportState->viewportCount, |
| 1076 | validation_error_map[VALIDATION_ERROR_10c00980]); |
| 1077 | } |
| 1078 | if (pCreateInfos[i].pViewportState->scissorCount != 1) { |
| 1079 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1080 | __LINE__, VALIDATION_ERROR_10c00982, LayerName, |
| 1081 | "vkCreateGraphicsPipelines: The multiViewport feature is not enabled, so " |
| 1082 | "pCreateInfos[%d].pViewportState->scissorCount must be 1 but is %d. %s", |
| 1083 | i, pCreateInfos[i].pViewportState->scissorCount, |
| 1084 | validation_error_map[VALIDATION_ERROR_10c00982]); |
| 1085 | } |
| 1086 | } else { |
| 1087 | if ((pCreateInfos[i].pViewportState->viewportCount < 1) || |
| 1088 | (pCreateInfos[i].pViewportState->viewportCount > device_data->device_limits.maxViewports)) { |
| 1089 | skip |= |
| 1090 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1091 | __LINE__, VALIDATION_ERROR_10c00984, LayerName, |
| 1092 | "vkCreateGraphicsPipelines: multiViewport feature is enabled; " |
| 1093 | "pCreateInfos[%d].pViewportState->viewportCount is %d but must be between 1 and " |
| 1094 | "maxViewports (%d), inclusive. %s", |
| 1095 | i, pCreateInfos[i].pViewportState->viewportCount, device_data->device_limits.maxViewports, |
| 1096 | validation_error_map[VALIDATION_ERROR_10c00984]); |
| 1097 | } |
| 1098 | if ((pCreateInfos[i].pViewportState->scissorCount < 1) || |
| 1099 | (pCreateInfos[i].pViewportState->scissorCount > device_data->device_limits.maxViewports)) { |
| 1100 | skip |= |
| 1101 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1102 | __LINE__, VALIDATION_ERROR_10c00986, LayerName, |
| 1103 | "vkCreateGraphicsPipelines: multiViewport feature is enabled; " |
| 1104 | "pCreateInfos[%d].pViewportState->scissorCount is %d but must be between 1 and " |
| 1105 | "maxViewports (%d), inclusive. %s", |
| 1106 | i, pCreateInfos[i].pViewportState->scissorCount, device_data->device_limits.maxViewports, |
| 1107 | validation_error_map[VALIDATION_ERROR_10c00986]); |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1112 | bool has_dynamic_viewport = false; |
| 1113 | bool has_dynamic_scissor = false; |
| 1114 | |
| 1115 | for (uint32_t state_index = 0; state_index < pCreateInfos[i].pDynamicState->dynamicStateCount; |
| 1116 | ++state_index) { |
| 1117 | if (pCreateInfos[i].pDynamicState->pDynamicStates[state_index] == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1118 | has_dynamic_viewport = true; |
| 1119 | } else if (pCreateInfos[i].pDynamicState->pDynamicStates[state_index] == VK_DYNAMIC_STATE_SCISSOR) { |
| 1120 | has_dynamic_scissor = true; |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | // If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_VIEWPORT, the pViewports |
| 1125 | // member of pViewportState must be a pointer to an array of pViewportState->viewportCount VkViewport |
| 1126 | // structures |
| 1127 | if (!has_dynamic_viewport && (pCreateInfos[i].pViewportState->pViewports == nullptr)) { |
| 1128 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1129 | __LINE__, VALIDATION_ERROR_096005d6, LayerName, |
| 1130 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pDynamicState->pDynamicStates does not " |
| 1131 | "contain VK_DYNAMIC_STATE_VIEWPORT, pCreateInfos[%d].pViewportState->pViewports must " |
| 1132 | "not be NULL. %s", |
| 1133 | i, i, validation_error_map[VALIDATION_ERROR_096005d6]); |
| 1134 | } |
| 1135 | |
| 1136 | // If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_SCISSOR, the pScissors |
| 1137 | // member |
| 1138 | // of pViewportState must be a pointer to an array of pViewportState->scissorCount VkRect2D structures |
| 1139 | if (!has_dynamic_scissor && (pCreateInfos[i].pViewportState->pScissors == nullptr)) { |
| 1140 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1141 | __LINE__, VALIDATION_ERROR_096005d8, LayerName, |
| 1142 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pDynamicState->pDynamicStates does not " |
| 1143 | "contain VK_DYNAMIC_STATE_SCISSOR, pCreateInfos[%d].pViewportState->pScissors must not " |
| 1144 | "be NULL. %s", |
| 1145 | i, i, validation_error_map[VALIDATION_ERROR_096005d8]); |
| 1146 | } |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
| 1151 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1152 | __LINE__, VALIDATION_ERROR_096005de, LayerName, |
| 1153 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 1154 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL. %s", |
| 1155 | i, i, validation_error_map[VALIDATION_ERROR_096005de]); |
| 1156 | } else { |
| 1157 | skip |= validate_struct_pnext( |
| 1158 | report_data, "vkCreateGraphicsPipelines", |
| 1159 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1160 | pCreateInfos[i].pMultisampleState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_1001c40d); |
| 1161 | |
| 1162 | skip |= validate_reserved_flags( |
| 1163 | report_data, "vkCreateGraphicsPipelines", |
| 1164 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
| 1165 | pCreateInfos[i].pMultisampleState->flags, VALIDATION_ERROR_10009005); |
| 1166 | |
| 1167 | skip |= validate_bool32( |
| 1168 | report_data, "vkCreateGraphicsPipelines", |
| 1169 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 1170 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 1171 | |
| 1172 | skip |= validate_array( |
| 1173 | report_data, "vkCreateGraphicsPipelines", |
| 1174 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 1175 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
| 1176 | pCreateInfos[i].pMultisampleState->rasterizationSamples, pCreateInfos[i].pMultisampleState->pSampleMask, |
| 1177 | true, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 1178 | |
| 1179 | skip |= validate_bool32( |
| 1180 | report_data, "vkCreateGraphicsPipelines", |
| 1181 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 1182 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 1183 | |
| 1184 | skip |= validate_bool32( |
| 1185 | report_data, "vkCreateGraphicsPipelines", |
| 1186 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 1187 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 1188 | |
| 1189 | if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) { |
| 1190 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1191 | __LINE__, INVALID_STRUCT_STYPE, LayerName, |
| 1192 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 1193 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 1194 | i); |
| 1195 | } |
| 1196 | } |
| 1197 | |
Mark Lobodzinski | 5cd0851 | 2017-09-12 09:50:25 -0600 | [diff] [blame] | 1198 | // TODO: Conditional NULL check based on subpass depth/stencil attachment |
| 1199 | if (pCreateInfos[i].pDepthStencilState != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1200 | skip |= validate_struct_pnext( |
| 1201 | report_data, "vkCreateGraphicsPipelines", |
| 1202 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1203 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f61c40d); |
| 1204 | |
| 1205 | skip |= validate_reserved_flags( |
| 1206 | report_data, "vkCreateGraphicsPipelines", |
| 1207 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
| 1208 | pCreateInfos[i].pDepthStencilState->flags, VALIDATION_ERROR_0f609005); |
| 1209 | |
| 1210 | skip |= validate_bool32( |
| 1211 | report_data, "vkCreateGraphicsPipelines", |
| 1212 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 1213 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 1214 | |
| 1215 | skip |= validate_bool32( |
| 1216 | report_data, "vkCreateGraphicsPipelines", |
| 1217 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 1218 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 1219 | |
| 1220 | skip |= validate_ranged_enum( |
| 1221 | report_data, "vkCreateGraphicsPipelines", |
| 1222 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 1223 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
| 1224 | VALIDATION_ERROR_0f604001); |
| 1225 | |
| 1226 | skip |= validate_bool32( |
| 1227 | report_data, "vkCreateGraphicsPipelines", |
| 1228 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 1229 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 1230 | |
| 1231 | skip |= validate_bool32( |
| 1232 | report_data, "vkCreateGraphicsPipelines", |
| 1233 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 1234 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 1235 | |
| 1236 | skip |= validate_ranged_enum( |
| 1237 | report_data, "vkCreateGraphicsPipelines", |
| 1238 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 1239 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
| 1240 | VALIDATION_ERROR_13a08601); |
| 1241 | |
| 1242 | skip |= validate_ranged_enum( |
| 1243 | report_data, "vkCreateGraphicsPipelines", |
| 1244 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 1245 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
| 1246 | VALIDATION_ERROR_13a27801); |
| 1247 | |
| 1248 | skip |= validate_ranged_enum( |
| 1249 | report_data, "vkCreateGraphicsPipelines", |
| 1250 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 1251 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
| 1252 | VALIDATION_ERROR_13a04201); |
| 1253 | |
| 1254 | skip |= validate_ranged_enum( |
| 1255 | report_data, "vkCreateGraphicsPipelines", |
| 1256 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 1257 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
| 1258 | VALIDATION_ERROR_0f604001); |
| 1259 | |
| 1260 | skip |= validate_ranged_enum( |
| 1261 | report_data, "vkCreateGraphicsPipelines", |
| 1262 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
| 1263 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
| 1264 | VALIDATION_ERROR_13a08601); |
| 1265 | |
| 1266 | skip |= validate_ranged_enum( |
| 1267 | report_data, "vkCreateGraphicsPipelines", |
| 1268 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
| 1269 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
| 1270 | VALIDATION_ERROR_13a27801); |
| 1271 | |
| 1272 | skip |= validate_ranged_enum( |
| 1273 | report_data, "vkCreateGraphicsPipelines", |
| 1274 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 1275 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
| 1276 | VALIDATION_ERROR_13a04201); |
| 1277 | |
| 1278 | skip |= validate_ranged_enum( |
| 1279 | report_data, "vkCreateGraphicsPipelines", |
| 1280 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 1281 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
| 1282 | VALIDATION_ERROR_0f604001); |
| 1283 | |
| 1284 | if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) { |
| 1285 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1286 | __LINE__, INVALID_STRUCT_STYPE, LayerName, |
| 1287 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 1288 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 1289 | i); |
| 1290 | } |
| 1291 | } |
| 1292 | |
Mark Lobodzinski | 5cd0851 | 2017-09-12 09:50:25 -0600 | [diff] [blame] | 1293 | // TODO: Conditional NULL check based on subpass color attachment |
| 1294 | if (pCreateInfos[i].pColorBlendState != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1295 | skip |= validate_struct_pnext( |
| 1296 | report_data, "vkCreateGraphicsPipelines", |
| 1297 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), NULL, |
| 1298 | pCreateInfos[i].pColorBlendState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f41c40d); |
| 1299 | |
| 1300 | skip |= validate_reserved_flags( |
| 1301 | report_data, "vkCreateGraphicsPipelines", |
| 1302 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
| 1303 | pCreateInfos[i].pColorBlendState->flags, VALIDATION_ERROR_0f409005); |
| 1304 | |
| 1305 | skip |= validate_bool32( |
| 1306 | report_data, "vkCreateGraphicsPipelines", |
| 1307 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 1308 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 1309 | |
| 1310 | skip |= validate_array( |
| 1311 | report_data, "vkCreateGraphicsPipelines", |
| 1312 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 1313 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
| 1314 | pCreateInfos[i].pColorBlendState->attachmentCount, pCreateInfos[i].pColorBlendState->pAttachments, false, |
| 1315 | true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 1316 | |
| 1317 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
| 1318 | for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 1319 | ++attachmentIndex) { |
| 1320 | skip |= validate_bool32(report_data, "vkCreateGraphicsPipelines", |
| 1321 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
| 1322 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1323 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable); |
| 1324 | |
| 1325 | skip |= validate_ranged_enum( |
| 1326 | report_data, "vkCreateGraphicsPipelines", |
| 1327 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
| 1328 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1329 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1330 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor, |
| 1331 | VALIDATION_ERROR_0f22cc01); |
| 1332 | |
| 1333 | skip |= validate_ranged_enum( |
| 1334 | report_data, "vkCreateGraphicsPipelines", |
| 1335 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
| 1336 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1337 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1338 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor, |
| 1339 | VALIDATION_ERROR_0f207001); |
| 1340 | |
| 1341 | skip |= validate_ranged_enum( |
| 1342 | report_data, "vkCreateGraphicsPipelines", |
| 1343 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
| 1344 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1345 | "VkBlendOp", AllVkBlendOpEnums, |
| 1346 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp, |
| 1347 | VALIDATION_ERROR_0f202001); |
| 1348 | |
| 1349 | skip |= validate_ranged_enum( |
| 1350 | report_data, "vkCreateGraphicsPipelines", |
| 1351 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
| 1352 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1353 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1354 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor, |
| 1355 | VALIDATION_ERROR_0f22c601); |
| 1356 | |
| 1357 | skip |= validate_ranged_enum( |
| 1358 | report_data, "vkCreateGraphicsPipelines", |
| 1359 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
| 1360 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1361 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1362 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor, |
| 1363 | VALIDATION_ERROR_0f206a01); |
| 1364 | |
| 1365 | skip |= validate_ranged_enum( |
| 1366 | report_data, "vkCreateGraphicsPipelines", |
| 1367 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
| 1368 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1369 | "VkBlendOp", AllVkBlendOpEnums, |
| 1370 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp, |
| 1371 | VALIDATION_ERROR_0f200801); |
| 1372 | |
| 1373 | skip |= |
| 1374 | validate_flags(report_data, "vkCreateGraphicsPipelines", |
| 1375 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
| 1376 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1377 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
| 1378 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask, |
| 1379 | false, false, VALIDATION_ERROR_0f202201); |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) { |
| 1384 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1385 | __LINE__, INVALID_STRUCT_STYPE, LayerName, |
| 1386 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 1387 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 1388 | i); |
| 1389 | } |
| 1390 | |
| 1391 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 1392 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 1393 | skip |= validate_ranged_enum( |
| 1394 | report_data, "vkCreateGraphicsPipelines", |
| 1395 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
| 1396 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, VALIDATION_ERROR_0f4004be); |
| 1397 | } |
| 1398 | } |
| 1399 | } |
| 1400 | } |
| 1401 | |
| 1402 | if (pCreateInfos != nullptr) { |
| 1403 | if (pCreateInfos->flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 1404 | if (pCreateInfos->basePipelineIndex != -1) { |
| 1405 | if (pCreateInfos->basePipelineHandle != VK_NULL_HANDLE) { |
| 1406 | skip |= log_msg( |
| 1407 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1408 | VALIDATION_ERROR_096005a8, LayerName, |
| 1409 | "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be VK_NULL_HANDLE if " |
| 1410 | "pCreateInfos->flags " |
| 1411 | "contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1. %s", |
| 1412 | validation_error_map[VALIDATION_ERROR_096005a8]); |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | if (pCreateInfos->basePipelineHandle != VK_NULL_HANDLE) { |
| 1417 | if (pCreateInfos->basePipelineIndex != -1) { |
| 1418 | skip |= log_msg( |
| 1419 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1420 | VALIDATION_ERROR_096005aa, LayerName, |
| 1421 | "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if " |
| 1422 | "pCreateInfos->flags " |
| 1423 | "contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineHandle is not " |
| 1424 | "VK_NULL_HANDLE. %s", |
| 1425 | validation_error_map[VALIDATION_ERROR_096005aa]); |
| 1426 | } |
| 1427 | } |
| 1428 | } |
| 1429 | |
| 1430 | if (pCreateInfos->pRasterizationState != nullptr) { |
| 1431 | if (pCreateInfos->pRasterizationState->cullMode & ~VK_CULL_MODE_FRONT_AND_BACK) { |
| 1432 | skip |= log_msg( |
| 1433 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1434 | UNRECOGNIZED_VALUE, LayerName, |
| 1435 | "vkCreateGraphicsPipelines parameter, VkCullMode pCreateInfos->pRasterizationState->cullMode, is an " |
| 1436 | "unrecognized enumerator"); |
| 1437 | } |
| 1438 | |
| 1439 | if ((pCreateInfos->pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 1440 | (device_data->physical_device_features.fillModeNonSolid == false)) { |
| 1441 | skip |= log_msg( |
| 1442 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1443 | DEVICE_FEATURE, LayerName, |
| 1444 | "vkCreateGraphicsPipelines parameter, VkPolygonMode pCreateInfos->pRasterizationState->polygonMode cannot " |
| 1445 | "be " |
| 1446 | "VK_POLYGON_MODE_POINT or VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false."); |
| 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | size_t i = 0; |
| 1451 | for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) { |
| 1452 | skip |= validate_string(device_data->report_data, "vkCreateGraphicsPipelines", |
| 1453 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}), |
| 1454 | pCreateInfos[i].pStages[j].pName); |
| 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | return skip; |
| 1460 | } |
| 1461 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1462 | bool pv_vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 1463 | const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 1464 | VkPipeline *pPipelines) { |
| 1465 | bool skip = false; |
| 1466 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1467 | |
| 1468 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 1469 | skip |= validate_string(device_data->report_data, "vkCreateComputePipelines", |
| 1470 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
| 1471 | pCreateInfos[i].stage.pName); |
| 1472 | } |
| 1473 | |
| 1474 | return skip; |
| 1475 | } |
| 1476 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1477 | bool pv_vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1478 | VkSampler *pSampler) { |
| 1479 | bool skip = false; |
| 1480 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1481 | debug_report_data *report_data = device_data->report_data; |
| 1482 | |
| 1483 | if (pCreateInfo != nullptr) { |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 1484 | const auto &features = device_data->physical_device_features; |
| 1485 | const auto &limits = device_data->device_limits; |
| 1486 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 1487 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
| 1488 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1489 | VALIDATION_ERROR_1260085e, LayerName, |
| 1490 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found. %s", |
| 1491 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 1492 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy, |
| 1493 | validation_error_map[VALIDATION_ERROR_1260085e]); |
| 1494 | } |
| 1495 | |
| 1496 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 1497 | if (features.samplerAnisotropy == VK_FALSE) { |
| 1498 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1499 | VALIDATION_ERROR_1260085c, LayerName, |
| 1500 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE. %s", |
| 1501 | "pCreateInfo->anisotropyEnable", validation_error_map[VALIDATION_ERROR_1260085c]); |
| 1502 | } |
| 1503 | |
| 1504 | // Anistropy and unnormalized coordinates cannot be enabled simultaneously |
| 1505 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 1506 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1507 | VALIDATION_ERROR_12600868, LayerName, |
| 1508 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates " |
| 1509 | "must not both be VK_TRUE. %s", |
| 1510 | validation_error_map[VALIDATION_ERROR_12600868]); |
| 1511 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1512 | } |
| 1513 | |
| 1514 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 1515 | if (pCreateInfo->compareEnable == VK_TRUE) { |
| 1516 | skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", |
| 1517 | AllVkCompareOpEnums, pCreateInfo->compareOp, VALIDATION_ERROR_12600870); |
| 1518 | } |
| 1519 | |
| 1520 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 1521 | // valid VkBorderColor value |
| 1522 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 1523 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 1524 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
| 1525 | skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", |
| 1526 | AllVkBorderColorEnums, pCreateInfo->borderColor, VALIDATION_ERROR_1260086c); |
| 1527 | } |
| 1528 | |
| 1529 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the |
| 1530 | // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled |
| 1531 | if (!device_data->extensions.vk_khr_sampler_mirror_clamp_to_edge && |
| 1532 | ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 1533 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 1534 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) { |
| 1535 | skip |= |
| 1536 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1537 | VALIDATION_ERROR_1260086e, LayerName, |
| 1538 | "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE " |
| 1539 | "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled. %s", |
| 1540 | validation_error_map[VALIDATION_ERROR_1260086e]); |
| 1541 | } |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame^] | 1542 | |
| 1543 | // Checks for the IMG cubic filtering extension |
| 1544 | if (device_data->extensions.vk_img_filter_cubic) { |
| 1545 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 1546 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
| 1547 | skip |= |
| 1548 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1549 | VALIDATION_ERROR_12600872, LayerName, |
| 1550 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter are " |
| 1551 | "VK_FILTER_CUBIC_IMG. %s", |
| 1552 | validation_error_map[VALIDATION_ERROR_12600872]); |
| 1553 | } |
| 1554 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1555 | } |
| 1556 | |
| 1557 | return skip; |
| 1558 | } |
| 1559 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1560 | bool pv_vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1561 | const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) { |
| 1562 | bool skip = false; |
| 1563 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1564 | debug_report_data *report_data = device_data->report_data; |
| 1565 | |
| 1566 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 1567 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 1568 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 1569 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
| 1570 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount |
| 1571 | // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount |
| 1572 | // valid VkSampler handles |
| 1573 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 1574 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 1575 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 1576 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 1577 | ++descriptor_index) { |
| 1578 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
| 1579 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1580 | __LINE__, REQUIRED_PARAMETER, LayerName, |
| 1581 | "vkCreateDescriptorSetLayout: required parameter " |
| 1582 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d]" |
| 1583 | " specified as VK_NULL_HANDLE", |
| 1584 | i, descriptor_index); |
| 1585 | } |
| 1586 | } |
| 1587 | } |
| 1588 | |
| 1589 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 1590 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 1591 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
| 1592 | skip |= log_msg( |
| 1593 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1594 | VALIDATION_ERROR_04e00236, LayerName, |
| 1595 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 1596 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits values. %s", |
| 1597 | i, i, validation_error_map[VALIDATION_ERROR_04e00236]); |
| 1598 | } |
| 1599 | } |
| 1600 | } |
| 1601 | } |
| 1602 | |
| 1603 | return skip; |
| 1604 | } |
| 1605 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1606 | bool pv_vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 1607 | const VkDescriptorSet *pDescriptorSets) { |
| 1608 | bool skip = false; |
| 1609 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1610 | debug_report_data *report_data = device_data->report_data; |
| 1611 | |
| 1612 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 1613 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 1614 | // validate_array() |
| 1615 | skip |= validate_array(report_data, "vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, |
| 1616 | pDescriptorSets, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 1617 | return skip; |
| 1618 | } |
| 1619 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1620 | bool pv_vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, |
| 1621 | uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) { |
| 1622 | bool skip = false; |
| 1623 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1624 | debug_report_data *report_data = device_data->report_data; |
| 1625 | |
| 1626 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 1627 | if (pDescriptorWrites != NULL) { |
| 1628 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 1629 | // descriptorCount must be greater than 0 |
| 1630 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 1631 | skip |= |
| 1632 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1633 | VALIDATION_ERROR_15c0441b, LayerName, |
| 1634 | "vkUpdateDescriptorSets(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0. %s", |
| 1635 | i, validation_error_map[VALIDATION_ERROR_15c0441b]); |
| 1636 | } |
| 1637 | |
| 1638 | // dstSet must be a valid VkDescriptorSet handle |
| 1639 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 1640 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 1641 | pDescriptorWrites[i].dstSet); |
| 1642 | |
| 1643 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 1644 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 1645 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 1646 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 1647 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 1648 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 1649 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, |
| 1650 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures |
| 1651 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
| 1652 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1653 | __LINE__, VALIDATION_ERROR_15c00284, LayerName, |
| 1654 | "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is " |
| 1655 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 1656 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 1657 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL. %s", |
| 1658 | i, i, validation_error_map[VALIDATION_ERROR_15c00284]); |
| 1659 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 1660 | // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, |
| 1661 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout |
| 1662 | // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively |
| 1663 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 1664 | ++descriptor_index) { |
| 1665 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 1666 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView", |
| 1667 | ParameterName::IndexVector{i, descriptor_index}), |
| 1668 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageView); |
| 1669 | skip |= validate_ranged_enum(report_data, "vkUpdateDescriptorSets", |
| 1670 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 1671 | ParameterName::IndexVector{i, descriptor_index}), |
| 1672 | "VkImageLayout", AllVkImageLayoutEnums, |
| 1673 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, |
| 1674 | VALIDATION_ERROR_UNDEFINED); |
| 1675 | } |
| 1676 | } |
| 1677 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 1678 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 1679 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 1680 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 1681 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 1682 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 1683 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
| 1684 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
| 1685 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1686 | __LINE__, VALIDATION_ERROR_15c00288, LayerName, |
| 1687 | "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is " |
| 1688 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 1689 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
| 1690 | "pDescriptorWrites[%d].pBufferInfo must not be NULL. %s", |
| 1691 | i, i, validation_error_map[VALIDATION_ERROR_15c00288]); |
| 1692 | } else { |
| 1693 | for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) { |
| 1694 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 1695 | ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer", |
| 1696 | ParameterName::IndexVector{i, descriptorIndex}), |
| 1697 | pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer); |
| 1698 | } |
| 1699 | } |
| 1700 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 1701 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
| 1702 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, |
| 1703 | // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles |
| 1704 | if (pDescriptorWrites[i].pTexelBufferView == nullptr) { |
| 1705 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1706 | __LINE__, VALIDATION_ERROR_15c00286, LayerName, |
| 1707 | "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is " |
| 1708 | "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, " |
| 1709 | "pDescriptorWrites[%d].pTexelBufferView must not be NULL. %s", |
| 1710 | i, i, validation_error_map[VALIDATION_ERROR_15c00286]); |
| 1711 | } else { |
| 1712 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 1713 | ++descriptor_index) { |
| 1714 | skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets", |
| 1715 | ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]", |
| 1716 | ParameterName::IndexVector{i, descriptor_index}), |
| 1717 | pDescriptorWrites[i].pTexelBufferView[descriptor_index]); |
| 1718 | } |
| 1719 | } |
| 1720 | } |
| 1721 | |
| 1722 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 1723 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
| 1724 | VkDeviceSize uniformAlignment = device_data->device_limits.minUniformBufferOffsetAlignment; |
| 1725 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 1726 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 1727 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { |
| 1728 | skip |= log_msg( |
| 1729 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1730 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c0028e, LayerName, |
| 1731 | "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 1732 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s", |
| 1733 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment, |
| 1734 | validation_error_map[VALIDATION_ERROR_15c0028e]); |
| 1735 | } |
| 1736 | } |
| 1737 | } |
| 1738 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 1739 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 1740 | VkDeviceSize storageAlignment = device_data->device_limits.minStorageBufferOffsetAlignment; |
| 1741 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 1742 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 1743 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { |
| 1744 | skip |= log_msg( |
| 1745 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1746 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c00290, LayerName, |
| 1747 | "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 1748 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s", |
| 1749 | i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment, |
| 1750 | validation_error_map[VALIDATION_ERROR_15c00290]); |
| 1751 | } |
| 1752 | } |
| 1753 | } |
| 1754 | } |
| 1755 | } |
| 1756 | } |
| 1757 | return skip; |
| 1758 | } |
| 1759 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1760 | bool pv_vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1761 | VkRenderPass *pRenderPass) { |
| 1762 | bool skip = false; |
| 1763 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1764 | uint32_t max_color_attachments = device_data->device_limits.maxColorAttachments; |
| 1765 | |
| 1766 | for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) { |
| 1767 | if (pCreateInfo->pAttachments[i].format == VK_FORMAT_UNDEFINED) { |
| 1768 | std::stringstream ss; |
| 1769 | ss << "vkCreateRenderPass: pCreateInfo->pAttachments[" << i << "].format is VK_FORMAT_UNDEFINED. " |
| 1770 | << validation_error_map[VALIDATION_ERROR_00809201]; |
| 1771 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1772 | __LINE__, VALIDATION_ERROR_00809201, "IMAGE", "%s", ss.str().c_str()); |
| 1773 | } |
| 1774 | if (pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_UNDEFINED || |
| 1775 | pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) { |
| 1776 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1777 | __LINE__, VALIDATION_ERROR_00800696, "DL", |
| 1778 | "pCreateInfo->pAttachments[%d].finalLayout must not be VK_IMAGE_LAYOUT_UNDEFINED or " |
| 1779 | "VK_IMAGE_LAYOUT_PREINITIALIZED. %s", |
| 1780 | i, validation_error_map[VALIDATION_ERROR_00800696]); |
| 1781 | } |
| 1782 | } |
| 1783 | |
| 1784 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 1785 | if (pCreateInfo->pSubpasses[i].colorAttachmentCount > max_color_attachments) { |
| 1786 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1787 | __LINE__, VALIDATION_ERROR_1400069a, "DL", |
| 1788 | "Cannot create a render pass with %d color attachments. Max is %d. %s", |
| 1789 | pCreateInfo->pSubpasses[i].colorAttachmentCount, max_color_attachments, |
| 1790 | validation_error_map[VALIDATION_ERROR_1400069a]); |
| 1791 | } |
| 1792 | } |
| 1793 | return skip; |
| 1794 | } |
| 1795 | |
| 1796 | bool pv_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 1797 | const VkCommandBuffer *pCommandBuffers) { |
| 1798 | bool skip = false; |
| 1799 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1800 | debug_report_data *report_data = device_data->report_data; |
| 1801 | |
| 1802 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 1803 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 1804 | // validate_array() |
| 1805 | skip |= validate_array(report_data, "vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, |
| 1806 | pCommandBuffers, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 1807 | return skip; |
| 1808 | } |
| 1809 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1810 | bool pv_vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo) { |
| 1811 | bool skip = false; |
| 1812 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 1813 | debug_report_data *report_data = device_data->report_data; |
| 1814 | const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo; |
| 1815 | |
| 1816 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 1817 | // TODO: pBeginInfo->pInheritanceInfo must not be NULL if commandBuffer is a secondary command buffer |
| 1818 | skip |= validate_struct_type(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo", |
| 1819 | "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", pBeginInfo->pInheritanceInfo, |
| 1820 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, false, VALIDATION_ERROR_UNDEFINED); |
| 1821 | |
| 1822 | if (pBeginInfo->pInheritanceInfo != NULL) { |
| 1823 | skip |= |
| 1824 | validate_struct_pnext(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pNext", NULL, |
| 1825 | pBeginInfo->pInheritanceInfo->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0281c40d); |
| 1826 | |
| 1827 | skip |= validate_bool32(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", |
| 1828 | pBeginInfo->pInheritanceInfo->occlusionQueryEnable); |
| 1829 | |
| 1830 | // TODO: This only needs to be validated when the inherited queries feature is enabled |
| 1831 | // skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags", |
| 1832 | // "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pBeginInfo->pInheritanceInfo->queryFlags, false); |
| 1833 | |
| 1834 | // TODO: This must be 0 if the pipeline statistics queries feature is not enabled |
| 1835 | skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pipelineStatistics", |
| 1836 | "VkQueryPipelineStatisticFlagBits", AllVkQueryPipelineStatisticFlagBits, |
| 1837 | pBeginInfo->pInheritanceInfo->pipelineStatistics, false, false, VALIDATION_ERROR_UNDEFINED); |
| 1838 | } |
| 1839 | |
| 1840 | if (pInfo != NULL) { |
| 1841 | if ((device_data->physical_device_features.inheritedQueries == VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) { |
| 1842 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1843 | HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_02a00070, LayerName, |
| 1844 | "Cannot set inherited occlusionQueryEnable in vkBeginCommandBuffer() when device does not support " |
| 1845 | "inheritedQueries. %s", |
| 1846 | validation_error_map[VALIDATION_ERROR_02a00070]); |
| 1847 | } |
| 1848 | if ((device_data->physical_device_features.inheritedQueries != VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) { |
| 1849 | skip |= validate_flags(device_data->report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags", |
| 1850 | "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pInfo->queryFlags, false, false, |
| 1851 | VALIDATION_ERROR_02a00072); |
| 1852 | } |
| 1853 | } |
| 1854 | |
| 1855 | return skip; |
| 1856 | } |
| 1857 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1858 | bool pv_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
| 1859 | const VkViewport *pViewports) { |
| 1860 | bool skip = false; |
| 1861 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 1862 | |
| 1863 | skip |= validate_array(device_data->report_data, "vkCmdSetViewport", "viewportCount", "pViewports", viewportCount, pViewports, |
| 1864 | true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 1865 | |
| 1866 | if (viewportCount > 0 && pViewports != nullptr) { |
| 1867 | const VkPhysicalDeviceLimits &limits = device_data->device_limits; |
| 1868 | for (uint32_t viewportIndex = 0; viewportIndex < viewportCount; ++viewportIndex) { |
| 1869 | const VkViewport &viewport = pViewports[viewportIndex]; |
| 1870 | |
| 1871 | if (device_data->physical_device_features.multiViewport == false) { |
| 1872 | if (viewportCount != 1) { |
| 1873 | skip |= log_msg( |
| 1874 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1875 | __LINE__, DEVICE_FEATURE, LayerName, |
| 1876 | "vkCmdSetViewport(): The multiViewport feature is not enabled, so viewportCount must be 1 but is %d.", |
| 1877 | viewportCount); |
| 1878 | } |
| 1879 | if (firstViewport != 0) { |
| 1880 | skip |= log_msg( |
| 1881 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1882 | __LINE__, DEVICE_FEATURE, LayerName, |
| 1883 | "vkCmdSetViewport(): The multiViewport feature is not enabled, so firstViewport must be 0 but is %d.", |
| 1884 | firstViewport); |
| 1885 | } |
| 1886 | } |
| 1887 | |
| 1888 | if (viewport.width <= 0 || viewport.width > limits.maxViewportDimensions[0]) { |
| 1889 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1890 | __LINE__, VALIDATION_ERROR_15000996, LayerName, |
| 1891 | "vkCmdSetViewport %d: width (%f) exceeds permitted bounds (0,%u). %s", viewportIndex, |
| 1892 | viewport.width, limits.maxViewportDimensions[0], validation_error_map[VALIDATION_ERROR_15000996]); |
| 1893 | } |
| 1894 | |
| 1895 | if (device_data->extensions.vk_amd_negative_viewport_height || device_data->extensions.vk_khr_maintenance1) { |
| 1896 | // Check lower bound against negative viewport height instead of zero |
| 1897 | if (viewport.height <= -(static_cast<int32_t>(limits.maxViewportDimensions[1])) || |
| 1898 | (viewport.height > limits.maxViewportDimensions[1])) { |
| 1899 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1900 | VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, VALIDATION_ERROR_1500099a, LayerName, |
| 1901 | "vkCmdSetViewport %d: height (%f) exceeds permitted bounds (-%u,%u). %s", viewportIndex, |
| 1902 | viewport.height, limits.maxViewportDimensions[1], limits.maxViewportDimensions[1], |
| 1903 | validation_error_map[VALIDATION_ERROR_1500099a]); |
| 1904 | } |
| 1905 | } else { |
| 1906 | if ((viewport.height <= 0) || (viewport.height > limits.maxViewportDimensions[1])) { |
| 1907 | skip |= |
| 1908 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1909 | __LINE__, VALIDATION_ERROR_15000998, LayerName, |
| 1910 | "vkCmdSetViewport %d: height (%f) exceeds permitted bounds (0,%u). %s", viewportIndex, |
| 1911 | viewport.height, limits.maxViewportDimensions[1], validation_error_map[VALIDATION_ERROR_15000998]); |
| 1912 | } |
| 1913 | } |
| 1914 | |
| 1915 | if (viewport.x < limits.viewportBoundsRange[0] || viewport.x > limits.viewportBoundsRange[1]) { |
| 1916 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1917 | __LINE__, VALIDATION_ERROR_1500099e, LayerName, |
| 1918 | "vkCmdSetViewport %d: x (%f) exceeds permitted bounds (%f,%f). %s", viewportIndex, viewport.x, |
| 1919 | limits.viewportBoundsRange[0], limits.viewportBoundsRange[1], |
| 1920 | validation_error_map[VALIDATION_ERROR_1500099e]); |
| 1921 | } |
| 1922 | |
| 1923 | if (viewport.y < limits.viewportBoundsRange[0] || viewport.y > limits.viewportBoundsRange[1]) { |
| 1924 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1925 | __LINE__, VALIDATION_ERROR_1500099e, LayerName, |
| 1926 | "vkCmdSetViewport %d: y (%f) exceeds permitted bounds (%f,%f). %s", viewportIndex, viewport.y, |
| 1927 | limits.viewportBoundsRange[0], limits.viewportBoundsRange[1], |
| 1928 | validation_error_map[VALIDATION_ERROR_1500099e]); |
| 1929 | } |
| 1930 | |
| 1931 | if (viewport.x + viewport.width > limits.viewportBoundsRange[1]) { |
| 1932 | skip |= |
| 1933 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1934 | __LINE__, VALIDATION_ERROR_150009a0, LayerName, |
| 1935 | "vkCmdSetViewport %d: x (%f) + width (%f) exceeds permitted bound (%f). %s", viewportIndex, viewport.x, |
| 1936 | viewport.width, limits.viewportBoundsRange[1], validation_error_map[VALIDATION_ERROR_150009a0]); |
| 1937 | } |
| 1938 | |
| 1939 | if (viewport.y + viewport.height > limits.viewportBoundsRange[1]) { |
| 1940 | skip |= |
| 1941 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 1942 | __LINE__, VALIDATION_ERROR_150009a2, LayerName, |
| 1943 | "vkCmdSetViewport %d: y (%f) + height (%f) exceeds permitted bound (%f). %s", viewportIndex, viewport.y, |
| 1944 | viewport.height, limits.viewportBoundsRange[1], validation_error_map[VALIDATION_ERROR_150009a2]); |
| 1945 | } |
| 1946 | } |
| 1947 | } |
| 1948 | return skip; |
| 1949 | } |
| 1950 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1951 | bool pv_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors) { |
| 1952 | bool skip = false; |
| 1953 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 1954 | debug_report_data *report_data = device_data->report_data; |
| 1955 | |
| 1956 | if (device_data->physical_device_features.multiViewport == false) { |
| 1957 | if (scissorCount != 1) { |
| 1958 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1959 | DEVICE_FEATURE, LayerName, |
| 1960 | "vkCmdSetScissor(): The multiViewport feature is not enabled, so scissorCount must be 1 but is %d.", |
| 1961 | scissorCount); |
| 1962 | } |
| 1963 | if (firstScissor != 0) { |
| 1964 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1965 | DEVICE_FEATURE, LayerName, |
| 1966 | "vkCmdSetScissor(): The multiViewport feature is not enabled, so firstScissor must be 0 but is %d.", |
| 1967 | firstScissor); |
| 1968 | } |
| 1969 | } |
| 1970 | |
| 1971 | for (uint32_t scissorIndex = 0; scissorIndex < scissorCount; ++scissorIndex) { |
| 1972 | const VkRect2D &pScissor = pScissors[scissorIndex]; |
| 1973 | |
| 1974 | if (pScissor.offset.x < 0) { |
| 1975 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1976 | VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.x (%d) must not be negative. %s", |
| 1977 | scissorIndex, pScissor.offset.x, validation_error_map[VALIDATION_ERROR_1d8004a6]); |
| 1978 | } else if (static_cast<int32_t>(pScissor.extent.width) > (INT_MAX - pScissor.offset.x)) { |
| 1979 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1980 | VALIDATION_ERROR_1d8004a8, LayerName, |
| 1981 | "vkCmdSetScissor %d: adding offset.x (%d) and extent.width (%u) will overflow. %s", scissorIndex, |
| 1982 | pScissor.offset.x, pScissor.extent.width, validation_error_map[VALIDATION_ERROR_1d8004a8]); |
| 1983 | } |
| 1984 | |
| 1985 | if (pScissor.offset.y < 0) { |
| 1986 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1987 | VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.y (%d) must not be negative. %s", |
| 1988 | scissorIndex, pScissor.offset.y, validation_error_map[VALIDATION_ERROR_1d8004a6]); |
| 1989 | } else if (static_cast<int32_t>(pScissor.extent.height) > (INT_MAX - pScissor.offset.y)) { |
| 1990 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 1991 | VALIDATION_ERROR_1d8004aa, LayerName, |
| 1992 | "vkCmdSetScissor %d: adding offset.y (%d) and extent.height (%u) will overflow. %s", scissorIndex, |
| 1993 | pScissor.offset.y, pScissor.extent.height, validation_error_map[VALIDATION_ERROR_1d8004aa]); |
| 1994 | } |
| 1995 | } |
| 1996 | return skip; |
| 1997 | } |
| 1998 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1999 | bool pv_vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
| 2000 | uint32_t firstInstance) { |
| 2001 | bool skip = false; |
| 2002 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2003 | if (vertexCount == 0) { |
| 2004 | // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make |
| 2005 | // this an error or leave as is. |
| 2006 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2007 | __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t vertexCount, is 0"); |
| 2008 | } |
| 2009 | |
| 2010 | if (instanceCount == 0) { |
| 2011 | // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make |
| 2012 | // this an error or leave as is. |
| 2013 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2014 | __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t instanceCount, is 0"); |
| 2015 | } |
| 2016 | return skip; |
| 2017 | } |
| 2018 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2019 | bool pv_vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) { |
| 2020 | bool skip = false; |
| 2021 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2022 | |
| 2023 | if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) { |
| 2024 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2025 | __LINE__, DEVICE_FEATURE, LayerName, |
| 2026 | "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count); |
| 2027 | } |
| 2028 | return skip; |
| 2029 | } |
| 2030 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2031 | bool pv_vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, |
| 2032 | uint32_t stride) { |
| 2033 | bool skip = false; |
| 2034 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2035 | if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) { |
| 2036 | skip |= |
| 2037 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2038 | DEVICE_FEATURE, LayerName, |
| 2039 | "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count); |
| 2040 | } |
| 2041 | return skip; |
| 2042 | } |
| 2043 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2044 | bool pv_vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 2045 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) { |
| 2046 | bool skip = false; |
| 2047 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2048 | |
| 2049 | if (pRegions != nullptr) { |
| 2050 | if ((pRegions->srcSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | |
| 2051 | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) { |
| 2052 | skip |= log_msg( |
| 2053 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2054 | VALIDATION_ERROR_0a600c01, LayerName, |
| 2055 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator. %s", |
| 2056 | validation_error_map[VALIDATION_ERROR_0a600c01]); |
| 2057 | } |
| 2058 | if ((pRegions->dstSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | |
| 2059 | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) { |
| 2060 | skip |= log_msg( |
| 2061 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2062 | VALIDATION_ERROR_0a600c01, LayerName, |
| 2063 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator. %s", |
| 2064 | validation_error_map[VALIDATION_ERROR_0a600c01]); |
| 2065 | } |
| 2066 | } |
| 2067 | return skip; |
| 2068 | } |
| 2069 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2070 | bool pv_vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 2071 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) { |
| 2072 | bool skip = false; |
| 2073 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2074 | |
| 2075 | if (pRegions != nullptr) { |
| 2076 | if ((pRegions->srcSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | |
| 2077 | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) { |
| 2078 | skip |= log_msg( |
| 2079 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2080 | UNRECOGNIZED_VALUE, LayerName, |
| 2081 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator"); |
| 2082 | } |
| 2083 | if ((pRegions->dstSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | |
| 2084 | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) { |
| 2085 | skip |= log_msg( |
| 2086 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2087 | UNRECOGNIZED_VALUE, LayerName, |
| 2088 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator"); |
| 2089 | } |
| 2090 | } |
| 2091 | return skip; |
| 2092 | } |
| 2093 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2094 | bool pv_vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, |
| 2095 | uint32_t regionCount, const VkBufferImageCopy *pRegions) { |
| 2096 | bool skip = false; |
| 2097 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2098 | |
| 2099 | if (pRegions != nullptr) { |
| 2100 | if ((pRegions->imageSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | |
| 2101 | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) { |
| 2102 | skip |= log_msg( |
| 2103 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2104 | UNRECOGNIZED_VALUE, LayerName, |
| 2105 | "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized " |
| 2106 | "enumerator"); |
| 2107 | } |
| 2108 | } |
| 2109 | return skip; |
| 2110 | } |
| 2111 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2112 | bool pv_vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, |
| 2113 | uint32_t regionCount, const VkBufferImageCopy *pRegions) { |
| 2114 | bool skip = false; |
| 2115 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2116 | |
| 2117 | if (pRegions != nullptr) { |
| 2118 | if ((pRegions->imageSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | |
| 2119 | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) { |
| 2120 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2121 | UNRECOGNIZED_VALUE, LayerName, |
| 2122 | "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized " |
| 2123 | "enumerator"); |
| 2124 | } |
| 2125 | } |
| 2126 | return skip; |
| 2127 | } |
| 2128 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2129 | bool pv_vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 2130 | const void *pData) { |
| 2131 | bool skip = false; |
| 2132 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2133 | |
| 2134 | if (dstOffset & 3) { |
| 2135 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2136 | __LINE__, VALIDATION_ERROR_1e400048, LayerName, |
| 2137 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4. %s", |
| 2138 | dstOffset, validation_error_map[VALIDATION_ERROR_1e400048]); |
| 2139 | } |
| 2140 | |
| 2141 | if ((dataSize <= 0) || (dataSize > 65536)) { |
| 2142 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2143 | __LINE__, VALIDATION_ERROR_1e40004a, LayerName, |
| 2144 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 2145 | "), must be greater than zero and less than or equal to 65536. %s", |
| 2146 | dataSize, validation_error_map[VALIDATION_ERROR_1e40004a]); |
| 2147 | } else if (dataSize & 3) { |
| 2148 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2149 | __LINE__, VALIDATION_ERROR_1e40004c, LayerName, |
| 2150 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4. %s", |
| 2151 | dataSize, validation_error_map[VALIDATION_ERROR_1e40004c]); |
| 2152 | } |
| 2153 | return skip; |
| 2154 | } |
| 2155 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2156 | bool pv_vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
| 2157 | uint32_t data) { |
| 2158 | bool skip = false; |
| 2159 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2160 | |
| 2161 | if (dstOffset & 3) { |
| 2162 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2163 | __LINE__, VALIDATION_ERROR_1b400032, LayerName, |
| 2164 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4. %s", |
| 2165 | dstOffset, validation_error_map[VALIDATION_ERROR_1b400032]); |
| 2166 | } |
| 2167 | |
| 2168 | if (size != VK_WHOLE_SIZE) { |
| 2169 | if (size <= 0) { |
| 2170 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2171 | __LINE__, VALIDATION_ERROR_1b400034, LayerName, |
| 2172 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero. %s", |
| 2173 | size, validation_error_map[VALIDATION_ERROR_1b400034]); |
| 2174 | } else if (size & 3) { |
| 2175 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2176 | __LINE__, VALIDATION_ERROR_1b400038, LayerName, |
| 2177 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4. %s", size, |
| 2178 | validation_error_map[VALIDATION_ERROR_1b400038]); |
| 2179 | } |
| 2180 | } |
| 2181 | return skip; |
| 2182 | } |
| 2183 | |
| 2184 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { |
| 2185 | return util_GetLayerProperties(1, &global_layer, pCount, pProperties); |
| 2186 | } |
| 2187 | |
| 2188 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 2189 | VkLayerProperties *pProperties) { |
| 2190 | return util_GetLayerProperties(1, &global_layer, pCount, pProperties); |
| 2191 | } |
| 2192 | |
| 2193 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 2194 | VkExtensionProperties *pProperties) { |
| 2195 | if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) |
| 2196 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
| 2197 | |
| 2198 | return VK_ERROR_LAYER_NOT_PRESENT; |
| 2199 | } |
| 2200 | |
| 2201 | VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, |
| 2202 | uint32_t *pPropertyCount, VkExtensionProperties *pProperties) { |
| 2203 | // Parameter_validation does not have any physical device extensions |
| 2204 | if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) |
| 2205 | return util_GetExtensionProperties(0, NULL, pPropertyCount, pProperties); |
| 2206 | |
| 2207 | instance_layer_data *local_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map); |
| 2208 | bool skip = |
| 2209 | validate_array(local_data->report_data, "vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", |
| 2210 | pPropertyCount, pProperties, true, false, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_2761f401); |
| 2211 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 2212 | |
| 2213 | return local_data->dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pPropertyCount, pProperties); |
| 2214 | } |
| 2215 | |
| 2216 | static bool require_device_extension(layer_data *device_data, bool flag, char const *function_name, char const *extension_name) { |
| 2217 | if (!flag) { |
| 2218 | return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2219 | __LINE__, EXTENSION_NOT_ENABLED, LayerName, |
| 2220 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 2221 | extension_name); |
| 2222 | } |
| 2223 | |
| 2224 | return false; |
| 2225 | } |
| 2226 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2227 | bool pv_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 2228 | VkSwapchainKHR *pSwapchain) { |
| 2229 | bool skip = false; |
| 2230 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2231 | debug_report_data *report_data = device_data->report_data; |
| 2232 | |
| 2233 | if (pCreateInfo != nullptr) { |
| 2234 | if ((device_data->physical_device_features.textureCompressionETC2 == false) && |
| 2235 | FormatIsCompressed_ETC2_EAC(pCreateInfo->imageFormat)) { |
| 2236 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2237 | DEVICE_FEATURE, LayerName, |
| 2238 | "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The " |
| 2239 | "textureCompressionETC2 feature is not enabled: neither ETC2 nor EAC formats can be used to create " |
| 2240 | "images.", |
| 2241 | string_VkFormat(pCreateInfo->imageFormat)); |
| 2242 | } |
| 2243 | |
| 2244 | if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) && |
| 2245 | FormatIsCompressed_ASTC_LDR(pCreateInfo->imageFormat)) { |
| 2246 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2247 | DEVICE_FEATURE, LayerName, |
| 2248 | "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The " |
| 2249 | "textureCompressionASTC_LDR feature is not enabled: ASTC formats cannot be used to create images.", |
| 2250 | string_VkFormat(pCreateInfo->imageFormat)); |
| 2251 | } |
| 2252 | |
| 2253 | if ((device_data->physical_device_features.textureCompressionBC == false) && |
| 2254 | FormatIsCompressed_BC(pCreateInfo->imageFormat)) { |
| 2255 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2256 | DEVICE_FEATURE, LayerName, |
| 2257 | "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The " |
| 2258 | "textureCompressionBC feature is not enabled: BC compressed formats cannot be used to create images.", |
| 2259 | string_VkFormat(pCreateInfo->imageFormat)); |
| 2260 | } |
| 2261 | |
| 2262 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2263 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 2264 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 2265 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
| 2266 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2267 | VALIDATION_ERROR_146009fc, LayerName, |
| 2268 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 2269 | "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s", |
| 2270 | validation_error_map[VALIDATION_ERROR_146009fc]); |
| 2271 | } |
| 2272 | |
| 2273 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 2274 | // queueFamilyIndexCount uint32_t values |
| 2275 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
| 2276 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 2277 | VALIDATION_ERROR_146009fa, LayerName, |
| 2278 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 2279 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 2280 | "pCreateInfo->queueFamilyIndexCount uint32_t values. %s", |
| 2281 | validation_error_map[VALIDATION_ERROR_146009fa]); |
| 2282 | } else { |
| 2283 | // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved. |
| 2284 | skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices, |
| 2285 | "vkCreateSwapchainKHR", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, |
| 2286 | INVALID_USAGE, false, "", ""); |
| 2287 | } |
| 2288 | } |
| 2289 | |
| 2290 | // imageArrayLayers must be greater than 0 |
| 2291 | skip |= ValidateGreaterThan(report_data, "vkCreateSwapchainKHR", "pCreateInfo->imageArrayLayers", |
| 2292 | pCreateInfo->imageArrayLayers, 0u); |
| 2293 | } |
| 2294 | |
| 2295 | return skip; |
| 2296 | } |
| 2297 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2298 | bool pv_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { |
| 2299 | bool skip = false; |
| 2300 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 2301 | |
| 2302 | if (pPresentInfo && pPresentInfo->pNext) { |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 2303 | const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
| 2304 | if (present_regions) { |
| 2305 | // TODO: This and all other pNext extension dependencies should be added to code-generation |
| 2306 | skip |= require_device_extension(device_data, device_data->extensions.vk_khr_incremental_present, "vkQueuePresentKHR", |
| 2307 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 2308 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
| 2309 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2310 | __LINE__, INVALID_USAGE, LayerName, |
| 2311 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i" |
| 2312 | " but VkPresentRegionsKHR extension swapchainCount is %i. These values must be equal.", |
| 2313 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
| 2314 | } |
| 2315 | skip |= validate_struct_pnext(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, |
| 2316 | present_regions->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_1121c40d); |
| 2317 | skip |= validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", |
| 2318 | "pCreateInfo->pNext->pRegions", present_regions->swapchainCount, present_regions->pRegions, true, |
| 2319 | false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); |
| 2320 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
| 2321 | skip |= validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2322 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
| 2323 | present_regions->pRegions[i].pRectangles, true, false, VALIDATION_ERROR_UNDEFINED, |
| 2324 | VALIDATION_ERROR_UNDEFINED); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2325 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | return skip; |
| 2330 | } |
| 2331 | |
| 2332 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2333 | bool pv_vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 2334 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
| 2335 | auto device_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 2336 | bool skip = false; |
| 2337 | |
| 2338 | if (pCreateInfo->hwnd == nullptr) { |
| 2339 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2340 | __LINE__, VALIDATION_ERROR_15a00a38, LayerName, |
| 2341 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL. %s", |
| 2342 | validation_error_map[VALIDATION_ERROR_15a00a38]); |
| 2343 | } |
| 2344 | |
| 2345 | return skip; |
| 2346 | } |
| 2347 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 2348 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2349 | bool pv_vkDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
| 2350 | auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2351 | if (pNameInfo->pObjectName) { |
| 2352 | device_data->report_data->debugObjectNameMap->insert( |
| 2353 | std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName)); |
| 2354 | } else { |
| 2355 | device_data->report_data->debugObjectNameMap->erase(pNameInfo->object); |
| 2356 | } |
| 2357 | return false; |
| 2358 | } |
| 2359 | |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2360 | bool pv_vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
| 2361 | const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool) { |
| 2362 | auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2363 | bool skip = false; |
| 2364 | |
| 2365 | if (pCreateInfo) { |
| 2366 | if (pCreateInfo->maxSets <= 0) { |
| 2367 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2368 | VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_0480025a, |
| 2369 | LayerName, "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0. %s", |
| 2370 | validation_error_map[VALIDATION_ERROR_0480025a]); |
| 2371 | } |
| 2372 | |
| 2373 | if (pCreateInfo->pPoolSizes) { |
| 2374 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 2375 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
| 2376 | skip |= log_msg( |
| 2377 | device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, |
| 2378 | VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_04a0025c, LayerName, |
| 2379 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0. %s", |
| 2380 | i, validation_error_map[VALIDATION_ERROR_04a0025c]); |
| 2381 | } |
| 2382 | } |
| 2383 | } |
| 2384 | } |
| 2385 | |
| 2386 | return skip; |
| 2387 | } |
| 2388 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2389 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *funcName) { |
| 2390 | const auto item = name_to_funcptr_map.find(funcName); |
| 2391 | if (item != name_to_funcptr_map.end()) { |
| 2392 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 2393 | } |
| 2394 | |
| 2395 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 2396 | const auto &table = device_data->dispatch_table; |
| 2397 | if (!table.GetDeviceProcAddr) return nullptr; |
| 2398 | return table.GetDeviceProcAddr(device, funcName); |
| 2399 | } |
| 2400 | |
| 2401 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 2402 | const auto item = name_to_funcptr_map.find(funcName); |
| 2403 | if (item != name_to_funcptr_map.end()) { |
| 2404 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 2405 | } |
| 2406 | |
| 2407 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 2408 | auto &table = instance_data->dispatch_table; |
| 2409 | if (!table.GetInstanceProcAddr) return nullptr; |
| 2410 | return table.GetInstanceProcAddr(instance, funcName); |
| 2411 | } |
| 2412 | |
| 2413 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { |
| 2414 | assert(instance); |
| 2415 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); |
| 2416 | |
| 2417 | if (!instance_data->dispatch_table.GetPhysicalDeviceProcAddr) return nullptr; |
| 2418 | return instance_data->dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); |
| 2419 | } |
| 2420 | |
| 2421 | // If additional validation is needed outside of the generated checks, a manual routine can be added to this file |
| 2422 | // 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] | 2423 | void InitializeManualParameterValidationFunctionPointers() { |
Mark Lobodzinski | 78a12a9 | 2017-08-08 14:16:51 -0600 | [diff] [blame] | 2424 | custom_functions["vkGetDeviceQueue"] = (void*)pv_vkGetDeviceQueue; |
| 2425 | custom_functions["vkCreateBuffer"] = (void*)pv_vkCreateBuffer; |
| 2426 | custom_functions["vkCreateImage"] = (void*)pv_vkCreateImage; |
| 2427 | custom_functions["vkCreateImageView"] = (void*)pv_vkCreateImageView; |
| 2428 | custom_functions["vkCreateGraphicsPipelines"] = (void*)pv_vkCreateGraphicsPipelines; |
| 2429 | custom_functions["vkCreateComputePipelines"] = (void*)pv_vkCreateComputePipelines; |
| 2430 | custom_functions["vkCreateSampler"] = (void*)pv_vkCreateSampler; |
| 2431 | custom_functions["vkCreateDescriptorSetLayout"] = (void*)pv_vkCreateDescriptorSetLayout; |
| 2432 | custom_functions["vkFreeDescriptorSets"] = (void*)pv_vkFreeDescriptorSets; |
| 2433 | custom_functions["vkUpdateDescriptorSets"] = (void*)pv_vkUpdateDescriptorSets; |
| 2434 | custom_functions["vkCreateRenderPass"] = (void*)pv_vkCreateRenderPass; |
| 2435 | custom_functions["vkBeginCommandBuffer"] = (void*)pv_vkBeginCommandBuffer; |
| 2436 | custom_functions["vkCmdSetViewport"] = (void*)pv_vkCmdSetViewport; |
| 2437 | custom_functions["vkCmdSetScissor"] = (void*)pv_vkCmdSetScissor; |
| 2438 | custom_functions["vkCmdDraw"] = (void*)pv_vkCmdDraw; |
| 2439 | custom_functions["vkCmdDrawIndirect"] = (void*)pv_vkCmdDrawIndirect; |
| 2440 | custom_functions["vkCmdDrawIndexedIndirect"] = (void*)pv_vkCmdDrawIndexedIndirect; |
| 2441 | custom_functions["vkCmdCopyImage"] = (void*)pv_vkCmdCopyImage; |
| 2442 | custom_functions["vkCmdBlitImage"] = (void*)pv_vkCmdBlitImage; |
| 2443 | custom_functions["vkCmdCopyBufferToImage"] = (void*)pv_vkCmdCopyBufferToImage; |
| 2444 | custom_functions["vkCmdCopyImageToBuffer"] = (void*)pv_vkCmdCopyImageToBuffer; |
| 2445 | custom_functions["vkCmdUpdateBuffer"] = (void*)pv_vkCmdUpdateBuffer; |
| 2446 | custom_functions["vkCmdFillBuffer"] = (void*)pv_vkCmdFillBuffer; |
| 2447 | custom_functions["vkCreateSwapchainKHR"] = (void*)pv_vkCreateSwapchainKHR; |
| 2448 | custom_functions["vkQueuePresentKHR"] = (void*)pv_vkQueuePresentKHR; |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2449 | custom_functions["vkCreateDescriptorPool"] = (void*)pv_vkCreateDescriptorPool; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2450 | } |
| 2451 | |
| 2452 | } // namespace parameter_validation |
| 2453 | |
| 2454 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 2455 | VkExtensionProperties *pProperties) { |
| 2456 | return parameter_validation::vkEnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties); |
| 2457 | } |
| 2458 | |
| 2459 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, |
| 2460 | VkLayerProperties *pProperties) { |
| 2461 | return parameter_validation::vkEnumerateInstanceLayerProperties(pCount, pProperties); |
| 2462 | } |
| 2463 | |
| 2464 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 2465 | VkLayerProperties *pProperties) { |
| 2466 | // the layer command handles VK_NULL_HANDLE just fine internally |
| 2467 | assert(physicalDevice == VK_NULL_HANDLE); |
| 2468 | return parameter_validation::vkEnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties); |
| 2469 | } |
| 2470 | |
| 2471 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 2472 | const char *pLayerName, uint32_t *pCount, |
| 2473 | VkExtensionProperties *pProperties) { |
| 2474 | // the layer command handles VK_NULL_HANDLE just fine internally |
| 2475 | assert(physicalDevice == VK_NULL_HANDLE); |
| 2476 | return parameter_validation::vkEnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties); |
| 2477 | } |
| 2478 | |
| 2479 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { |
| 2480 | return parameter_validation::vkGetDeviceProcAddr(dev, funcName); |
| 2481 | } |
| 2482 | |
| 2483 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 2484 | return parameter_validation::vkGetInstanceProcAddr(instance, funcName); |
| 2485 | } |
| 2486 | |
| 2487 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, |
| 2488 | const char *funcName) { |
| 2489 | return parameter_validation::vkGetPhysicalDeviceProcAddr(instance, funcName); |
| 2490 | } |
| 2491 | |
| 2492 | VK_LAYER_EXPORT bool pv_vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) { |
| 2493 | assert(pVersionStruct != NULL); |
| 2494 | assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT); |
| 2495 | |
| 2496 | // Fill in the function pointers if our version is at least capable of having the structure contain them. |
| 2497 | if (pVersionStruct->loaderLayerInterfaceVersion >= 2) { |
| 2498 | pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr; |
| 2499 | pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr; |
| 2500 | pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr; |
| 2501 | } |
| 2502 | |
| 2503 | if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 2504 | parameter_validation::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion; |
| 2505 | } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 2506 | pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 2507 | } |
| 2508 | |
| 2509 | return VK_SUCCESS; |
| 2510 | } |