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