aitor-lunarg | d530159 | 2022-01-05 22:38:16 +0100 | [diff] [blame] | 1 | /* Copyright (c) 2015-2022 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2022 Valve Corporation |
| 3 | * Copyright (c) 2015-2022 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2022 Google Inc. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 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> |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 19 | * Author: John Zulauf <jzulauf@lunarg.com> |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 20 | */ |
| 21 | |
orbea | 80ddc06 | 2019-09-10 10:33:19 -0700 | [diff] [blame] | 22 | #include <cmath> |
Shahbaz Youssefi | 6be1141 | 2019-01-10 15:29:30 -0500 | [diff] [blame] | 23 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 24 | #include "chassis.h" |
| 25 | #include "stateless_validation.h" |
Mark Lobodzinski | e514d1a | 2019-03-12 08:47:45 -0600 | [diff] [blame] | 26 | #include "layer_chassis_dispatch.h" |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 27 | #include "core_validation_error_enums.h" |
Tobias Hector | d942eb9 | 2018-10-22 15:18:56 +0100 | [diff] [blame] | 28 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 29 | static const int kMaxParamCheckerStringLength = 256; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 30 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 31 | template <typename T> |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 32 | inline bool in_inclusive_range(const T &value, const T &min, const T &max) { |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 33 | // Using only < for generality and || for early abort |
| 34 | return !((value < min) || (max < value)); |
| 35 | } |
| 36 | |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 37 | ReadLockGuard StatelessValidation::ReadLock() { return ReadLockGuard(validation_object_mutex, std::defer_lock); } |
| 38 | WriteLockGuard StatelessValidation::WriteLock() { return WriteLockGuard(validation_object_mutex, std::defer_lock); } |
Mark Lobodzinski | 21b91fe | 2020-12-03 15:44:24 -0700 | [diff] [blame] | 39 | |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 40 | static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{}; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 41 | static ReadWriteLock secondary_cb_map_mutex; |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 42 | static ReadLockGuard CBReadLock() { return ReadLockGuard(secondary_cb_map_mutex); } |
| 43 | static WriteLockGuard CBWriteLock() { return WriteLockGuard(secondary_cb_map_mutex); } |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 44 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 45 | bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid, |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 46 | const char *validateString) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 47 | bool skip = false; |
| 48 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 49 | VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 50 | |
| 51 | if (result == VK_STRING_ERROR_NONE) { |
| 52 | return skip; |
| 53 | } else if (result & VK_STRING_ERROR_LENGTH) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 54 | skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 55 | kMaxParamCheckerStringLength); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 56 | } else if (result & VK_STRING_ERROR_BAD_DATA) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 57 | skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName, |
| 58 | stringName.get_name().c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 59 | } |
| 60 | return skip; |
| 61 | } |
| 62 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 63 | bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const { |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 64 | bool skip = false; |
| 65 | uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0); |
| 66 | if (api_version_nopatch != effective_api_version) { |
sfricke-samsung | 6aec21b | 2020-11-01 07:49:43 -0800 | [diff] [blame] | 67 | if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) { |
| 68 | skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 69 | "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 70 | "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 71 | api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version)); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 72 | } else { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 73 | skip |= LogWarning(instance, kVUIDUndefined, |
| 74 | "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 75 | "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 76 | api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version)); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | return skip; |
| 80 | } |
| 81 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 82 | bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const { |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 83 | bool skip = false; |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 84 | // Create and use a local instance extension object, as an actual instance has not been created yet |
| 85 | uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0); |
| 86 | InstanceExtensions local_instance_extensions; |
| 87 | local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo); |
| 88 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 89 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 90 | skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388", |
| 91 | "instance", pCreateInfo->ppEnabledExtensionNames[i]); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 92 | } |
ziga-lunarg | 7334af3 | 2022-03-27 16:48:15 +0200 | [diff] [blame] | 93 | if (pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR && |
| 94 | !local_instance_extensions.vk_khr_portability_enumeration) { |
| 95 | skip |= LogError(instance, "VUID-VkInstanceCreateInfo-flags-06559", |
| 96 | "vkCreateInstance(): pCreateInfo->flags has VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR set, but " |
| 97 | "pCreateInfo->ppEnabledExtensionNames does not include VK_KHR_portability_enumeration"); |
| 98 | } |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 99 | |
| 100 | return skip; |
| 101 | } |
| 102 | |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 103 | bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const { |
Mike Schuchardt | c57de4a | 2021-07-20 17:26:32 -0700 | [diff] [blame] | 104 | if (instance_extensions.vk_khr_get_physical_device_properties2) { |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 105 | // Struct is legal IF it's supported |
| 106 | const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device); |
| 107 | if (dev_exts_enumerated == device_extensions_enumerated.end()) return true; |
| 108 | auto enum_iter = dev_exts_enumerated->second.find(ext_name); |
| 109 | if (enum_iter != dev_exts_enumerated->second.cend()) { |
| 110 | return true; |
| 111 | } |
| 112 | } |
| 113 | return false; |
| 114 | } |
| 115 | |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 116 | bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo, |
| 117 | const VkValidationFeaturesEXT *validation_features) const { |
| 118 | bool skip = false; |
| 119 | bool debug_printf = false; |
| 120 | bool gpu_assisted = false; |
| 121 | bool reserve_slot = false; |
| 122 | for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) { |
| 123 | switch (validation_features->pEnabledValidationFeatures[i]) { |
| 124 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT: |
| 125 | gpu_assisted = true; |
| 126 | break; |
| 127 | |
| 128 | case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT: |
| 129 | debug_printf = true; |
| 130 | break; |
| 131 | |
| 132 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT: |
| 133 | reserve_slot = true; |
| 134 | break; |
| 135 | |
| 136 | default: |
| 137 | break; |
| 138 | } |
| 139 | } |
| 140 | if (reserve_slot && !gpu_assisted) { |
| 141 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967", |
| 142 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, " |
| 143 | "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures."); |
| 144 | } |
| 145 | if (gpu_assisted && debug_printf) { |
| 146 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968", |
| 147 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, " |
| 148 | "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures."); |
| 149 | } |
| 150 | |
| 151 | return skip; |
| 152 | } |
| 153 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 154 | template <typename ExtensionState> |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 155 | ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) { |
| 156 | if (!extension_name) return kNotEnabled; // null strings specify nothing |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 157 | auto info = ExtensionState::get_info(extension_name); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 158 | ExtEnabled state = |
| 159 | info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 160 | return state; |
| 161 | } |
| 162 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 163 | bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 164 | const VkAllocationCallbacks *pAllocator, |
| 165 | VkInstance *pInstance) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 166 | bool skip = false; |
| 167 | // Note: From the spec-- |
| 168 | // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing |
| 169 | // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0) |
| 170 | uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion) |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 171 | ? pCreateInfo->pApplicationInfo->apiVersion |
| 172 | : VK_API_VERSION_1_0; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 173 | skip |= validate_api_version(local_api_version, api_version); |
| 174 | skip |= validate_instance_extensions(pCreateInfo); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 175 | const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext); |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 176 | if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features); |
| 177 | |
Tony-LunarG | 115f89d | 2022-06-15 10:53:22 -0600 | [diff] [blame] | 178 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 179 | auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pCreateInfo->pNext); |
| 180 | while (export_metal_object_info) { |
| 181 | if ((export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT) && |
| 182 | (export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT)) { |
| 183 | skip |= LogError(instance, "VUID-VkInstanceCreateInfo-pNext-06779", |
| 184 | "vkCreateInstance(): The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose " |
| 185 | "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of " |
| 186 | "VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT or " |
| 187 | "VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT are allowed", |
| 188 | string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType)); |
| 189 | } |
| 190 | export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext); |
| 191 | } |
| 192 | #endif // VK_USE_PLATFORM_METAL_EXT |
| 193 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 194 | return skip; |
| 195 | } |
| 196 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 197 | void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 198 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, |
| 199 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 200 | auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 201 | // Copy extension data into local object |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 202 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 203 | this->instance_extensions = instance_data->instance_extensions; |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 204 | } |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 205 | |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 206 | void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) { |
| 207 | // Assume phys_devices is valid |
| 208 | assert(phys_devices); |
| 209 | for (int i = 0; i < count; ++i) { |
| 210 | const auto &phys_device = phys_devices[i]; |
| 211 | if (0 == physical_device_properties_map.count(phys_device)) { |
| 212 | auto phys_dev_props = new VkPhysicalDeviceProperties; |
| 213 | DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props); |
| 214 | physical_device_properties_map[phys_device] = phys_dev_props; |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 215 | |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 216 | // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state |
| 217 | uint32_t ext_count = 0; |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 218 | layer_data::unordered_set<std::string> dev_exts_enumerated{}; |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 219 | std::vector<VkExtensionProperties> ext_props{}; |
| 220 | instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr); |
| 221 | ext_props.resize(ext_count); |
| 222 | instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data()); |
| 223 | for (uint32_t j = 0; j < ext_count; j++) { |
| 224 | dev_exts_enumerated.insert(ext_props[j].extensionName); |
| 225 | } |
| 226 | device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated); |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 227 | } |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
| 231 | void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 232 | VkPhysicalDevice *pPhysicalDevices, VkResult result) { |
| 233 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) { |
| 234 | return; |
| 235 | } |
| 236 | |
| 237 | if (pPhysicalDeviceCount && pPhysicalDevices) { |
| 238 | CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups( |
| 243 | VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties, |
| 244 | VkResult result) { |
| 245 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) { |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) { |
| 250 | for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) { |
| 251 | const auto &group = pPhysicalDeviceGroupProperties[i]; |
| 252 | CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount); |
| 253 | } |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 254 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 257 | void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 258 | for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) { |
| 259 | delete (it->second); |
| 260 | it = physical_device_properties_map.erase(it); |
| 261 | } |
| 262 | }; |
| 263 | |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 264 | |
| 265 | void StatelessValidation::GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, |
| 266 | VkPhysicalDeviceProperties2 &pProperties) const { |
| 267 | if (api_version >= VK_API_VERSION_1_1) { |
| 268 | DispatchGetPhysicalDeviceProperties2(physicalDevice, &pProperties); |
| 269 | } else if (IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) { |
| 270 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &pProperties); |
| 271 | } |
| 272 | } |
| 273 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 274 | void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 275 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 276 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 277 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 278 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); |
| 279 | StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 280 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 281 | // Parmeter validation also uses extension data |
| 282 | stateless_validation->device_extensions = this->device_extensions; |
| 283 | |
| 284 | VkPhysicalDeviceProperties device_properties = {}; |
| 285 | // Need to get instance and do a getlayerdata call... |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 286 | DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 287 | memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 288 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 289 | if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 290 | // Get the needed shading rate image limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 291 | auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); |
| 292 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 293 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 294 | phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; |
| 295 | } |
| 296 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 297 | if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 298 | // Get the needed mesh shader limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 299 | auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>(); |
| 300 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 301 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 302 | phys_dev_ext_props.mesh_shader_props = mesh_shader_props; |
| 303 | } |
| 304 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 305 | if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 306 | // Get the needed ray tracing limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 307 | auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>(); |
| 308 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 309 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 310 | phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props; |
| 311 | } |
| 312 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 313 | if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 314 | // Get the needed ray tracing limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 315 | auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>(); |
| 316 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 317 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 318 | phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props; |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 319 | } |
| 320 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 321 | if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 322 | // Get the needed ray tracing acc structure limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 323 | auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>(); |
| 324 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 325 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 326 | phys_dev_ext_props.acc_structure_props = acc_structure_props; |
| 327 | } |
| 328 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 329 | if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) { |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 330 | // Get the needed transform feedback limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 331 | auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
| 332 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 333 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 334 | phys_dev_ext_props.transform_feedback_props = transform_feedback_props; |
| 335 | } |
| 336 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 337 | if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) { |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 338 | // Get the needed vertex attribute divisor limits |
| 339 | auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>(); |
| 340 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 341 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 342 | phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props; |
| 343 | } |
| 344 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 345 | if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) { |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 346 | // Get the needed blend operation advanced properties |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 347 | auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>(); |
| 348 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 349 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 350 | phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props; |
| 351 | } |
| 352 | |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 353 | if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) { |
| 354 | // Get the needed maintenance4 properties |
| 355 | auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>(); |
| 356 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props); |
ziga-lunarg | 685d5d6 | 2022-05-14 00:38:06 +0200 | [diff] [blame] | 357 | GetPhysicalDeviceProperties2(physicalDevice, prop2); |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 358 | phys_dev_ext_props.maintenance4_props = maintance4_props; |
| 359 | } |
| 360 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 361 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 362 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 363 | // Save app-enabled features in this device's validation object |
| 364 | // The enabled features can come from either pEnabledFeatures, or from the pNext chain |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 365 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 366 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 367 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 368 | if (features2) { |
| 369 | tmp_features2_state.features = features2->features; |
| 370 | } else if (pCreateInfo->pEnabledFeatures) { |
| 371 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 372 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 373 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 374 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 375 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 376 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 377 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 378 | } |
| 379 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 380 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 381 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 382 | bool skip = false; |
| 383 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 384 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 385 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 386 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 387 | } |
| 388 | |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 389 | // If this device supports VK_KHR_portability_subset, it must be enabled |
| 390 | const std::string portability_extension_name("VK_KHR_portability_subset"); |
| 391 | const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice); |
| 392 | const bool portability_supported = dev_extensions.count(portability_extension_name) != 0; |
| 393 | bool portability_requested = false; |
| 394 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 395 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 396 | skip |= |
| 397 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 398 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 399 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 400 | pCreateInfo->ppEnabledExtensionNames[i]); |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 401 | if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) { |
| 402 | portability_requested = true; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | if (portability_supported && !portability_requested) { |
| 407 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451", |
| 408 | "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it", |
| 409 | report_data->FormatHandle(physicalDevice).c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 410 | } |
| 411 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 412 | { |
aitor-lunarg | d530159 | 2022-01-05 22:38:16 +0100 | [diff] [blame] | 413 | bool maint1 = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME)); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 414 | bool negative_viewport = |
aitor-lunarg | d530159 | 2022-01-05 22:38:16 +0100 | [diff] [blame] | 415 | IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME)); |
| 416 | if (negative_viewport) { |
| 417 | // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to |
| 418 | // integration into api version 1.1 |
| 419 | if (api_version >= VK_API_VERSION_1_1) { |
| 420 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840", |
| 421 | "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not include " |
| 422 | "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1."); |
| 423 | } else if (maint1) { |
| 424 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 425 | "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include " |
| 426 | "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height."); |
| 427 | } |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 428 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 429 | } |
| 430 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 431 | { |
ziga-lunarg | 9271a7c | 2021-07-19 16:37:06 +0200 | [diff] [blame] | 432 | bool khr_bda = |
| 433 | IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 434 | bool ext_bda = |
| 435 | IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 436 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 437 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 438 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 439 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 443 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 444 | // Check for get_physical_device_properties2 struct |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 445 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 446 | if (features2) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 447 | // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 448 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 449 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 450 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 451 | } |
| 452 | } |
| 453 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 454 | auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 455 | const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 456 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 457 | if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { |
| 458 | skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", |
| 459 | "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); |
| 460 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 461 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 462 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed && |
| 463 | !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) { |
| 464 | skip |= LogError( |
| 465 | device, |
| 466 | "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575", |
| 467 | "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay " |
| 468 | "must also be VK_TRUE."); |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 469 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 470 | auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 471 | if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) { |
Mark Lobodzinski | 3e66ae8 | 2020-08-12 16:27:29 -0600 | [diff] [blame] | 472 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 473 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 474 | "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device."); |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 475 | } |
| 476 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 477 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 478 | if (vulkan_11_features) { |
| 479 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 480 | while (current) { |
| 481 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 482 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 483 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 484 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 485 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 486 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 487 | skip |= LogError( |
| 488 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 489 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 490 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 491 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 492 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 493 | break; |
| 494 | } |
| 495 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 496 | } |
sfricke-samsung | ebda679 | 2021-01-16 08:57:52 -0800 | [diff] [blame] | 497 | |
| 498 | // Check features are enabled if matching extension is passed in as well |
| 499 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 500 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 501 | if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 502 | (vulkan_11_features->shaderDrawParameters == VK_FALSE)) { |
| 503 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 504 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476", |
sfricke-samsung | ebda679 | 2021-01-16 08:57:52 -0800 | [diff] [blame] | 505 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.", |
| 506 | VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME); |
| 507 | } |
| 508 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 509 | } |
| 510 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 511 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 512 | if (vulkan_12_features) { |
| 513 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 514 | while (current) { |
| 515 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 516 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 517 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 518 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 519 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 520 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 521 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 522 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 523 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 524 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 525 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 526 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 527 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 528 | skip |= LogError( |
| 529 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 530 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 531 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 532 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 533 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 534 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 535 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 536 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 537 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 538 | break; |
| 539 | } |
| 540 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 541 | } |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 542 | // Check features are enabled if matching extension is passed in as well |
| 543 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 544 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 545 | if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 546 | (vulkan_12_features->drawIndirectCount == VK_FALSE)) { |
| 547 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 548 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 549 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", |
| 550 | VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 551 | } |
| 552 | if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 553 | (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 554 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 555 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " |
| 556 | "is not VK_TRUE.", |
| 557 | VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); |
| 558 | } |
| 559 | if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 560 | (vulkan_12_features->descriptorIndexing == VK_FALSE)) { |
| 561 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 562 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 563 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", |
| 564 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 565 | } |
| 566 | if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 567 | (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { |
| 568 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 569 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 570 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", |
| 571 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 572 | } |
| 573 | if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 574 | ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || |
| 575 | (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { |
| 576 | skip |= |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 577 | LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 578 | "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " |
| 579 | "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", |
| 580 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); |
| 581 | } |
| 582 | } |
ziga-lunarg | 27f88fd | 2021-08-01 15:47:30 +0200 | [diff] [blame] | 583 | if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) { |
| 584 | if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) { |
| 585 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748", |
| 586 | "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress " |
| 587 | "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address"); |
| 588 | } |
| 589 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Tony-LunarG | 273f32f | 2021-09-28 08:56:30 -0600 | [diff] [blame] | 592 | const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(pCreateInfo->pNext); |
| 593 | if (vulkan_13_features) { |
| 594 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 595 | while (current) { |
| 596 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES || |
| 597 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES || |
| 598 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES || |
| 599 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES || |
| 600 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES || |
| 601 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES || |
| 602 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES || |
| 603 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES || |
| 604 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES || |
| 605 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES || |
| 606 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES || |
| 607 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES || |
| 608 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES) { |
Nathaniel Cesario | 7a1f5b0 | 2022-06-06 12:32:59 -0600 | [diff] [blame] | 609 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-06532", |
| 610 | "vkCreateDevice(): %s structure included in VkPhysicalDeviceVulkan13Features' pNext chain.", |
| 611 | string_VkStructureType(current->sType)); |
Tony-LunarG | 273f32f | 2021-09-28 08:56:30 -0600 | [diff] [blame] | 612 | break; |
| 613 | } |
| 614 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 615 | } |
| 616 | } |
| 617 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 618 | // Validate pCreateInfo->pQueueCreateInfos |
| 619 | if (pCreateInfo->pQueueCreateInfos) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 620 | |
| 621 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 622 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
| 623 | const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 624 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 625 | skip |= |
| 626 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 627 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 628 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 629 | "index value.", |
| 630 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 631 | } |
| 632 | |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 633 | if (queue_create_info.pQueuePriorities != nullptr) { |
| 634 | for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { |
| 635 | const float queue_priority = queue_create_info.pQueuePriorities[j]; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 636 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 637 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 638 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 639 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 640 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 641 | } |
| 642 | } |
| 643 | } |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 644 | |
| 645 | // Need to know if protectedMemory feature is passed in preCall to creating the device |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 646 | VkBool32 protected_memory = VK_FALSE; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 647 | const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 648 | LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 649 | if (protected_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 650 | protected_memory = protected_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 651 | } else if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 652 | protected_memory = vulkan_11_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 653 | } |
Mike Schuchardt | a9101d3 | 2021-11-12 12:24:08 -0800 | [diff] [blame] | 654 | if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 655 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", |
Mike Schuchardt | a9101d3 | 2021-11-12 12:24:08 -0800 | [diff] [blame] | 656 | "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " |
| 657 | "protectedMemory feature being enabled as well."); |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 658 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 659 | } |
| 660 | } |
| 661 | |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 662 | // feature dependencies for VK_KHR_variable_pointers |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 663 | const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 664 | VkBool32 variable_pointers = VK_FALSE; |
| 665 | VkBool32 variable_pointers_storage_buffer = VK_FALSE; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 666 | if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 667 | variable_pointers = vulkan_11_features->variablePointers; |
| 668 | variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 669 | } else if (variable_pointers_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 670 | variable_pointers = variable_pointers_features->variablePointers; |
| 671 | variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 672 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 673 | if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) { |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 674 | skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431", |
| 675 | "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE"); |
| 676 | } |
| 677 | |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 678 | // feature dependencies for VK_KHR_multiview |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 679 | const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 680 | VkBool32 multiview = VK_FALSE; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 681 | VkBool32 multiview_geometry_shader = VK_FALSE; |
| 682 | VkBool32 multiview_tessellation_shader = VK_FALSE; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 683 | if (vulkan_11_features) { |
| 684 | multiview = vulkan_11_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 685 | multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader; |
| 686 | multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 687 | } else if (multiview_features) { |
| 688 | multiview = multiview_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 689 | multiview_geometry_shader = multiview_features->multiviewGeometryShader; |
| 690 | multiview_tessellation_shader = multiview_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 691 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 692 | if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 693 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580", |
| 694 | "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 695 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 696 | if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 697 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581", |
| 698 | "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 699 | } |
| 700 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 701 | return skip; |
| 702 | } |
| 703 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 704 | bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 705 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 706 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 707 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 708 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 709 | } |
| 710 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 711 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 712 | } |
| 713 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 714 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 715 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 716 | bool skip = false; |
| 717 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 718 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 719 | skip |= |
| 720 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 721 | |
| 722 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 723 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 724 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 725 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 726 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 727 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 728 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 732 | // queueFamilyIndexCount uint32_t values |
| 733 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 734 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 735 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 736 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 737 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 738 | } |
| 739 | } |
| 740 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 741 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
| 742 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915", |
| 743 | "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the " |
| 744 | "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set."); |
| 745 | } |
| 746 | |
| 747 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) { |
| 748 | skip |= |
| 749 | LogError(device, "VUID-VkBufferCreateInfo-flags-00916", |
| 750 | "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with " |
| 751 | "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set."); |
| 752 | } |
| 753 | |
| 754 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 755 | skip |= |
| 756 | LogError(device, "VUID-VkBufferCreateInfo-flags-00917", |
| 757 | "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with " |
| 758 | "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set."); |
| 759 | } |
| 760 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 761 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 762 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 763 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 764 | ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 765 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 766 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 767 | "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 768 | } |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 769 | |
| 770 | const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext); |
| 771 | if (maintenance4_features && maintenance4_features->maintenance4) { |
| 772 | if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) { |
| 773 | skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409", |
| 774 | "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size " |
| 775 | "VkPhysicalDeviceMaintenance4Properties.maxBufferSize"); |
| 776 | } |
| 777 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | return skip; |
| 781 | } |
| 782 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 783 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 784 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 785 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 786 | |
| 787 | if (pCreateInfo != nullptr) { |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 788 | const VkFormat image_format = pCreateInfo->format; |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 789 | const VkImageCreateFlags image_flags = pCreateInfo->flags; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 790 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 791 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 792 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 793 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 794 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942", |
| 795 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 796 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 800 | // queueFamilyIndexCount uint32_t values |
| 801 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 802 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941", |
| 803 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 804 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 805 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 806 | } |
| 807 | } |
| 808 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 809 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 810 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 811 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 812 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 813 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 814 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 815 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 816 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 817 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 818 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 819 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 820 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 821 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 822 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 823 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 824 | skip |= LogError( |
| 825 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 826 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 827 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 828 | } |
| 829 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 830 | // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1 |
Petr Kraus | 3ac9e81 | 2018-03-13 12:31:08 +0100 | [diff] [blame] | 831 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 832 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 833 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 834 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 835 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 839 | if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 840 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 841 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 842 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 843 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 844 | ") are not equal.", |
| 845 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 849 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 850 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 851 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 852 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 853 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 857 | skip |= LogError( |
| 858 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 859 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 860 | } |
| 861 | } |
| 862 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 863 | // 3D image may have only 1 layer |
| 864 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 865 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 866 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 869 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 870 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 871 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 872 | // At least one of the legal attachment bits must be set |
| 873 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 874 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 875 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 876 | } |
| 877 | // No flags other than the legal attachment bits may be set |
| 878 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 879 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 880 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 881 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 882 | } |
| 883 | } |
| 884 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 885 | // mipLevels must be less than or equal to the number of levels in the complete mipmap chain |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 886 | uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 887 | // Max mip levels is different for corner-sampled images vs normal images. |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 888 | uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 889 | ? static_cast<uint32_t>(ceil(log2(max_dim))) |
| 890 | : static_cast<uint32_t>(floor(log2(max_dim)) + 1); |
| 891 | if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 892 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 893 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 894 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 895 | "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 896 | } |
| 897 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 898 | if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 899 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 900 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 901 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 902 | } |
| 903 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 904 | if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 905 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 906 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 907 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 908 | } |
| 909 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 910 | if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 911 | skip |= LogError( |
| 912 | device, "VUID-VkImageCreateInfo-flags-01924", |
| 913 | "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the " |
| 914 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set."); |
| 915 | } |
| 916 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 917 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 918 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 919 | if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 920 | ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 921 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 922 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 923 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 927 | if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 928 | // Linear tiling is unsupported |
| 929 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
sfricke-samsung | 9801d75 | 2020-08-23 22:00:16 -0700 | [diff] [blame] | 930 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 931 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 932 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | // Sparse 1D image isn't valid |
| 936 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 937 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 938 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 939 | } |
| 940 | |
| 941 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 942 | if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 943 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 944 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 945 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 949 | if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 950 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 951 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 952 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | // Multi-sample 2D image when device doesn't support it |
| 956 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 957 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 958 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 959 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 960 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 961 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 962 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 963 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 964 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 965 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 966 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 967 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 968 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 969 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 970 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 971 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 972 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 973 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 974 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 975 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 976 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 977 | } |
| 978 | } |
| 979 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 980 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 981 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 982 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 983 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 984 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 985 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 986 | } |
| 987 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 988 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 989 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 990 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 991 | } |
| 992 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 993 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 994 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 995 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 996 | } |
| 997 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 998 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 999 | if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1000 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1001 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 1002 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 1003 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1004 | } |
| 1005 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1006 | if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1007 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 1008 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1009 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a " |
| 1010 | "depth/stencil format.", |
| 1011 | string_VkFormat(image_format)); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1012 | } |
| 1013 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1014 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1015 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 1016 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 1017 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 1018 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1019 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1020 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1021 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 1022 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 1023 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 1024 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1025 | } |
| 1026 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1027 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1028 | if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) && |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1029 | (FormatHasDepth(image_format) == false)) { |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 1030 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533", |
| 1031 | "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the " |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1032 | "format (%s) must be a depth or depth/stencil format.", |
| 1033 | string_VkFormat(image_format)); |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 1034 | } |
| 1035 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1036 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1037 | if (image_stencil_struct != nullptr) { |
| 1038 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 1039 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 1040 | // No flags other than the legal attachment bits may be set |
| 1041 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 1042 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1043 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 1044 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 1045 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 1046 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1047 | } |
| 1048 | } |
| 1049 | |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1050 | if (FormatIsDepthOrStencil(image_format)) { |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1051 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 1052 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1053 | skip |= |
| 1054 | LogError(device, "VUID-VkImageCreateInfo-Format-02536", |
| 1055 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 1056 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32 |
| 1057 | ") exceeds device " |
| 1058 | "maxFramebufferWidth (%" PRIu32 ")", |
| 1059 | pCreateInfo->extent.width, device_limits.maxFramebufferWidth); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1063 | skip |= |
| 1064 | LogError(device, "VUID-VkImageCreateInfo-format-02537", |
| 1065 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 1066 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32 |
| 1067 | ") exceeds device " |
| 1068 | "maxFramebufferHeight (%" PRIu32 ")", |
| 1069 | pCreateInfo->extent.height, device_limits.maxFramebufferHeight); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | if (!physical_device_features.shaderStorageImageMultisample && |
| 1074 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 1075 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 1076 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1077 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 1078 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 1079 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 1080 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 1084 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1085 | skip |= LogError( |
| 1086 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1087 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 1088 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1089 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 1090 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 1091 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1092 | skip |= LogError( |
| 1093 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1094 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 1095 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 1096 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1097 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 1098 | } |
| 1099 | |
| 1100 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 1101 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1102 | skip |= LogError( |
| 1103 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1104 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 1105 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1106 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 1107 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 1108 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1109 | skip |= LogError( |
| 1110 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1111 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 1112 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 1113 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1114 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 1115 | } |
| 1116 | } |
| 1117 | } |
Spencer Fricke | ca52b5c | 2020-03-16 17:34:00 -0700 | [diff] [blame] | 1118 | |
| 1119 | if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 1120 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 1121 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968", |
| 1122 | "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images " |
| 1123 | "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
| 1124 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1125 | |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1126 | std::vector<uint64_t> image_create_drm_format_modifiers; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1127 | if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1128 | const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext); |
| 1129 | const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext); |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1130 | if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1131 | if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) || |
| 1132 | ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) { |
| 1133 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261", |
| 1134 | "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have " |
| 1135 | "either VkImageDrmFormatModifierListCreateInfoEXT or " |
| 1136 | "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain"); |
Martin Freebody | 0ec2c7a | 2021-03-03 16:48:00 +0000 | [diff] [blame] | 1137 | } else if (drm_format_mod_explict != nullptr) { |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1138 | image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier); |
| 1139 | } else if (drm_format_mod_list != nullptr) { |
| 1140 | for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) { |
| 1141 | image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers); |
| 1142 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1143 | } |
| 1144 | } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) { |
| 1145 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262", |
| 1146 | "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a " |
| 1147 | "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT " |
| 1148 | "in the pNext chain"); |
| 1149 | } |
| 1150 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1151 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1152 | static const uint64_t drm_format_mod_linear = 0; |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1153 | bool image_create_maybe_linear = false; |
| 1154 | if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) { |
| 1155 | image_create_maybe_linear = true; |
| 1156 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) { |
| 1157 | image_create_maybe_linear = false; |
| 1158 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1159 | image_create_maybe_linear = |
| 1160 | (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(), |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1161 | drm_format_mod_linear) != image_create_drm_format_modifiers.end()); |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 1165 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1166 | ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1167 | (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) { |
| 1168 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 1169 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
| 1170 | } |
| 1171 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1172 | if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) && |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1173 | ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || |
| 1174 | image_create_maybe_linear)) { |
| 1175 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259", |
| 1176 | "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips."); |
| 1177 | } |
| 1178 | |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1179 | if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) { |
| 1180 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1181 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557", |
| 1182 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1183 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1184 | } |
| 1185 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1186 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558", |
| 1187 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1188 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
| 1189 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1190 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1191 | if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) { |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1192 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1193 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565", |
| 1194 | "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1195 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 1196 | } |
| 1197 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1198 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566", |
| 1199 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1200 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1201 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1202 | if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1203 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567", |
| 1204 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1205 | "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT."); |
| 1206 | } |
| 1207 | if (pCreateInfo->mipLevels != 1) { |
| 1208 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1209 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32 |
| 1210 | ") must be 1.", |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1211 | pCreateInfo->mipLevels); |
| 1212 | } |
| 1213 | } |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1214 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1215 | const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1216 | if (swapchain_create_info != nullptr) { |
| 1217 | if (swapchain_create_info->swapchain != VK_NULL_HANDLE) { |
| 1218 | // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the |
| 1219 | // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information |
| 1220 | // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation |
| 1221 | const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995"; |
| 1222 | const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image"; |
| 1223 | |
| 1224 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1225 | // also implicitly forces the check above that extent.depth is 1 |
| 1226 | skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message, |
| 1227 | string_VkImageType(pCreateInfo->imageType)); |
| 1228 | } |
| 1229 | if (pCreateInfo->mipLevels != 1) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1230 | skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message, |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1231 | pCreateInfo->mipLevels); |
| 1232 | } |
| 1233 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1234 | skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.", |
| 1235 | base_message, string_VkSampleCountFlagBits(pCreateInfo->samples)); |
| 1236 | } |
| 1237 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1238 | skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.", |
| 1239 | base_message, string_VkImageTiling(pCreateInfo->tiling)); |
| 1240 | } |
| 1241 | if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) { |
| 1242 | skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.", |
| 1243 | base_message, string_VkImageLayout(pCreateInfo->initialLayout)); |
| 1244 | } |
| 1245 | const VkImageCreateFlags valid_flags = |
| 1246 | (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1247 | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT); |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1248 | if ((image_flags & ~valid_flags) != 0) { |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1249 | skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message, |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1250 | image_flags); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1251 | } |
| 1252 | } |
| 1253 | } |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1254 | |
| 1255 | // If Chroma subsampled format ( _420_ or _422_ ) |
| 1256 | if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) { |
| 1257 | skip |= |
| 1258 | LogError(device, "VUID-VkImageCreateInfo-format-04712", |
| 1259 | "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32 |
| 1260 | ") must be a multiple of 2.", |
| 1261 | string_VkFormat(image_format), pCreateInfo->extent.width); |
| 1262 | } |
| 1263 | if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) { |
| 1264 | skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713", |
| 1265 | "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32 |
| 1266 | ") must be a multiple of 2.", |
| 1267 | string_VkFormat(image_format), pCreateInfo->extent.height); |
| 1268 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1269 | |
| 1270 | const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext); |
| 1271 | if (format_list_info) { |
| 1272 | const uint32_t viewFormatCount = format_list_info->viewFormatCount; |
| 1273 | if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) { |
| 1274 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738", |
| 1275 | "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1276 | "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.", |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1277 | viewFormatCount); |
| 1278 | } |
| 1279 | // Check if viewFormatCount is not zero that it is all compatible |
| 1280 | for (uint32_t i = 0; i < viewFormatCount; i++) { |
Mike Schuchardt | b060849 | 2022-04-05 18:52:48 -0700 | [diff] [blame] | 1281 | const bool class_compatible = |
| 1282 | FormatCompatibilityClass(format_list_info->pViewFormats[i]) == FormatCompatibilityClass(image_format); |
| 1283 | if (!class_compatible) { |
| 1284 | if (image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) { |
| 1285 | const bool size_compatible = |
| 1286 | FormatIsCompressed(format_list_info->pViewFormats[i]) |
| 1287 | ? false |
| 1288 | : FormatElementSize(format_list_info->pViewFormats[i]) == FormatElementSize(image_format); |
| 1289 | if (!size_compatible) { |
| 1290 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722", |
| 1291 | "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32 |
| 1292 | "] (%s) and VkImageCreateInfo::format (%s) are not compatible or size-compatible.", |
| 1293 | i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format)); |
| 1294 | } |
| 1295 | } else { |
| 1296 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722", |
| 1297 | "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32 |
| 1298 | "] (%s) and VkImageCreateInfo::format (%s) are not compatible.", |
| 1299 | i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format)); |
| 1300 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1301 | } |
| 1302 | } |
| 1303 | } |
Younggwan Kim | ff6495a | 2021-12-16 20:28:45 +0000 | [diff] [blame] | 1304 | |
| 1305 | const auto image_compression_control = LvlFindInChain<VkImageCompressionControlEXT>(pCreateInfo->pNext); |
| 1306 | if (image_compression_control) { |
| 1307 | constexpr VkImageCompressionFlagsEXT AllVkImageCompressionFlagBitsEXT = |
| 1308 | (VK_IMAGE_COMPRESSION_DEFAULT_EXT | VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT | |
| 1309 | VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT | VK_IMAGE_COMPRESSION_DISABLED_EXT); |
| 1310 | skip |= validate_flags("vkCreateImage", "VkImageCompressionControlEXT::flags", "VkImageCompressionFlagsEXT", |
| 1311 | AllVkImageCompressionFlagBitsEXT, image_compression_control->flags, kRequiredSingleBit, |
| 1312 | "VUID-VkImageCompressionControlEXT-flags-06747"); |
| 1313 | |
| 1314 | if (image_compression_control->flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT && |
| 1315 | !image_compression_control->pFixedRateFlags) { |
| 1316 | skip |= LogError( |
| 1317 | device, "VUID-VkImageCompressionControlEXT-flags-06748", |
| 1318 | "VkImageCompressionControlEXT::pFixedRateFlags is nullptr even though VkImageCompressionControlEXT::flags are %s", |
| 1319 | string_VkImageCompressionFlagsEXT(image_compression_control->flags).c_str()); |
| 1320 | } |
| 1321 | } |
Tony-LunarG | 115f89d | 2022-06-15 10:53:22 -0600 | [diff] [blame] | 1322 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 1323 | auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pCreateInfo->pNext); |
| 1324 | while (export_metal_object_info) { |
| 1325 | if ((export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT) && |
| 1326 | (export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT)) { |
| 1327 | skip |= |
| 1328 | LogError(device, "VUID-VkImageCreateInfo-pNext-06783", |
| 1329 | "vkCreateImage(): The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose " |
| 1330 | "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of " |
| 1331 | "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT or VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT are allowed", |
| 1332 | string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType)); |
| 1333 | } |
| 1334 | export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext); |
| 1335 | } |
| 1336 | auto import_metal_texture_info = LvlFindInChain<VkImportMetalTextureInfoEXT>(pCreateInfo->pNext); |
| 1337 | while (import_metal_texture_info) { |
| 1338 | if ((import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_0_BIT) && |
| 1339 | (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_1_BIT) && |
| 1340 | (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_2_BIT)) { |
| 1341 | skip |= |
| 1342 | LogError(device, "VUID-VkImageCreateInfo-pNext-06784", |
| 1343 | "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose " |
| 1344 | "plane = %s, but only VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, or VK_IMAGE_ASPECT_PLANE_2_BIT are allowed", |
| 1345 | string_VkImageAspectFlags(import_metal_texture_info->plane).c_str()); |
| 1346 | } |
| 1347 | auto format_plane_count = FormatPlaneCount(pCreateInfo->format); |
| 1348 | if ((format_plane_count <= 1) && (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_0_BIT)) { |
| 1349 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06785", |
| 1350 | "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose " |
| 1351 | "plane = %s, but only VK_IMAGE_ASPECT_PLANE_0_BIT is allowed for an image created with format %s, which is not multiplaner", |
| 1352 | string_VkImageAspectFlags(import_metal_texture_info->plane).c_str(), |
| 1353 | string_VkFormat(pCreateInfo->format)); |
| 1354 | } |
| 1355 | if ((format_plane_count == 2) && (import_metal_texture_info->plane == VK_IMAGE_ASPECT_PLANE_2_BIT)) { |
| 1356 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06786", |
| 1357 | "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose " |
| 1358 | "plane == VK_IMAGE_ASPECT_PLANE_2_BIT, which is not allowed for an image created with format %s, " |
| 1359 | "which has only 2 planes", |
| 1360 | string_VkFormat(pCreateInfo->format)); |
| 1361 | } |
| 1362 | import_metal_texture_info = LvlFindInChain<VkImportMetalTextureInfoEXT>(import_metal_texture_info->pNext); |
| 1363 | } |
| 1364 | #endif // VK_USE_PLATFORM_METAL_EXT |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1365 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1366 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1367 | return skip; |
| 1368 | } |
| 1369 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1370 | bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 1371 | const VkAllocationCallbacks *pAllocator, VkImageView *pView) const { |
| 1372 | bool skip = false; |
| 1373 | |
| 1374 | if (pCreateInfo != nullptr) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1375 | // Validate feature set if using CUBE_ARRAY |
| 1376 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) { |
| 1377 | skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004", |
| 1378 | "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without " |
| 1379 | "enabling the imageCubeArray feature."); |
| 1380 | } |
| 1381 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1382 | if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 1383 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) { |
| 1384 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1385 | "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32 |
| 1386 | ") must be 6 or VK_REMAINING_ARRAY_LAYERS.", |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1387 | pCreateInfo->subresourceRange.layerCount); |
| 1388 | } |
| 1389 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1390 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961", |
| 1391 | "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32 |
| 1392 | ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.", |
| 1393 | pCreateInfo->subresourceRange.layerCount); |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1394 | } |
| 1395 | } |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1396 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1397 | auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1398 | if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) { |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1399 | if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) && |
| 1400 | (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) && |
| 1401 | (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) { |
| 1402 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230", |
| 1403 | "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be " |
| 1404 | "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32."); |
| 1405 | } |
sfricke-samsung | e308629 | 2021-11-18 23:02:35 -0800 | [diff] [blame] | 1406 | if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) && |
| 1407 | (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) { |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1408 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084", |
| 1409 | "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and " |
| 1410 | "not an ASTC format.", |
| 1411 | string_VkFormat(pCreateInfo->format)); |
| 1412 | } |
| 1413 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1414 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1415 | auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1416 | if (ycbcr_conversion != nullptr) { |
| 1417 | if (ycbcr_conversion->conversion != VK_NULL_HANDLE) { |
| 1418 | if (IsIdentitySwizzle(pCreateInfo->components) == false) { |
| 1419 | skip |= LogError( |
| 1420 | device, "VUID-VkImageViewCreateInfo-pNext-01970", |
| 1421 | "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must " |
| 1422 | "be created with the identity swizzle. Here are the actual swizzle values:\n" |
| 1423 | "r swizzle = %s\n" |
| 1424 | "g swizzle = %s\n" |
| 1425 | "b swizzle = %s\n" |
| 1426 | "a swizzle = %s\n", |
| 1427 | string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g), |
| 1428 | string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a)); |
| 1429 | } |
| 1430 | } |
| 1431 | } |
Tony-LunarG | 115f89d | 2022-06-15 10:53:22 -0600 | [diff] [blame] | 1432 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 1433 | skip |= ExportMetalObjectsPNextUtil( |
| 1434 | VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkImageViewCreateInfo-pNext-06787", |
| 1435 | "vkCreateImageView():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pCreateInfo->pNext); |
| 1436 | #endif // VK_USE_PLATFORM_METAL_EXT |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1437 | } |
| 1438 | return skip; |
| 1439 | } |
| 1440 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1441 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1442 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1443 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1444 | |
| 1445 | // Note: for numerical correctness |
| 1446 | // - float comparisons should expect NaN (comparison always false). |
| 1447 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 1448 | |
| 1449 | const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) { |
John Zulauf | ac0876c | 2018-02-19 10:09:35 -0700 | [diff] [blame] | 1450 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1451 | if (v1_f <= 0.0f) return true; |
| 1452 | |
| 1453 | float intpart; |
| 1454 | const float fract = modff(v1_f, &intpart); |
| 1455 | |
| 1456 | assert(std::numeric_limits<float>::radix == 2); |
| 1457 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 1458 | if (intpart >= u32_max_plus1) return false; |
| 1459 | |
| 1460 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1461 | if (v1_u32 < v2_u32) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1462 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1463 | } else if (v1_u32 == v2_u32 && fract == 0.0f) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1464 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1465 | } else { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1466 | return false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1467 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1468 | }; |
| 1469 | |
| 1470 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 1471 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 1472 | return (v1_f <= v2_f); |
| 1473 | }; |
| 1474 | |
| 1475 | // width |
| 1476 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1477 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1478 | |
| 1479 | if (!(viewport.width > 0.0f)) { |
| 1480 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1481 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 1482 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1483 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 1484 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1485 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 1486 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 1487 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1488 | } |
| 1489 | |
| 1490 | // height |
| 1491 | bool height_healthy = true; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1492 | const bool negative_height_enabled = |
| 1493 | IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1494 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1495 | |
| 1496 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1497 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1498 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 1499 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1500 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1501 | height_healthy = false; |
| 1502 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1503 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 1504 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 1505 | ").", |
| 1506 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1507 | } |
| 1508 | |
| 1509 | // x |
| 1510 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1511 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1512 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1513 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 1514 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1515 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1516 | } |
| 1517 | |
| 1518 | // x + width |
| 1519 | if (x_healthy && width_healthy) { |
| 1520 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1521 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1522 | skip |= LogError( |
| 1523 | object, "VUID-VkViewport-x-01232", |
| 1524 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1525 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 1526 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1527 | } |
| 1528 | } |
| 1529 | |
| 1530 | // y |
| 1531 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1532 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1533 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1534 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 1535 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1536 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1537 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1538 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1539 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 1540 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1541 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | // y + height |
| 1545 | if (y_healthy && height_healthy) { |
| 1546 | const float boundary = viewport.y + viewport.height; |
| 1547 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1548 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1549 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 1550 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1551 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 1552 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1553 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1554 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1555 | LogError(object, "VUID-VkViewport-y-01777", |
| 1556 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 1557 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 1558 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1559 | } |
| 1560 | } |
| 1561 | |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1562 | // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1563 | if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1564 | // minDepth |
| 1565 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1566 | // Also VUID-VkViewport-minDepth-02540 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1567 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1568 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 1569 | "[0.0, 1.0] range.", |
| 1570 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1571 | } |
| 1572 | |
| 1573 | // maxDepth |
| 1574 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1575 | // Also VUID-VkViewport-maxDepth-02541 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1576 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1577 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 1578 | "[0.0, 1.0] range.", |
| 1579 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1580 | } |
| 1581 | } |
| 1582 | |
| 1583 | return skip; |
| 1584 | } |
| 1585 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1586 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1587 | VkShadingRatePaletteEntryNV shadingRate; |
| 1588 | uint32_t width; |
| 1589 | uint32_t height; |
| 1590 | }; |
| 1591 | |
| 1592 | // All palette entries with more than one pixel per fragment |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1593 | static SampleOrderInfo sample_order_infos[] = { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1594 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 1595 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 1596 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 1597 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 1598 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 1599 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4}, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1600 | }; |
| 1601 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 1602 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1603 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1604 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1605 | SampleOrderInfo *sample_order_info; |
| 1606 | uint32_t info_idx = 0; |
| 1607 | for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) { |
| 1608 | if (sample_order_infos[info_idx].shadingRate == order->shadingRate) { |
| 1609 | sample_order_info = &sample_order_infos[info_idx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1610 | break; |
| 1611 | } |
| 1612 | } |
| 1613 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1614 | if (sample_order_info == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1615 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 1616 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 1617 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1618 | return skip; |
| 1619 | } |
| 1620 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1621 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1622 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1623 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 1624 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 1625 | ") must " |
| 1626 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 1627 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 1628 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1629 | } |
| 1630 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1631 | if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1632 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 1633 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1634 | ") must " |
| 1635 | "be equal to the product of sampleCount (=%" PRIu32 |
| 1636 | "), the fragment width for shadingRate " |
| 1637 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1638 | order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1639 | } |
| 1640 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1641 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1642 | skip |= LogError( |
| 1643 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1644 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1645 | ") must " |
| 1646 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1647 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1648 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1649 | |
| 1650 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1651 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 1652 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 1653 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1654 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1655 | uint64_t sample_locations_mask = 0; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1656 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1657 | const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i]; |
| 1658 | if (sample_loc->pixelX >= sample_order_info->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1659 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 1660 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1661 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1662 | if (sample_loc->pixelY >= sample_order_info->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1663 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 1664 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1665 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1666 | if (sample_loc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1667 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 1668 | "sample must be less than the number of coverage samples in each pixel belonging to the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1669 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1670 | uint32_t idx = |
| 1671 | sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY); |
| 1672 | sample_locations_mask |= 1ULL << idx; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1673 | } |
| 1674 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1675 | uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 1676 | if (sample_locations_mask != expected_mask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1677 | skip |= LogError( |
| 1678 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1679 | "The array pSampleLocations must contain exactly one entry for " |
| 1680 | "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1681 | } |
| 1682 | |
| 1683 | return skip; |
| 1684 | } |
| 1685 | |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1686 | bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, |
| 1687 | const VkAllocationCallbacks *pAllocator, |
| 1688 | VkPipelineLayout *pPipelineLayout) const { |
| 1689 | bool skip = false; |
| 1690 | // Validate layout count against device physical limit |
| 1691 | if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) { |
| 1692 | skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1693 | "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32 |
| 1694 | ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1695 | pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets); |
| 1696 | } |
| 1697 | |
Nathaniel Cesario | 73c994c | 2022-05-26 23:07:34 -0600 | [diff] [blame] | 1698 | if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) { |
Nathaniel Cesario | db38b7a | 2022-03-10 22:16:51 -0700 | [diff] [blame] | 1699 | for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) { |
| 1700 | if (!pCreateInfo->pSetLayouts[i]) { |
Nathaniel Cesario | 73c994c | 2022-05-26 23:07:34 -0600 | [diff] [blame] | 1701 | skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561", |
| 1702 | "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32 |
| 1703 | "] is VK_NULL_HANDLE, but VK_EXT_graphics_pipeline_library is not enabled.", |
| 1704 | i); |
Nathaniel Cesario | db38b7a | 2022-03-10 22:16:51 -0700 | [diff] [blame] | 1705 | } |
| 1706 | } |
| 1707 | } |
| 1708 | |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1709 | // Validate Push Constant ranges |
| 1710 | for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) { |
| 1711 | const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset; |
| 1712 | const uint32_t size = pCreateInfo->pPushConstantRanges[i].size; |
| 1713 | const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize; |
| 1714 | // Check that offset + size don't exceed the max. |
| 1715 | // Prevent arithetic overflow here by avoiding addition and testing in this order. |
| 1716 | if (offset >= max_push_constants_size) { |
| 1717 | skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1718 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32 |
| 1719 | ") that exceeds this " |
| 1720 | "device's maxPushConstantSize of %" PRIu32 ".", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1721 | i, offset, max_push_constants_size); |
| 1722 | } |
| 1723 | if (size > max_push_constants_size - offset) { |
| 1724 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00298", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1725 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32 |
| 1726 | ") and size (%" PRIu32 |
| 1727 | ") " |
| 1728 | "together exceeds this device's maxPushConstantSize of %" PRIu32 ".", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1729 | i, offset, size, max_push_constants_size); |
| 1730 | } |
| 1731 | |
| 1732 | // size needs to be non-zero and a multiple of 4. |
| 1733 | if (size == 0) { |
| 1734 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00296", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1735 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32 |
| 1736 | ") is not greater than zero.", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1737 | i, size); |
| 1738 | } |
| 1739 | if (size & 0x3) { |
| 1740 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00297", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1741 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32 |
| 1742 | ") is not a multiple of 4.", |
| 1743 | i, size); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1744 | } |
| 1745 | |
| 1746 | // offset needs to be a multiple of 4. |
| 1747 | if ((offset & 0x3) != 0) { |
| 1748 | skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1749 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32 |
| 1750 | ") is not a multiple of 4.", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1751 | i, offset); |
| 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | // As of 1.0.28, there is a VU that states that a stage flag cannot appear more than once in the list of push constant ranges. |
| 1756 | for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) { |
| 1757 | for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) { |
| 1758 | if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1759 | skip |= |
| 1760 | LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292", |
| 1761 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1762 | } |
| 1763 | } |
| 1764 | } |
| 1765 | return skip; |
| 1766 | } |
| 1767 | |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 1768 | bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg, |
| 1769 | const VkPipelineShaderStageCreateInfo *pCreateInfo) const { |
| 1770 | bool skip = false; |
| 1771 | |
| 1772 | const auto *required_subgroup_size_features = |
| 1773 | LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext); |
| 1774 | |
| 1775 | if (required_subgroup_size_features) { |
| 1776 | if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) { |
| 1777 | skip |= LogError( |
| 1778 | device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754", |
| 1779 | "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while " |
| 1780 | "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.", |
| 1781 | func_name, msg, pCreateInfo->flags); |
| 1782 | } |
| 1783 | } |
| 1784 | |
| 1785 | return skip; |
| 1786 | } |
| 1787 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1788 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 1789 | uint32_t createInfoCount, |
| 1790 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1791 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1792 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1793 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1794 | |
| 1795 | if (pCreateInfos != nullptr) { |
| 1796 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1797 | bool has_dynamic_viewport = false; |
| 1798 | bool has_dynamic_scissor = false; |
| 1799 | bool has_dynamic_line_width = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1800 | bool has_dynamic_depth_bias = false; |
| 1801 | bool has_dynamic_blend_constant = false; |
| 1802 | bool has_dynamic_depth_bounds = false; |
| 1803 | bool has_dynamic_stencil_compare = false; |
| 1804 | bool has_dynamic_stencil_write = false; |
| 1805 | bool has_dynamic_stencil_reference = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1806 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1807 | bool has_dynamic_discard_rectangle_ext = false; |
| 1808 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1809 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1810 | bool has_dynamic_shading_rate_palette_nv = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1811 | bool has_dynamic_viewport_course_sample_order_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1812 | bool has_dynamic_line_stipple = false; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1813 | bool has_dynamic_cull_mode = false; |
| 1814 | bool has_dynamic_front_face = false; |
| 1815 | bool has_dynamic_primitive_topology = false; |
| 1816 | bool has_dynamic_viewport_with_count = false; |
| 1817 | bool has_dynamic_scissor_with_count = false; |
| 1818 | bool has_dynamic_vertex_input_binding_stride = false; |
| 1819 | bool has_dynamic_depth_test_enable = false; |
| 1820 | bool has_dynamic_depth_write_enable = false; |
| 1821 | bool has_dynamic_depth_compare_op = false; |
| 1822 | bool has_dynamic_depth_bounds_test_enable = false; |
| 1823 | bool has_dynamic_stencil_test_enable = false; |
| 1824 | bool has_dynamic_stencil_op = false; |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 1825 | bool has_patch_control_points = false; |
| 1826 | bool has_rasterizer_discard_enable = false; |
| 1827 | bool has_depth_bias_enable = false; |
| 1828 | bool has_logic_op = false; |
| 1829 | bool has_primitive_restart_enable = false; |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 1830 | bool has_dynamic_vertex_input = false; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 1831 | |
| 1832 | // Create a copy of create_info and set non-included sub-state to null |
| 1833 | auto create_info = pCreateInfos[i]; |
| 1834 | const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext); |
| 1835 | if (graphics_lib_info) { |
Nathaniel Cesario | bcb7968 | 2022-03-31 21:13:52 -0600 | [diff] [blame] | 1836 | // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries |
| 1837 | if (enabled[gpu_validation]) { |
| 1838 | skip |= |
| 1839 | LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported"); |
| 1840 | } |
| 1841 | if (enabled[gpu_validation]) { |
| 1842 | skip |= LogError(device, kVUIDUndefined, |
| 1843 | "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported"); |
| 1844 | } |
| 1845 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 1846 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) { |
| 1847 | create_info.pVertexInputState = nullptr; |
| 1848 | create_info.pInputAssemblyState = nullptr; |
| 1849 | } |
| 1850 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) { |
| 1851 | create_info.pViewportState = nullptr; |
| 1852 | create_info.pRasterizationState = nullptr; |
| 1853 | create_info.pTessellationState = nullptr; |
| 1854 | } |
| 1855 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) { |
| 1856 | create_info.pDepthStencilState = nullptr; |
| 1857 | } |
| 1858 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) { |
| 1859 | create_info.pColorBlendState = nullptr; |
| 1860 | } |
| 1861 | if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT | |
| 1862 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) { |
| 1863 | create_info.pMultisampleState = nullptr; |
| 1864 | } |
| 1865 | if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT | |
| 1866 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) { |
| 1867 | create_info.layout = VK_NULL_HANDLE; |
| 1868 | } |
| 1869 | if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT | |
| 1870 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT | |
| 1871 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) { |
| 1872 | create_info.renderPass = VK_NULL_HANDLE; |
| 1873 | create_info.subpass = 0; |
| 1874 | } |
| 1875 | } |
| 1876 | |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1877 | // Values needed from either dynamic rendering or the subpass description |
| 1878 | uint32_t color_attachment_count = 0; |
| 1879 | |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1880 | if (!create_info.renderPass) { |
| 1881 | if (create_info.pColorBlendState && create_info.pMultisampleState) { |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1882 | const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext); |
ziga-lunarg | 97584c3 | 2022-04-22 14:33:37 +0200 | [diff] [blame] | 1883 | // Pipeline has fragment output state |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1884 | if (rendering_struct) { |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1885 | color_attachment_count = rendering_struct->colorAttachmentCount; |
| 1886 | |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1887 | if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) { |
| 1888 | skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat", |
| 1889 | AllVkFormatEnums, rendering_struct->stencilAttachmentFormat, |
| 1890 | "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583"); |
Nathaniel Cesario | e77320e | 2022-04-11 17:32:33 -0600 | [diff] [blame] | 1891 | |
| 1892 | if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) { |
| 1893 | skip |= LogError( |
| 1894 | device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587", |
| 1895 | "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32 |
| 1896 | "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.", |
| 1897 | i, string_VkFormat(rendering_struct->depthAttachmentFormat)); |
| 1898 | } |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1899 | } |
| 1900 | |
| 1901 | if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) { |
| 1902 | skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat", |
| 1903 | AllVkFormatEnums, rendering_struct->stencilAttachmentFormat, |
| 1904 | "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584"); |
Nathaniel Cesario | e77320e | 2022-04-11 17:32:33 -0600 | [diff] [blame] | 1905 | if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) { |
Nathaniel Cesario | 1ba7ca5 | 2022-04-18 12:35:00 -0600 | [diff] [blame] | 1906 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588", |
| 1907 | "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32 |
| 1908 | "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a " |
| 1909 | "stencil aspect.", |
| 1910 | i, string_VkFormat(rendering_struct->stencilAttachmentFormat)); |
Nathaniel Cesario | e77320e | 2022-04-11 17:32:33 -0600 | [diff] [blame] | 1911 | } |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1912 | } |
Nathaniel Cesario | 45efaac | 2022-04-11 17:04:33 -0600 | [diff] [blame] | 1913 | |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1914 | if (color_attachment_count != 0) { |
Nathaniel Cesario | 45efaac | 2022-04-11 17:04:33 -0600 | [diff] [blame] | 1915 | skip |= validate_ranged_enum_array( |
| 1916 | "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579", |
| 1917 | "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums, |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1918 | color_attachment_count, rendering_struct->pColorAttachmentFormats, true, true); |
Nathaniel Cesario | 45efaac | 2022-04-11 17:04:33 -0600 | [diff] [blame] | 1919 | } |
ziga-lunarg | 97584c3 | 2022-04-22 14:33:37 +0200 | [diff] [blame] | 1920 | |
| 1921 | if (rendering_struct->pColorAttachmentFormats) { |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1922 | for (uint32_t j = 0; j < color_attachment_count; ++j) { |
ziga-lunarg | 97584c3 | 2022-04-22 14:33:37 +0200 | [diff] [blame] | 1923 | skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "pColorAttachmentFormats", "VkFormat", |
| 1924 | AllVkFormatEnums, rendering_struct->pColorAttachmentFormats[j], |
| 1925 | "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580"); |
| 1926 | } |
| 1927 | } |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1928 | } |
ziga-lunarg | 4725854 | 2022-04-22 17:40:43 +0200 | [diff] [blame] | 1929 | |
| 1930 | // VkAttachmentSampleCountInfoAMD == VkAttachmentSampleCountInfoNV |
| 1931 | auto attachment_sample_count_info = LvlFindInChain<VkAttachmentSampleCountInfoAMD>(create_info.pNext); |
| 1932 | if (attachment_sample_count_info && attachment_sample_count_info->pColorAttachmentSamples) { |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1933 | color_attachment_count = attachment_sample_count_info->colorAttachmentCount; |
| 1934 | |
| 1935 | for (uint32_t j = 0; j < color_attachment_count; ++j) { |
ziga-lunarg | 4725854 | 2022-04-22 17:40:43 +0200 | [diff] [blame] | 1936 | skip |= validate_flags("vkCreateGraphicsPipelines", |
| 1937 | ParameterName("VkAttachmentSampleCountInfoAMD->pColorAttachmentSamples"), |
| 1938 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, |
| 1939 | attachment_sample_count_info->pColorAttachmentSamples[j], kRequiredFlags, |
| 1940 | "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592"); |
| 1941 | } |
| 1942 | } |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1943 | } |
| 1944 | } |
| 1945 | |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1946 | if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) { |
| 1947 | if (create_info.stageCount == 0) { |
| 1948 | skip |= |
| 1949 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604", |
| 1950 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i, |
| 1951 | VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 1952 | } |
| 1953 | // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to |
| 1954 | // ParameterName::IndexFormatSpecifier |
| 1955 | skip |= validate_struct_type_array( |
| 1956 | "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}), |
| 1957 | ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1958 | "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", create_info.stageCount, create_info.pStages, |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1959 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true, |
| 1960 | "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600", |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 1961 | "VUID-VkGraphicsPipelineCreateInfo-pStages-06600"); |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1962 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 1963 | ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}), |
| 1964 | "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO", |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 1965 | create_info.pRasterizationState, |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1966 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true, |
| 1967 | "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601", |
| 1968 | "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType"); |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1969 | } |
| 1970 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 1971 | // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline" |
| 1972 | if (create_info.pDynamicState != nullptr) { |
| 1973 | const auto &dynamic_state_info = *create_info.pDynamicState; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1974 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1975 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1976 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1977 | if (has_dynamic_viewport == true) { |
| 1978 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1979 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1980 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1981 | i); |
| 1982 | } |
| 1983 | has_dynamic_viewport = true; |
| 1984 | } |
| 1985 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) { |
| 1986 | if (has_dynamic_scissor == true) { |
| 1987 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1988 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1989 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1990 | i); |
| 1991 | } |
| 1992 | has_dynamic_scissor = true; |
| 1993 | } |
| 1994 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) { |
| 1995 | if (has_dynamic_line_width == true) { |
| 1996 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1997 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1998 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1999 | i); |
| 2000 | } |
| 2001 | has_dynamic_line_width = true; |
| 2002 | } |
| 2003 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) { |
| 2004 | if (has_dynamic_depth_bias == true) { |
| 2005 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2006 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2007 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2008 | i); |
| 2009 | } |
| 2010 | has_dynamic_depth_bias = true; |
| 2011 | } |
| 2012 | if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) { |
| 2013 | if (has_dynamic_blend_constant == true) { |
| 2014 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2015 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2016 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2017 | i); |
| 2018 | } |
| 2019 | has_dynamic_blend_constant = true; |
| 2020 | } |
| 2021 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) { |
| 2022 | if (has_dynamic_depth_bounds == true) { |
| 2023 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2024 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2025 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2026 | i); |
| 2027 | } |
| 2028 | has_dynamic_depth_bounds = true; |
| 2029 | } |
| 2030 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) { |
| 2031 | if (has_dynamic_stencil_compare == true) { |
| 2032 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2033 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2034 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2035 | i); |
| 2036 | } |
| 2037 | has_dynamic_stencil_compare = true; |
| 2038 | } |
| 2039 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) { |
| 2040 | if (has_dynamic_stencil_write == true) { |
| 2041 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2042 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2043 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2044 | i); |
| 2045 | } |
| 2046 | has_dynamic_stencil_write = true; |
| 2047 | } |
| 2048 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) { |
| 2049 | if (has_dynamic_stencil_reference == true) { |
| 2050 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2051 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2052 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2053 | i); |
| 2054 | } |
| 2055 | has_dynamic_stencil_reference = true; |
| 2056 | } |
| 2057 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) { |
| 2058 | if (has_dynamic_viewport_w_scaling_nv == true) { |
| 2059 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2060 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2061 | "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2062 | i); |
| 2063 | } |
| 2064 | has_dynamic_viewport_w_scaling_nv = true; |
| 2065 | } |
| 2066 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) { |
| 2067 | if (has_dynamic_discard_rectangle_ext == true) { |
| 2068 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2069 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2070 | "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2071 | i); |
| 2072 | } |
| 2073 | has_dynamic_discard_rectangle_ext = true; |
| 2074 | } |
| 2075 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) { |
| 2076 | if (has_dynamic_sample_locations_ext == true) { |
| 2077 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2078 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2079 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2080 | i); |
| 2081 | } |
| 2082 | has_dynamic_sample_locations_ext = true; |
| 2083 | } |
| 2084 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) { |
| 2085 | if (has_dynamic_exclusive_scissor_nv == true) { |
| 2086 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2087 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2088 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2089 | i); |
| 2090 | } |
| 2091 | has_dynamic_exclusive_scissor_nv = true; |
| 2092 | } |
| 2093 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) { |
| 2094 | if (has_dynamic_shading_rate_palette_nv == true) { |
| 2095 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2096 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2097 | "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2098 | i); |
| 2099 | } |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2100 | has_dynamic_shading_rate_palette_nv = true; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2101 | } |
| 2102 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) { |
| 2103 | if (has_dynamic_viewport_course_sample_order_nv == true) { |
| 2104 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2105 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2106 | "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2107 | i); |
| 2108 | } |
| 2109 | has_dynamic_viewport_course_sample_order_nv = true; |
| 2110 | } |
| 2111 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) { |
| 2112 | if (has_dynamic_line_stipple == true) { |
| 2113 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2114 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2115 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2116 | i); |
| 2117 | } |
| 2118 | has_dynamic_line_stipple = true; |
| 2119 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2120 | if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) { |
| 2121 | if (has_dynamic_cull_mode) { |
| 2122 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2123 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2124 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2125 | i); |
| 2126 | } |
| 2127 | has_dynamic_cull_mode = true; |
| 2128 | } |
| 2129 | if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) { |
| 2130 | if (has_dynamic_front_face) { |
| 2131 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2132 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2133 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2134 | i); |
| 2135 | } |
| 2136 | has_dynamic_front_face = true; |
| 2137 | } |
| 2138 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) { |
| 2139 | if (has_dynamic_primitive_topology) { |
| 2140 | skip |= LogError( |
| 2141 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2142 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2143 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2144 | i); |
| 2145 | } |
| 2146 | has_dynamic_primitive_topology = true; |
| 2147 | } |
| 2148 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) { |
| 2149 | if (has_dynamic_viewport_with_count) { |
| 2150 | skip |= LogError( |
| 2151 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2152 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2153 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2154 | i); |
| 2155 | } |
| 2156 | has_dynamic_viewport_with_count = true; |
| 2157 | } |
| 2158 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) { |
| 2159 | if (has_dynamic_scissor_with_count) { |
| 2160 | skip |= LogError( |
| 2161 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2162 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2163 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2164 | i); |
| 2165 | } |
| 2166 | has_dynamic_scissor_with_count = true; |
| 2167 | } |
| 2168 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) { |
| 2169 | if (has_dynamic_vertex_input_binding_stride) { |
| 2170 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2171 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was " |
| 2172 | "listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2173 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2174 | i); |
| 2175 | } |
| 2176 | has_dynamic_vertex_input_binding_stride = true; |
| 2177 | } |
| 2178 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) { |
| 2179 | if (has_dynamic_depth_test_enable) { |
| 2180 | skip |= LogError( |
| 2181 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2182 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2183 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2184 | i); |
| 2185 | } |
| 2186 | has_dynamic_depth_test_enable = true; |
| 2187 | } |
| 2188 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) { |
| 2189 | if (has_dynamic_depth_write_enable) { |
| 2190 | skip |= LogError( |
| 2191 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2192 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2193 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2194 | i); |
| 2195 | } |
| 2196 | has_dynamic_depth_write_enable = true; |
| 2197 | } |
| 2198 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) { |
| 2199 | if (has_dynamic_depth_compare_op) { |
| 2200 | skip |= |
| 2201 | LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2202 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2203 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2204 | i); |
| 2205 | } |
| 2206 | has_dynamic_depth_compare_op = true; |
| 2207 | } |
| 2208 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) { |
| 2209 | if (has_dynamic_depth_bounds_test_enable) { |
| 2210 | skip |= LogError( |
| 2211 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2212 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2213 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2214 | i); |
| 2215 | } |
| 2216 | has_dynamic_depth_bounds_test_enable = true; |
| 2217 | } |
| 2218 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) { |
| 2219 | if (has_dynamic_stencil_test_enable) { |
| 2220 | skip |= LogError( |
| 2221 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2222 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2223 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2224 | i); |
| 2225 | } |
| 2226 | has_dynamic_stencil_test_enable = true; |
| 2227 | } |
| 2228 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) { |
| 2229 | if (has_dynamic_stencil_op) { |
| 2230 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2231 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2232 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2233 | i); |
| 2234 | } |
| 2235 | has_dynamic_stencil_op = true; |
| 2236 | } |
sfricke-samsung | 5f8f970 | 2021-01-29 23:30:30 -0800 | [diff] [blame] | 2237 | if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) { |
| 2238 | // Not allowed for graphics pipelines |
| 2239 | skip |= LogError( |
| 2240 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578", |
| 2241 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2242 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32 |
| 2243 | "] but not allowed in graphic pipelines.", |
sfricke-samsung | 5f8f970 | 2021-01-29 23:30:30 -0800 | [diff] [blame] | 2244 | i, state_index); |
| 2245 | } |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2246 | if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) { |
| 2247 | if (has_patch_control_points) { |
| 2248 | skip |= LogError( |
| 2249 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2250 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2251 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2252 | i); |
| 2253 | } |
| 2254 | has_patch_control_points = true; |
| 2255 | } |
| 2256 | if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) { |
| 2257 | if (has_rasterizer_discard_enable) { |
| 2258 | skip |= LogError( |
| 2259 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2260 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2261 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2262 | i); |
| 2263 | } |
| 2264 | has_rasterizer_discard_enable = true; |
| 2265 | } |
| 2266 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) { |
| 2267 | if (has_depth_bias_enable) { |
| 2268 | skip |= LogError( |
| 2269 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2270 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2271 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2272 | i); |
| 2273 | } |
| 2274 | has_depth_bias_enable = true; |
| 2275 | } |
| 2276 | if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) { |
| 2277 | if (has_logic_op) { |
| 2278 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2279 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2280 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2281 | i); |
| 2282 | } |
| 2283 | has_logic_op = true; |
| 2284 | } |
| 2285 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) { |
| 2286 | if (has_primitive_restart_enable) { |
| 2287 | skip |= LogError( |
| 2288 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2289 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2290 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2291 | i); |
| 2292 | } |
| 2293 | has_primitive_restart_enable = true; |
| 2294 | } |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 2295 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) { |
| 2296 | if (has_dynamic_vertex_input) { |
| 2297 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2298 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the " |
| 2299 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
| 2300 | i); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 2301 | } |
| 2302 | has_dynamic_vertex_input = true; |
| 2303 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2304 | } |
| 2305 | } |
| 2306 | |
sfricke-samsung | 3b94442 | 2021-01-23 02:15:19 -0800 | [diff] [blame] | 2307 | if (has_dynamic_viewport_with_count && has_dynamic_viewport) { |
| 2308 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132", |
| 2309 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2310 | "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32 |
| 2311 | "].pDynamicState->pDynamicStates array", |
sfricke-samsung | 3b94442 | 2021-01-23 02:15:19 -0800 | [diff] [blame] | 2312 | i); |
| 2313 | } |
| 2314 | |
| 2315 | if (has_dynamic_scissor_with_count && has_dynamic_scissor) { |
| 2316 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133", |
| 2317 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2318 | "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
sfricke-samsung | 3b94442 | 2021-01-23 02:15:19 -0800 | [diff] [blame] | 2319 | i); |
| 2320 | } |
| 2321 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2322 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext); |
| 2323 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) { |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 2324 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2325 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 2326 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 2327 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2328 | i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2329 | } |
| 2330 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2331 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2332 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2333 | // Collect active stages and other information |
| 2334 | // Only want to loop through pStages once |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2335 | uint32_t active_shaders = 0; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2336 | bool has_eval = false; |
| 2337 | bool has_control = false; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2338 | if (create_info.pStages != nullptr) { |
| 2339 | for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) { |
| 2340 | active_shaders |= create_info.pStages[stage_index].stage; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2341 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2342 | if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2343 | has_control = true; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2344 | } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2345 | has_eval = true; |
| 2346 | } |
| 2347 | |
Tony-LunarG | d29cc03 | 2022-05-13 14:38:27 -0600 | [diff] [blame] | 2348 | skip |= validate_required_pointer( |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2349 | "vkCreateGraphicsPipelines", |
Tony-LunarG | d29cc03 | 2022-05-13 14:38:27 -0600 | [diff] [blame] | 2350 | ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}), |
| 2351 | create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter"); |
| 2352 | |
| 2353 | if (create_info.pStages[stage_index].pName) { |
| 2354 | skip |= validate_string( |
| 2355 | "vkCreateGraphicsPipelines", |
| 2356 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}), |
| 2357 | kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName); |
| 2358 | } |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 2359 | |
| 2360 | std::stringstream msg; |
| 2361 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 2362 | ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2363 | &create_info.pStages[stage_index]); |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2364 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2365 | } |
| 2366 | |
| 2367 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2368 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) { |
| 2369 | skip |= |
| 2370 | validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 2371 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 2372 | create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 2373 | false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2374 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2375 | const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2376 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 2377 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2378 | skip |= validate_struct_pnext( |
| 2379 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2380 | "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2381 | ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info), |
| 2382 | allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion, |
| 2383 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 2384 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2385 | |
| 2386 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2387 | create_info.pTessellationState->flags, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2388 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 2389 | } |
| 2390 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2391 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2392 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 2393 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2394 | create_info.pInputAssemblyState, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2395 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2396 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 2397 | |
| 2398 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2399 | create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2400 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2401 | |
| 2402 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2403 | create_info.pInputAssemblyState->flags, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2404 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 2405 | |
| 2406 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 2407 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2408 | create_info.pInputAssemblyState->topology, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2409 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 2410 | |
| 2411 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2412 | create_info.pInputAssemblyState->primitiveRestartEnable); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2413 | } |
| 2414 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2415 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) { |
| 2416 | auto const &vertex_input_state = create_info.pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2417 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2418 | if (create_info.pVertexInputState->flags != 0) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2419 | skip |= |
| 2420 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 2421 | "vkCreateGraphicsPipelines: pararameter " |
| 2422 | "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.", |
| 2423 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2424 | } |
| 2425 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2426 | const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2427 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2428 | skip |= |
| 2429 | validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 2430 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1, |
| 2431 | allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion, |
| 2432 | "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
| 2433 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2434 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 2435 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 2436 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2437 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 2438 | skip |= |
| 2439 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 2440 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2441 | create_info.pVertexInputState->vertexBindingDescriptionCount, |
| 2442 | &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2443 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 2444 | |
| 2445 | skip |= validate_array( |
| 2446 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 2447 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 2448 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 2449 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 2450 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2451 | if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2452 | for (uint32_t vertex_binding_description_index = 0; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2453 | vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2454 | ++vertex_binding_description_index) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2455 | skip |= validate_ranged_enum( |
| 2456 | "vkCreateGraphicsPipelines", |
| 2457 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 2458 | AllVkVertexInputRateEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2459 | create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2460 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 2461 | } |
| 2462 | } |
| 2463 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2464 | if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2465 | for (uint32_t vertex_attribute_description_index = 0; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2466 | vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2467 | ++vertex_attribute_description_index) { |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2468 | const VkFormat format = |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2469 | create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format; |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2470 | skip |= validate_ranged_enum( |
| 2471 | "vkCreateGraphicsPipelines", |
| 2472 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 2473 | AllVkFormatEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2474 | create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2475 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2476 | if (FormatIsDepthOrStencil(format)) { |
| 2477 | // Should never hopefully get here, but there are known driver advertising the wrong feature flags |
| 2478 | // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849 |
| 2479 | skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat, |
| 2480 | "vkCreateGraphicsPipelines: " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2481 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2482 | "].format is a " |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2483 | "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for " |
| 2484 | "alignment, replace with a color format.", |
| 2485 | i, vertex_attribute_description_index, string_VkFormat(format)); |
| 2486 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2487 | } |
| 2488 | } |
| 2489 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2490 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2491 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 2492 | "vkCreateGraphicsPipelines: pararameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2493 | "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32 |
| 2494 | ") is " |
| 2495 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2496 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2497 | } |
| 2498 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2499 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2500 | skip |= |
| 2501 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 2502 | "vkCreateGraphicsPipelines: pararameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2503 | "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32 |
| 2504 | ") is " |
| 2505 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2506 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2507 | } |
| 2508 | |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 2509 | layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2510 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 2511 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2512 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 2513 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2514 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 2515 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2516 | "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32 |
| 2517 | "].binding " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2518 | "(%" PRIu32 ") is not distinct.", |
| 2519 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2520 | } |
| 2521 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 2522 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2523 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2524 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 2525 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2526 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32 |
| 2527 | "].binding (%" PRIu32 |
| 2528 | ") is " |
| 2529 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2530 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2531 | } |
| 2532 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2533 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2534 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 2535 | "vkCreateGraphicsPipelines: parameter " |
| 2536 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32 |
| 2537 | "].stride (%" PRIu32 |
| 2538 | ") is greater " |
| 2539 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").", |
| 2540 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2541 | } |
| 2542 | } |
| 2543 | |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 2544 | layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2545 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 2546 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2547 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 2548 | if (location_it != attribute_locations.cend()) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2549 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
| 2550 | "vkCreateGraphicsPipelines: parameter " |
| 2551 | "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32 |
| 2552 | "].location (%" PRIu32 ") is not distinct.", |
| 2553 | i, d, vertex_attrib_desc.location); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2554 | } |
| 2555 | attribute_locations.insert(vertex_attrib_desc.location); |
| 2556 | |
| 2557 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 2558 | if (binding_it == vertex_bindings.cend()) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2559 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
| 2560 | "vkCreateGraphicsPipelines: parameter " |
| 2561 | " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32 |
| 2562 | "].binding (%" PRIu32 |
| 2563 | ") does not exist " |
| 2564 | "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.", |
| 2565 | i, d, vertex_attrib_desc.binding, i); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2566 | } |
| 2567 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2568 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2569 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 2570 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2571 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2572 | "].location (%" PRIu32 |
| 2573 | ") is " |
| 2574 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2575 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2576 | } |
| 2577 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2578 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2579 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 2580 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2581 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2582 | "].binding (%" PRIu32 |
| 2583 | ") is " |
| 2584 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2585 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2586 | } |
| 2587 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2588 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2589 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 2590 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2591 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2592 | "].offset (%" PRIu32 |
| 2593 | ") is " |
| 2594 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2595 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2596 | } |
| 2597 | } |
| 2598 | } |
| 2599 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2600 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 2601 | if (has_control && has_eval) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2602 | if (create_info.pTessellationState == nullptr) { |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2603 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2604 | "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32 |
| 2605 | "].pStages includes a tessellation control " |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2606 | "shader stage and a tessellation evaluation shader stage, " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2607 | "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.", |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2608 | i, i); |
| 2609 | } else { |
| 2610 | const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
| 2611 | skip |= validate_struct_pnext( |
| 2612 | "vkCreateGraphicsPipelines", |
| 2613 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2614 | "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1, |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2615 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 2616 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2617 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2618 | skip |= validate_reserved_flags( |
| 2619 | "vkCreateGraphicsPipelines", |
| 2620 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2621 | create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2622 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2623 | if (create_info.pTessellationState->patchControlPoints == 0 || |
| 2624 | create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
| 2625 | skip |= |
| 2626 | LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 2627 | "vkCreateGraphicsPipelines: invalid parameter " |
| 2628 | "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32 |
| 2629 | ". patchControlPoints " |
| 2630 | "should be >0 and <=%" PRIu32 ".", |
| 2631 | i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2632 | } |
| 2633 | } |
| 2634 | } |
| 2635 | |
| 2636 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2637 | if ((create_info.pRasterizationState != nullptr) && |
| 2638 | (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 2639 | if (create_info.pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2640 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 2641 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 2642 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 2643 | "].pViewportState (=NULL) is not a valid pointer.", |
| 2644 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2645 | } else { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2646 | const auto &viewport_state = *create_info.pViewportState; |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2647 | |
| 2648 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2649 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 2650 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2651 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 2652 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2653 | } |
| 2654 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2655 | const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2656 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2657 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 2658 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2659 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 2660 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2661 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2662 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2663 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2664 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2665 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2666 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 2667 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2668 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2669 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info), |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2670 | allowed_structs_vk_pipeline_viewport_state_create_info, 200, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2671 | "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2672 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2673 | |
| 2674 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2675 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2676 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2677 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2678 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2679 | auto exclusive_scissor_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2680 | LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2681 | auto shading_rate_image_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2682 | LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2683 | auto coarse_sample_order_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2684 | LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext); |
| 2685 | const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2686 | const auto vp_w_scaling_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2687 | LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext); |
| 2688 | const auto depth_clip_control_struct = |
| 2689 | LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2690 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2691 | if (!physical_device_features.multiViewport) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 2692 | if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount > 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2693 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 2694 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2695 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 2696 | ") is not 1.", |
| 2697 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2698 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2699 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 2700 | if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount > 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2701 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 2702 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2703 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2704 | ") is not 1.", |
| 2705 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2706 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2707 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2708 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 2709 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2710 | skip |= LogError( |
| 2711 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 2712 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2713 | "disabled, but pCreateInfos[%" PRIu32 |
| 2714 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 2715 | ") is not 1.", |
| 2716 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2717 | } |
| 2718 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2719 | if (shading_rate_image_struct && |
| 2720 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2721 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 2722 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2723 | "disabled, but pCreateInfos[%" PRIu32 |
| 2724 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 2725 | ") is neither 0 nor 1.", |
| 2726 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2727 | } |
| 2728 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2729 | } else { // multiViewport enabled |
| 2730 | if (viewport_state.viewportCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2731 | if (!has_dynamic_viewport_with_count) { |
| 2732 | skip |= LogError( |
| 2733 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
| 2734 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
| 2735 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2736 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2737 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 2738 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2739 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2740 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2741 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2742 | } else if (has_dynamic_viewport_with_count) { |
| 2743 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379", |
| 2744 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2745 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2746 | ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.", |
| 2747 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2748 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2749 | |
| 2750 | if (viewport_state.scissorCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2751 | if (!has_dynamic_scissor_with_count) { |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2752 | const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) |
| 2753 | ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136" |
| 2754 | : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength"; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2755 | skip |= LogError( |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2756 | device, vuid, |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2757 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
| 2758 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2759 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2760 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 2761 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2762 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2763 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2764 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2765 | } else if (has_dynamic_scissor_with_count) { |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2766 | const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) |
| 2767 | ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136" |
| 2768 | : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380"; |
| 2769 | skip |= LogError(device, vuid, |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2770 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2771 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2772 | ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.", |
| 2773 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2774 | } |
| 2775 | } |
| 2776 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2777 | if (!has_dynamic_scissor && viewport_state.pScissors) { |
| 2778 | for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) { |
| 2779 | const auto &scissor = viewport_state.pScissors[scissor_i]; |
ziga-lunarg | a77dc80 | 2021-07-15 13:19:06 +0200 | [diff] [blame] | 2780 | |
| 2781 | if (scissor.offset.x < 0) { |
| 2782 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821", |
| 2783 | "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32 |
| 2784 | "].pViewportState->pScissors[%" PRIu32 "] is negative.", |
| 2785 | scissor.offset.x, i, scissor_i); |
| 2786 | } |
| 2787 | |
| 2788 | if (scissor.offset.y < 0) { |
| 2789 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821", |
| 2790 | "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32 |
| 2791 | "].pViewportState->pScissors[%" PRIu32 "] is negative.", |
| 2792 | scissor.offset.y, i, scissor_i); |
| 2793 | } |
| 2794 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2795 | const int64_t x_sum = |
| 2796 | static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 2797 | if (x_sum > std::numeric_limits<int32_t>::max()) { |
| 2798 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822", |
| 2799 | "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 |
| 2800 | " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32 |
| 2801 | "] will overflow int32_t.", |
| 2802 | scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i); |
| 2803 | } |
ziga-lunarg | a77dc80 | 2021-07-15 13:19:06 +0200 | [diff] [blame] | 2804 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2805 | const int64_t y_sum = |
| 2806 | static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 2807 | if (y_sum > std::numeric_limits<int32_t>::max()) { |
| 2808 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823", |
| 2809 | "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 |
| 2810 | " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32 |
| 2811 | "] will overflow int32_t.", |
| 2812 | scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i); |
| 2813 | } |
| 2814 | } |
| 2815 | } |
| 2816 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2817 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2818 | skip |= |
| 2819 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 2820 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2821 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2822 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2823 | } |
| 2824 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2825 | if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2826 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 2827 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2828 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2829 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2830 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2831 | } |
| 2832 | |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2833 | if (viewport_state.scissorCount != viewport_state.viewportCount) { |
| 2834 | if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) || |
| 2835 | (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) { |
| 2836 | const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) |
| 2837 | ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134" |
| 2838 | : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220"; |
| 2839 | skip |= LogError( |
| 2840 | device, vuid, |
| 2841 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2842 | ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2843 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
| 2844 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2845 | } |
| 2846 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2847 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2848 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2849 | skip |= |
| 2850 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 2851 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2852 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 2853 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2854 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2855 | } |
| 2856 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2857 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2858 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2859 | skip |= LogError( |
| 2860 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2861 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 2862 | "] " |
| 2863 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2864 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2865 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2866 | } |
| 2867 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2868 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2869 | skip |= LogError( |
| 2870 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2871 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 2872 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2873 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 2874 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2875 | } |
| 2876 | |
| 2877 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2878 | skip |= LogError( |
| 2879 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2880 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 2881 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2882 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 2883 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2884 | } |
| 2885 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2886 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2887 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 2888 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 2889 | skip |= |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2890 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2891 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 2892 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 2893 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 2894 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2895 | } |
| 2896 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2897 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2898 | shading_rate_image_struct->viewportCount > 0 && |
| 2899 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2900 | skip |= LogError( |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2901 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2902 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2903 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 2904 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2905 | i, i); |
| 2906 | } |
| 2907 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2908 | if (vp_swizzle_struct) { |
| 2909 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2910 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 2911 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 2912 | " does " |
| 2913 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 2914 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2915 | } |
| 2916 | } |
| 2917 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2918 | // validate the VkViewports |
| 2919 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 2920 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 2921 | const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 2922 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 2923 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 2924 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 2925 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2926 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2927 | } |
| 2928 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2929 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2930 | if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2931 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2932 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2933 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 2934 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 2935 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2936 | } |
| 2937 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2938 | if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2939 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2940 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2941 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 2942 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 2943 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2944 | } |
| 2945 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2946 | if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2947 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2948 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2949 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 2950 | "VK_EXT_sample_locations extension is not enabled.", |
| 2951 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2952 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2953 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2954 | if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2955 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2956 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2957 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 2958 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 2959 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2960 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2961 | |
| 2962 | if (coarse_sample_order_struct && |
| 2963 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 2964 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2965 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 2966 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2967 | "] " |
| 2968 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 2969 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 2970 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2971 | } |
| 2972 | |
| 2973 | if (coarse_sample_order_struct) { |
| 2974 | for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2975 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2976 | } |
| 2977 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2978 | |
| 2979 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 2980 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2981 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 2982 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2983 | "] " |
| 2984 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 2985 | ") " |
| 2986 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 2987 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2988 | } |
| 2989 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2990 | skip |= LogError( |
| 2991 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2992 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2993 | "] " |
| 2994 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 2995 | i); |
| 2996 | } |
| 2997 | } |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2998 | |
| 2999 | if (depth_clip_control_struct) { |
| 3000 | const auto *depth_clip_control_features = |
| 3001 | LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext); |
| 3002 | const bool enabled_depth_clip_control = |
| 3003 | depth_clip_control_features && depth_clip_control_features->depthClipControl; |
| 3004 | if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) { |
| 3005 | skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470", |
| 3006 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 3007 | "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the " |
| 3008 | "depthClipControl feature is not enabled. ", |
| 3009 | i); |
| 3010 | } |
| 3011 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3012 | } |
| 3013 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3014 | const bool is_frag_out_graphics_lib = |
| 3015 | graphics_lib_info && |
| 3016 | ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0); |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3017 | if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3018 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3019 | "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32 |
| 3020 | "].pRasterizationState->rasterizerDiscardEnable " |
| 3021 | "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3022 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3023 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 3024 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 3025 | LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType, |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 3026 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 3027 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 3028 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3029 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 3030 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3031 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3032 | // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3033 | if (create_info.pMultisampleState) { |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3034 | skip |= validate_struct_pnext( |
| 3035 | "vkCreateGraphicsPipelines", |
| 3036 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3037 | valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes, |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3038 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 3039 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3040 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3041 | skip |= validate_reserved_flags( |
| 3042 | "vkCreateGraphicsPipelines", |
| 3043 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3044 | create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3045 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3046 | skip |= validate_bool32( |
| 3047 | "vkCreateGraphicsPipelines", |
| 3048 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3049 | create_info.pMultisampleState->sampleShadingEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3050 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3051 | skip |= validate_array( |
| 3052 | "vkCreateGraphicsPipelines", |
| 3053 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", |
| 3054 | ParameterName::IndexVector{i}), |
| 3055 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3056 | create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true, |
| 3057 | false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 3058 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3059 | skip |= validate_flags("vkCreateGraphicsPipelines", |
| 3060 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", |
| 3061 | ParameterName::IndexVector{i}), |
| 3062 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3063 | create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit, |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3064 | "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3065 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3066 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
| 3067 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", |
| 3068 | ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3069 | create_info.pMultisampleState->alphaToCoverageEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3070 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3071 | skip |= validate_bool32( |
| 3072 | "vkCreateGraphicsPipelines", |
| 3073 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3074 | create_info.pMultisampleState->alphaToOneEnable); |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3075 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3076 | if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) { |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3077 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType", |
| 3078 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32 |
| 3079 | "].pMultisampleState->sType must be " |
| 3080 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3081 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 3082 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3083 | if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3084 | if (!physical_device_features.sampleRateShading) { |
| 3085 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 3086 | "vkCreateGraphicsPipelines(): parameter " |
| 3087 | "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.", |
| 3088 | i); |
| 3089 | } |
| 3090 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 3091 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3092 | if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3093 | skip |= LogError(device, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3094 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3095 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
| 3096 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32 |
| 3097 | "].pMultisampleState->minSampleShading.", |
| 3098 | i); |
| 3099 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 3100 | } |
| 3101 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3102 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3103 | const auto *line_state = |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3104 | LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3105 | |
| 3106 | if (line_state) { |
| 3107 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 3108 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3109 | if (create_info.pMultisampleState->alphaToCoverageEnable) { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3110 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3111 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 3112 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3113 | "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3114 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3115 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3116 | if (create_info.pMultisampleState->alphaToOneEnable) { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3117 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3118 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 3119 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3120 | "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3121 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3122 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3123 | if (create_info.pMultisampleState->sampleShadingEnable) { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3124 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3125 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 3126 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3127 | "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3128 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3129 | } |
| 3130 | } |
| 3131 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 3132 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 3133 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3134 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3135 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32 |
| 3136 | " must be in the " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3137 | "range [1,256].", |
| 3138 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3139 | } |
| 3140 | } |
| 3141 | const auto *line_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3142 | LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3143 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 3144 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3145 | skip |= |
| 3146 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3147 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3148 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3149 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 3150 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3151 | } |
| 3152 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 3153 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3154 | skip |= |
| 3155 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3156 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3157 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3158 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 3159 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3160 | } |
| 3161 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 3162 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3163 | skip |= |
| 3164 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3165 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3166 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3167 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 3168 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3169 | } |
| 3170 | if (line_state->stippledLineEnable) { |
| 3171 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 3172 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3173 | skip |= |
| 3174 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3175 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3176 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3177 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 3178 | "stippledRectangularLines feature.", |
| 3179 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3180 | } |
| 3181 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 3182 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3183 | skip |= |
| 3184 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3185 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3186 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3187 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 3188 | "stippledBresenhamLines feature.", |
| 3189 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3190 | } |
| 3191 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 3192 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3193 | skip |= |
| 3194 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3195 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3196 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3197 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 3198 | "stippledSmoothLines feature.", |
| 3199 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3200 | } |
| 3201 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
Malcolm Bechard | fc50900 | 2021-11-17 21:57:28 -0500 | [diff] [blame] | 3202 | (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3203 | skip |= |
| 3204 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3205 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3206 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3207 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 3208 | "stippledRectangularLines and strictLines features.", |
| 3209 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3210 | } |
| 3211 | } |
| 3212 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3213 | } |
| 3214 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3215 | bool uses_color_attachment = false; |
| 3216 | bool uses_depthstencil_attachment = false; |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3217 | VkSubpassDescriptionFlags subpass_flags = 0; |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3218 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 3219 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3220 | const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3221 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3222 | const auto &subpasses_uses = subpasses_uses_it->second; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3223 | if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3224 | uses_color_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3225 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3226 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3227 | uses_depthstencil_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3228 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3229 | subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass]; |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3230 | |
| 3231 | color_attachment_count = subpasses_uses.color_attachment_count; |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3232 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 3233 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3234 | } |
| 3235 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3236 | if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3237 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3238 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3239 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3240 | create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 3241 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3242 | |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3243 | skip |= |
| 3244 | validate_flags("vkCreateGraphicsPipelines", |
| 3245 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
| 3246 | "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3247 | create_info.pDepthStencilState->flags, kOptionalFlags, |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3248 | "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3249 | |
| 3250 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3251 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3252 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3253 | create_info.pDepthStencilState->depthTestEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3254 | |
| 3255 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3256 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3257 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3258 | create_info.pDepthStencilState->depthWriteEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3259 | |
| 3260 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3261 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3262 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3263 | "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3264 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3265 | |
| 3266 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3267 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3268 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3269 | create_info.pDepthStencilState->depthBoundsTestEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3270 | |
| 3271 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3272 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3273 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3274 | create_info.pDepthStencilState->stencilTestEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3275 | |
| 3276 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3277 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3278 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3279 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3280 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3281 | |
| 3282 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3283 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3284 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3285 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3286 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3287 | |
| 3288 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3289 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3290 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3291 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3292 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3293 | |
| 3294 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3295 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3296 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3297 | "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3298 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3299 | |
| 3300 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3301 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3302 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3303 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3304 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3305 | |
| 3306 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3307 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3308 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3309 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3310 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3311 | |
| 3312 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3313 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3314 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3315 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3316 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3317 | |
| 3318 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3319 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3320 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3321 | "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3322 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3323 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3324 | if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 3325 | skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3326 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32 |
| 3327 | "].pDepthStencilState->sType must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3328 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 3329 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3330 | } |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3331 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3332 | if ((create_info.pDepthStencilState->flags & |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3333 | VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) { |
| 3334 | const auto *rasterization_order_attachment_access_feature = |
| 3335 | LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext); |
| 3336 | const bool rasterization_order_depth_attachment_access_feature_enabled = |
| 3337 | rasterization_order_attachment_access_feature && |
| 3338 | rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE; |
| 3339 | if (!rasterization_order_depth_attachment_access_feature_enabled) { |
| 3340 | skip |= LogError( |
| 3341 | device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463", |
| 3342 | "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::" |
| 3343 | "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but " |
| 3344 | "VkPipelineDepthStencilStateCreateInfo::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3345 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3346 | } |
| 3347 | |
| 3348 | if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) { |
| 3349 | skip |= LogError( |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 3350 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485", |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3351 | "VkPipelineDepthStencilStateCreateInfo::flags == %s but " |
| 3352 | "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3353 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(), |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3354 | string_VkSubpassDescriptionFlags(subpass_flags).c_str()); |
| 3355 | } |
| 3356 | } |
| 3357 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3358 | if ((create_info.pDepthStencilState->flags & |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3359 | VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) { |
| 3360 | const auto *rasterization_order_attachment_access_feature = |
| 3361 | LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext); |
| 3362 | const bool rasterization_order_stencil_attachment_access_feature_enabled = |
| 3363 | rasterization_order_attachment_access_feature && |
| 3364 | rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE; |
| 3365 | if (!rasterization_order_stencil_attachment_access_feature_enabled) { |
| 3366 | skip |= LogError( |
| 3367 | device, |
| 3368 | "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464", |
| 3369 | "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::" |
| 3370 | "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but " |
| 3371 | "VkPipelineDepthStencilStateCreateInfo::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3372 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3373 | } |
| 3374 | |
| 3375 | if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) { |
| 3376 | skip |= LogError( |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 3377 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486", |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3378 | "VkPipelineDepthStencilStateCreateInfo::flags == %s but " |
| 3379 | "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3380 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(), |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3381 | string_VkSubpassDescriptionFlags(subpass_flags).c_str()); |
| 3382 | } |
| 3383 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3384 | } |
| 3385 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3386 | const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = { |
ziga-lunarg | 8de0916 | 2021-08-05 15:21:33 +0200 | [diff] [blame] | 3387 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT, |
| 3388 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT}; |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 3389 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3390 | if (create_info.pColorBlendState != nullptr && uses_color_attachment) { |
| 3391 | skip |= |
| 3392 | validate_struct_type("vkCreateGraphicsPipelines", |
| 3393 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 3394 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 3395 | create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, |
| 3396 | false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 3397 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3398 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3399 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 3400 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3401 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", |
| 3402 | create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info), |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3403 | allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 3404 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 3405 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3406 | |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3407 | skip |= validate_flags("vkCreateGraphicsPipelines", |
| 3408 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
| 3409 | "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3410 | create_info.pColorBlendState->flags, kOptionalFlags, |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3411 | "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3412 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3413 | if ((create_info.pColorBlendState->flags & |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3414 | VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) { |
| 3415 | const auto *rasterization_order_attachment_access_feature = |
| 3416 | LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext); |
| 3417 | const bool rasterization_order_color_attachment_access_feature_enabled = |
| 3418 | rasterization_order_attachment_access_feature && |
| 3419 | rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE; |
| 3420 | |
| 3421 | if (!rasterization_order_color_attachment_access_feature_enabled) { |
| 3422 | skip |= LogError( |
| 3423 | device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465", |
| 3424 | "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::" |
| 3425 | "rasterizationColorAttachmentAccess == VK_FALSE, but " |
| 3426 | "VkPipelineColorBlendStateCreateInfo::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3427 | string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3428 | } |
| 3429 | |
| 3430 | if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3431 | skip |= |
| 3432 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484", |
| 3433 | "VkPipelineColorBlendStateCreateInfo::flags == %s but " |
| 3434 | "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s", |
| 3435 | string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(), |
| 3436 | string_VkSubpassDescriptionFlags(subpass_flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3437 | } |
| 3438 | } |
| 3439 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3440 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3441 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3442 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3443 | create_info.pColorBlendState->logicOpEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3444 | |
| 3445 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3446 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3447 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 3448 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3449 | create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true, |
| 3450 | kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3451 | |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3452 | if (create_info.pColorBlendState->pAttachments != nullptr) { |
| 3453 | const VkBlendOp first_color_blend_op = create_info.pColorBlendState->pAttachments[0].colorBlendOp; |
| 3454 | const VkBlendOp first_alpha_blend_op = create_info.pColorBlendState->pAttachments[0].alphaBlendOp; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3455 | for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3456 | ++attachment_index) { |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3457 | const VkPipelineColorBlendAttachmentState attachment_state = |
| 3458 | create_info.pColorBlendState->pAttachments[attachment_index]; |
| 3459 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3460 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3461 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3462 | ParameterName::IndexVector{i, attachment_index}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3463 | attachment_state.blendEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3464 | |
| 3465 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3466 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3467 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3468 | ParameterName::IndexVector{i, attachment_index}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3469 | "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3470 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3471 | |
| 3472 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3473 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3474 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3475 | ParameterName::IndexVector{i, attachment_index}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3476 | "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3477 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3478 | |
| 3479 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3480 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3481 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3482 | ParameterName::IndexVector{i, attachment_index}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3483 | "VkBlendOp", AllVkBlendOpEnums, attachment_state.colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3484 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3485 | |
| 3486 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3487 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3488 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3489 | ParameterName::IndexVector{i, attachment_index}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3490 | "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3491 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3492 | |
| 3493 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3494 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3495 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3496 | ParameterName::IndexVector{i, attachment_index}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3497 | "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3498 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3499 | |
| 3500 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3501 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3502 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3503 | ParameterName::IndexVector{i, attachment_index}), |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3504 | "VkBlendOp", AllVkBlendOpEnums, attachment_state.alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3505 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3506 | |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3507 | skip |= validate_flags( |
| 3508 | "vkCreateGraphicsPipelines", |
| 3509 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
| 3510 | ParameterName::IndexVector{i, attachment_index}), |
| 3511 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, attachment_state.colorWriteMask, |
| 3512 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 3513 | |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3514 | // if blendEnabled is false, these values are ignored |
| 3515 | if (attachment_state.blendEnable) { |
| 3516 | bool advance_blend = false; |
| 3517 | if (IsAdvanceBlendOperation(attachment_state.colorBlendOp)) { |
| 3518 | advance_blend = true; |
| 3519 | if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) { |
| 3520 | // This VUID checks if a subset of advance blend ops are allowed |
| 3521 | switch (attachment_state.colorBlendOp) { |
| 3522 | case VK_BLEND_OP_ZERO_EXT: |
| 3523 | case VK_BLEND_OP_SRC_EXT: |
| 3524 | case VK_BLEND_OP_DST_EXT: |
| 3525 | case VK_BLEND_OP_SRC_OVER_EXT: |
| 3526 | case VK_BLEND_OP_DST_OVER_EXT: |
| 3527 | case VK_BLEND_OP_SRC_IN_EXT: |
| 3528 | case VK_BLEND_OP_DST_IN_EXT: |
| 3529 | case VK_BLEND_OP_SRC_OUT_EXT: |
| 3530 | case VK_BLEND_OP_DST_OUT_EXT: |
| 3531 | case VK_BLEND_OP_SRC_ATOP_EXT: |
| 3532 | case VK_BLEND_OP_DST_ATOP_EXT: |
| 3533 | case VK_BLEND_OP_XOR_EXT: |
| 3534 | case VK_BLEND_OP_INVERT_EXT: |
| 3535 | case VK_BLEND_OP_INVERT_RGB_EXT: |
| 3536 | case VK_BLEND_OP_LINEARDODGE_EXT: |
| 3537 | case VK_BLEND_OP_LINEARBURN_EXT: |
| 3538 | case VK_BLEND_OP_VIVIDLIGHT_EXT: |
| 3539 | case VK_BLEND_OP_LINEARLIGHT_EXT: |
| 3540 | case VK_BLEND_OP_PINLIGHT_EXT: |
| 3541 | case VK_BLEND_OP_HARDMIX_EXT: |
| 3542 | case VK_BLEND_OP_PLUS_EXT: |
| 3543 | case VK_BLEND_OP_PLUS_CLAMPED_EXT: |
| 3544 | case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT: |
| 3545 | case VK_BLEND_OP_PLUS_DARKER_EXT: |
| 3546 | case VK_BLEND_OP_MINUS_EXT: |
| 3547 | case VK_BLEND_OP_MINUS_CLAMPED_EXT: |
| 3548 | case VK_BLEND_OP_CONTRAST_EXT: |
| 3549 | case VK_BLEND_OP_INVERT_OVG_EXT: |
| 3550 | case VK_BLEND_OP_RED_EXT: |
| 3551 | case VK_BLEND_OP_GREEN_EXT: |
| 3552 | case VK_BLEND_OP_BLUE_EXT: { |
| 3553 | skip |= LogError( |
| 3554 | device, |
| 3555 | "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409", |
| 3556 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 3557 | "].pColorBlendState->pAttachments[%" PRIu32 |
| 3558 | "].colorBlendOp (%s) is not valid when " |
| 3559 | "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::" |
| 3560 | "advancedBlendAllOperations is " |
| 3561 | "VK_FALSE", |
| 3562 | i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp)); |
| 3563 | break; |
| 3564 | } |
| 3565 | default: |
| 3566 | break; |
| 3567 | } |
| 3568 | } |
| 3569 | |
| 3570 | if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendIndependentBlend == |
| 3571 | VK_FALSE && |
| 3572 | attachment_state.colorBlendOp != first_color_blend_op) { |
| 3573 | skip |= LogError( |
| 3574 | device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendIndependentBlend-01407", |
| 3575 | "vkCreateGraphicsPipelines: advancedBlendIndependentBlend is set to VK_FALSE, but " |
| 3576 | "pCreateInfos[%" PRIu32 "].pColorBlendState->pAttachments[%" PRIu32 |
| 3577 | "].colorBlendOp (%s) is not same the other attachments (%s).", |
| 3578 | i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp), |
| 3579 | string_VkBlendOp(first_color_blend_op)); |
| 3580 | } |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 3581 | } |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3582 | |
| 3583 | if (IsAdvanceBlendOperation(attachment_state.alphaBlendOp)) { |
| 3584 | advance_blend = true; |
| 3585 | if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendIndependentBlend == |
| 3586 | VK_FALSE && |
| 3587 | attachment_state.alphaBlendOp != first_alpha_blend_op) { |
| 3588 | skip |= LogError( |
| 3589 | device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendIndependentBlend-01408", |
| 3590 | "vkCreateGraphicsPipelines: advancedBlendIndependentBlend is set to VK_FALSE, but " |
| 3591 | "pCreateInfos[%" PRIu32 "].pColorBlendState->pAttachments[%" PRIu32 |
| 3592 | "].alphaBlendOp (%s) is not same the other attachments (%s).", |
| 3593 | i, attachment_index, string_VkBlendOp(attachment_state.alphaBlendOp), |
| 3594 | string_VkBlendOp(first_alpha_blend_op)); |
| 3595 | } |
| 3596 | } |
| 3597 | |
| 3598 | if (advance_blend) { |
| 3599 | if (attachment_state.colorBlendOp != attachment_state.alphaBlendOp) { |
| 3600 | skip |= LogError(device, "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01406", |
| 3601 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 3602 | "].pColorBlendState->pAttachments[%" PRIu32 |
| 3603 | "] has different colorBlendOp (%s) and alphaBlendOp (%s) but one of " |
| 3604 | "them is an advance blend operation.", |
| 3605 | i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp), |
| 3606 | string_VkBlendOp(attachment_state.alphaBlendOp)); |
ziga-lunarg | b2d507e | 2022-09-21 02:58:52 +0200 | [diff] [blame] | 3607 | } else if (color_attachment_count > |
sjfricke | 69877a7 | 2022-08-10 09:20:01 +0900 | [diff] [blame] | 3608 | phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments) { |
| 3609 | // color_attachment_count is found one of multiple spots above |
| 3610 | // |
| 3611 | // error can guarantee it is the same VkBlendOp |
| 3612 | skip |= LogError( |
| 3613 | device, "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01410", |
| 3614 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 3615 | "].pColorBlendState->pAttachments[%" PRIu32 |
| 3616 | "] has an advance blend operation (%s) but the colorAttachmentCount (%" PRIu32 |
| 3617 | ") for the subpass is greater than advancedBlendMaxColorAttachments (%" PRIu32 ").", |
| 3618 | i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp), |
| 3619 | color_attachment_count, |
| 3620 | phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments); |
| 3621 | } |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 3622 | } |
| 3623 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3624 | } |
| 3625 | } |
| 3626 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3627 | if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 3628 | skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3629 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32 |
| 3630 | "].pColorBlendState->sType must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3631 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 3632 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3633 | } |
| 3634 | |
| 3635 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3636 | if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3637 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3638 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3639 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3640 | AllVkLogicOpEnums, create_info.pColorBlendState->logicOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3641 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3642 | } |
| 3643 | } |
| 3644 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3645 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3646 | const VkPipelineCreateFlags flags = create_info.flags; |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3647 | if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3648 | if (create_info.basePipelineIndex != -1) { |
| 3649 | if (create_info.basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3650 | skip |= |
| 3651 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3652 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32 |
| 3653 | "]->basePipelineHandle, must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3654 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3655 | "and pCreateInfos->basePipelineIndex is not -1.", |
| 3656 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3657 | } |
| 3658 | } |
| 3659 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3660 | if (create_info.basePipelineHandle != VK_NULL_HANDLE) { |
| 3661 | if (create_info.basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3662 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3663 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32 |
| 3664 | "]->basePipelineIndex, must be -1 if " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3665 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3666 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 3667 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3668 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 3669 | } else { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3670 | if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) { |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3671 | skip |= |
| 3672 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3673 | "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32 |
| 3674 | ") must be a valid" |
| 3675 | "index into the pCreateInfos array, of size %" PRIu32 ".", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3676 | i, create_info.basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 3677 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3678 | } |
| 3679 | } |
| 3680 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3681 | if (create_info.pRasterizationState) { |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3682 | if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3683 | if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3684 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3685 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 3686 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 3687 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 3688 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3689 | } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3690 | (physical_device_features.fillModeNonSolid == false)) { |
sfricke-samsung | a44586f | 2020-08-23 22:19:44 -0700 | [diff] [blame] | 3691 | skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3692 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3693 | "pCreateInfos[%" PRIu32 |
| 3694 | "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3695 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 3696 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3697 | } |
| 3698 | } else { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3699 | if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 3700 | (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3701 | (physical_device_features.fillModeNonSolid == false)) { |
| 3702 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3703 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 3704 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3705 | "pCreateInfos[%" PRIu32 |
| 3706 | "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3707 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 3708 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3709 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3710 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3711 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3712 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3713 | (create_info.pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3714 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 3715 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 3716 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 3717 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 3718 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3719 | i, i, create_info.pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3720 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3721 | } |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3722 | |
| 3723 | // Validate no flags not allowed are used |
| 3724 | if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) { |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3725 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3726 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3727 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3728 | "VK_PIPELINE_CREATE_DISPATCH_BASE.", |
| 3729 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3730 | } |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3731 | if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) && |
| 3732 | (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) { |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3733 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3734 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3735 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3736 | "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.", |
| 3737 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3738 | } |
| 3739 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) { |
| 3740 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3741 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3742 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3743 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.", |
| 3744 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3745 | } |
| 3746 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) { |
| 3747 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3748 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3749 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3750 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.", |
| 3751 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3752 | } |
| 3753 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) { |
| 3754 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3755 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3756 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3757 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.", |
| 3758 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3759 | } |
| 3760 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) { |
| 3761 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3762 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3763 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3764 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.", |
| 3765 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3766 | } |
| 3767 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) { |
| 3768 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3769 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3770 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3771 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.", |
| 3772 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3773 | } |
| 3774 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) { |
| 3775 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3776 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3777 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3778 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.", |
| 3779 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3780 | } |
| 3781 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) { |
| 3782 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3783 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3784 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3785 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.", |
| 3786 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3787 | } |
ziga-lunarg | 4bd42e4 | 2021-10-04 13:19:29 +0200 | [diff] [blame] | 3788 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) { |
| 3789 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947", |
| 3790 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3791 | "]->flags (0x%x) must not include " |
| 3792 | "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.", |
| 3793 | i, flags); |
| 3794 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3795 | } |
| 3796 | } |
| 3797 | |
| 3798 | return skip; |
| 3799 | } |
| 3800 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3801 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 3802 | uint32_t createInfoCount, |
| 3803 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 3804 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3805 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3806 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3807 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3808 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3809 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 3810 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3811 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Nathaniel Cesario | 29e1240 | 2022-03-14 09:45:23 -0600 | [diff] [blame] | 3812 | if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
| 3813 | const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount; |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 3814 | if ((feedback_count != 0) && (feedback_count != 1)) { |
Nathaniel Cesario | 29e1240 | 2022-03-14 09:45:23 -0600 | [diff] [blame] | 3815 | skip |= LogError( |
| 3816 | device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566", |
| 3817 | "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32 |
| 3818 | ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].", |
| 3819 | feedback_count, i); |
| 3820 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 3821 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 3822 | |
| 3823 | // Make sure compute stage is selected |
| 3824 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3825 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3826 | "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32 |
| 3827 | "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3828 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 3829 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3830 | |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3831 | const VkPipelineCreateFlags flags = pCreateInfos[i].flags; |
| 3832 | // Validate no flags not allowed are used |
| 3833 | if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3834 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364", |
| 3835 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3836 | "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.", |
| 3837 | i, flags); |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3838 | } |
| 3839 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) { |
| 3840 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3841 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3842 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3843 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.", |
| 3844 | i, flags); |
| 3845 | } |
| 3846 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) { |
| 3847 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3848 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3849 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3850 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.", |
| 3851 | i, flags); |
| 3852 | } |
| 3853 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) { |
| 3854 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3855 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3856 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3857 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.", |
| 3858 | i, flags); |
| 3859 | } |
| 3860 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) { |
| 3861 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3862 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3863 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3864 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.", |
| 3865 | i, flags); |
| 3866 | } |
| 3867 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) { |
| 3868 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3869 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3870 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3871 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.", |
| 3872 | i, flags); |
| 3873 | } |
| 3874 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) { |
| 3875 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3876 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3877 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3878 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.", |
| 3879 | i, flags); |
| 3880 | } |
| 3881 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) { |
| 3882 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3883 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3884 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3885 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.", |
| 3886 | i, flags); |
| 3887 | } |
ziga-lunarg | f51e65f | 2021-07-18 23:51:57 +0200 | [diff] [blame] | 3888 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) { |
| 3889 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3890 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3891 | "]->flags (0x%x) must not include " |
ziga-lunarg | f51e65f | 2021-07-18 23:51:57 +0200 | [diff] [blame] | 3892 | "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.", |
| 3893 | i, flags); |
| 3894 | } |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3895 | if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) { |
| 3896 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3897 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3898 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3899 | "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.", |
| 3900 | i, flags); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3901 | } |
ziga-lunarg | 065f240 | 2021-07-22 11:56:05 +0200 | [diff] [blame] | 3902 | if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 3903 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 3904 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 3905 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699", |
| 3906 | "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32 |
| 3907 | "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the " |
| 3908 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.", |
| 3909 | i); |
| 3910 | } |
| 3911 | } |
| 3912 | |
| 3913 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 3914 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 3915 | skip |= LogError( |
| 3916 | device, "VUID-VkComputePipelineCreateInfo-flags-00700", |
| 3917 | "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32 |
| 3918 | "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT " |
| 3919 | "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 3920 | i); |
| 3921 | } |
| 3922 | } else { |
| 3923 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
| 3924 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698", |
| 3925 | "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32 |
| 3926 | ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".", |
| 3927 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 3928 | } |
| 3929 | } |
| 3930 | } |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 3931 | |
| 3932 | std::stringstream msg; |
| 3933 | msg << "pCreateInfos[%" << i << "].stage"; |
| 3934 | ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3935 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3936 | return skip; |
| 3937 | } |
| 3938 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3939 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3940 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3941 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3942 | |
| 3943 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3944 | const auto &features = physical_device_features; |
| 3945 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3946 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3947 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 3948 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3949 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 3950 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 3951 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 3952 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3953 | } |
| 3954 | |
| 3955 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 3956 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3957 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 3958 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 3959 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3960 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3961 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3962 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3963 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 3964 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3965 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 3966 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3967 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 3968 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3969 | } |
| 3970 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3971 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 3972 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3973 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 3974 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3975 | } |
| 3976 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3977 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 3978 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3979 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 3980 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3981 | } |
| 3982 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 3983 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 3984 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 3985 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3986 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 3987 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3988 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 3989 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 3990 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 3991 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3992 | } |
| 3993 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3994 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 3995 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 3996 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3997 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3998 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3999 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 4000 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 4001 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 4002 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4003 | } |
| 4004 | |
| 4005 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 4006 | const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4007 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4008 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 4009 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 4010 | if (sampler_reduction != nullptr) { |
| 4011 | if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
sjfricke | 751b709 | 2022-04-12 21:49:37 +0900 | [diff] [blame] | 4012 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423", |
| 4013 | "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be " |
| 4014 | "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE."); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 4015 | } |
| 4016 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4017 | } |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 4018 | if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
ziga-lunarg | 01be97a | 2022-05-01 14:30:39 +0200 | [diff] [blame] | 4019 | if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) { |
| 4020 | if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) { |
| 4021 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422", |
| 4022 | "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but " |
| 4023 | "extension %s is not enabled.", |
| 4024 | string_VkSamplerReductionMode(sampler_reduction->reductionMode), |
| 4025 | string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter), |
| 4026 | VK_EXT_FILTER_CUBIC_EXTENSION_NAME); |
| 4027 | } |
| 4028 | } |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 4029 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4030 | |
| 4031 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 4032 | // valid VkBorderColor value |
| 4033 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 4034 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 4035 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4036 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 4037 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4038 | } |
| 4039 | |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 4040 | // Checks for the IMG cubic filtering extension |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 4041 | if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 4042 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 4043 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4044 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 4045 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 4046 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 4047 | } |
| 4048 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 4049 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 4050 | // Check for valid Lod range |
| 4051 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 4052 | skip |= |
| 4053 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 4054 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 4055 | } |
| 4056 | |
| 4057 | // Check mipLodBias to device limit |
| 4058 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 4059 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 4060 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 4061 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 4062 | } |
| 4063 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4064 | const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 4065 | if (sampler_conversion != nullptr) { |
| 4066 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 4067 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 4068 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 4069 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4070 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 4071 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 4072 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 4073 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 4074 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 4075 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 4076 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 4077 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 4078 | } |
| 4079 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 4080 | |
| 4081 | if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) { |
| 4082 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
| 4083 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574", |
| 4084 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 4085 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 4086 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
| 4087 | } |
| 4088 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
| 4089 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575", |
| 4090 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 4091 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 4092 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
| 4093 | } |
| 4094 | if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) { |
| 4095 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576", |
| 4096 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 4097 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.", |
| 4098 | pCreateInfo->minLod, pCreateInfo->maxLod); |
| 4099 | } |
| 4100 | if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 4101 | (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) || |
| 4102 | ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 4103 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) { |
| 4104 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577", |
| 4105 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 4106 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be " |
| 4107 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER", |
| 4108 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 4109 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
| 4110 | } |
| 4111 | if (pCreateInfo->anisotropyEnable) { |
| 4112 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578", |
| 4113 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 4114 | "pCreateInfo->anisotropyEnable must be VK_FALSE"); |
| 4115 | } |
| 4116 | if (pCreateInfo->compareEnable) { |
| 4117 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579", |
| 4118 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 4119 | "pCreateInfo->compareEnable must be VK_FALSE"); |
| 4120 | } |
| 4121 | if (pCreateInfo->unnormalizedCoordinates) { |
| 4122 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580", |
| 4123 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 4124 | "pCreateInfo->unnormalizedCoordinates must be VK_FALSE"); |
| 4125 | } |
| 4126 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4127 | |
Piers Daniell | 833b949 | 2021-11-20 11:47:10 -0700 | [diff] [blame] | 4128 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 4129 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
| 4130 | if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) { |
| 4131 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 4132 | "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n", |
| 4133 | string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 4134 | } |
| 4135 | auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext); |
| 4136 | if (!custom_create_info) { |
| 4137 | skip |= LogError( |
| 4138 | device, "VUID-VkSamplerCreateInfo-borderColor-04011", |
| 4139 | "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT " |
| 4140 | "struct in pNext chain.\n", |
| 4141 | string_VkBorderColor(pCreateInfo->borderColor)); |
| 4142 | } else { |
| 4143 | if ((custom_create_info->format != VK_FORMAT_UNDEFINED) && |
| 4144 | ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && |
| 4145 | !FormatIsSampledInt(custom_create_info->format)) || |
| 4146 | (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT && |
| 4147 | !FormatIsSampledFloat(custom_create_info->format)))) { |
| 4148 | skip |= |
| 4149 | LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013", |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 4150 | "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s " |
| 4151 | "whose type does not match\n", |
| 4152 | string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format)); |
Piers Daniell | 833b949 | 2021-11-20 11:47:10 -0700 | [diff] [blame] | 4153 | ; |
| 4154 | } |
| 4155 | } |
| 4156 | } |
| 4157 | |
| 4158 | const auto *border_color_component_mapping = |
| 4159 | LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext); |
| 4160 | if (border_color_component_mapping) { |
| 4161 | const auto *border_color_swizzle_features = |
| 4162 | LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext); |
| 4163 | bool border_color_swizzle_features_enabled = |
| 4164 | border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle; |
| 4165 | if (!border_color_swizzle_features_enabled) { |
| 4166 | skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437", |
| 4167 | "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use " |
| 4168 | "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT"); |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 4169 | } |
| 4170 | } |
| 4171 | } |
| 4172 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4173 | return skip; |
| 4174 | } |
| 4175 | |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4176 | bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info, |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4177 | const VkMutableDescriptorTypeCreateInfoEXT &mutable_create_info, |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4178 | const char *func_name) const { |
| 4179 | bool skip = false; |
| 4180 | |
| 4181 | for (uint32_t i = 0; i < create_info.bindingCount; ++i) { |
| 4182 | uint32_t mutable_type_count = 0; |
| 4183 | if (mutable_create_info.mutableDescriptorTypeListCount > i) { |
| 4184 | mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount; |
| 4185 | } |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4186 | if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) { |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4187 | if (mutable_type_count == 0) { |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4188 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-descriptorTypeCount-04597", |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4189 | "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4190 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT, but " |
| 4191 | "VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4192 | "].descriptorTypeCount is 0.", |
| 4193 | func_name, i, i); |
| 4194 | } |
| 4195 | } else { |
| 4196 | if (mutable_type_count > 0) { |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4197 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-descriptorTypeCount-04599", |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4198 | "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32 |
| 4199 | "].descriptorType is %s, but " |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4200 | "VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4201 | "].descriptorTypeCount is not 0.", |
| 4202 | func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i); |
| 4203 | } |
| 4204 | } |
| 4205 | } |
| 4206 | |
| 4207 | for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) { |
| 4208 | for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) { |
| 4209 | switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) { |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4210 | case VK_DESCRIPTOR_TYPE_MUTABLE_EXT: |
| 4211 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04600", |
| 4212 | "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
| 4213 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_EXT.", |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4214 | func_name, j, k); |
| 4215 | break; |
| 4216 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4217 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04601", |
| 4218 | "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4219 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.", |
| 4220 | func_name, j, k); |
| 4221 | break; |
| 4222 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4223 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04602", |
| 4224 | "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4225 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.", |
| 4226 | func_name, j, k); |
| 4227 | break; |
| 4228 | case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT: |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4229 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04603", |
| 4230 | "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4231 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.", |
| 4232 | func_name, j, k); |
| 4233 | break; |
| 4234 | default: |
| 4235 | break; |
| 4236 | } |
| 4237 | for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) { |
| 4238 | if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] == |
| 4239 | mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) { |
| 4240 | skip |= |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4241 | LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04598", |
| 4242 | "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4243 | "].pDescriptorTypes[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4244 | "] and VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32 |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4245 | "].pDescriptorTypes[%" PRIu32 "] are both %s.", |
| 4246 | func_name, j, k, j, l, |
| 4247 | string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k])); |
| 4248 | } |
| 4249 | } |
| 4250 | } |
| 4251 | } |
| 4252 | |
| 4253 | return skip; |
| 4254 | } |
| 4255 | |
Tony-LunarG | 115f89d | 2022-06-15 10:53:22 -0600 | [diff] [blame] | 4256 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 4257 | bool StatelessValidation::ExportMetalObjectsPNextUtil(VkExportMetalObjectTypeFlagBitsEXT bit, const char *vuid, |
| 4258 | const char *api_call, const char *sType, const void *pNext) const { |
| 4259 | bool skip = false; |
| 4260 | auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pNext); |
| 4261 | while (export_metal_object_info) { |
| 4262 | if (export_metal_object_info->exportObjectType != bit) { |
| 4263 | std::stringstream message; |
| 4264 | message << api_call |
| 4265 | << " The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose " |
| 4266 | "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of " |
| 4267 | << sType << " are allowed"; |
| 4268 | skip |= LogError(device, vuid, message.str().c_str(), |
| 4269 | string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType)); |
| 4270 | } |
| 4271 | export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext); |
| 4272 | } |
| 4273 | return skip; |
| 4274 | } |
| 4275 | #endif // VK_USE_PLATFORM_METAL_EXT |
| 4276 | |
| 4277 | bool StatelessValidation::manual_PreCallValidateCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, |
| 4278 | const VkAllocationCallbacks *pAllocator, |
| 4279 | VkSemaphore *pSemaphore) const { |
| 4280 | bool skip = false; |
| 4281 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 4282 | skip |= ExportMetalObjectsPNextUtil( |
| 4283 | VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT, "VUID-VkSemaphoreCreateInfo-pNext-06789", |
| 4284 | "vkCreateSemaphore():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT", pCreateInfo->pNext); |
| 4285 | #endif // VK_USE_PLATFORM_METAL_EXT |
| 4286 | return skip; |
| 4287 | } |
| 4288 | bool StatelessValidation::manual_PreCallValidateCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo, |
| 4289 | const VkAllocationCallbacks *pAllocator, VkEvent *pEvent) const { |
| 4290 | bool skip = false; |
| 4291 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 4292 | skip |= ExportMetalObjectsPNextUtil( |
| 4293 | VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT, "VUID-VkEventCreateInfo-pNext-06790", |
| 4294 | "vkCreateEvent():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT", pCreateInfo->pNext); |
| 4295 | #endif // VK_USE_PLATFORM_METAL_EXT |
| 4296 | return skip; |
| 4297 | } |
| 4298 | bool StatelessValidation::manual_PreCallValidateCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, |
| 4299 | const VkAllocationCallbacks *pAllocator, |
| 4300 | VkBufferView *pBufferView) const { |
| 4301 | bool skip = false; |
| 4302 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 4303 | skip |= ExportMetalObjectsPNextUtil( |
| 4304 | VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkBufferViewCreateInfo-pNext-06782", |
| 4305 | "vkCreateBufferView():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pCreateInfo->pNext); |
| 4306 | #endif // VK_USE_PLATFORM_METAL_EXT |
| 4307 | return skip; |
| 4308 | } |
| 4309 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4310 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 4311 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 4312 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4313 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4314 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4315 | |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4316 | const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoEXT>(pCreateInfo->pNext); |
| 4317 | const auto *mutable_descriptor_type_features = |
| 4318 | LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT>(device_createinfo_pnext); |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4319 | bool mutable_descriptor_type_features_enabled = |
| 4320 | mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE; |
| 4321 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4322 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
sjfricke | 9c08a43 | 2022-08-20 13:45:34 +0900 | [diff] [blame] | 4323 | if (pCreateInfo->pBindings != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4324 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 4325 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4326 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 4327 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 4328 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 4329 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 4330 | ++descriptor_index) { |
| 4331 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Spencer Fricke | b0e3082 | 2020-03-23 10:32:30 -0700 | [diff] [blame] | 4332 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4333 | "vkCreateDescriptorSetLayout: required parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4334 | "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32 |
| 4335 | "] specified as VK_NULL_HANDLE", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4336 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4337 | } |
| 4338 | } |
| 4339 | } |
| 4340 | |
| 4341 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 4342 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 4343 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4344 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4345 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32 |
| 4346 | "].descriptorCount is not 0, " |
| 4347 | "pCreateInfo->pBindings[%" PRIu32 |
| 4348 | "].stageFlags must be a valid combination of VkShaderStageFlagBits " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4349 | "values.", |
| 4350 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4351 | } |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 4352 | |
| 4353 | if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) && |
| 4354 | (pCreateInfo->pBindings[i].stageFlags != 0) && |
| 4355 | (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4356 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510", |
| 4357 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32 |
| 4358 | "].descriptorCount is not 0 and " |
| 4359 | "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32 |
| 4360 | "].stageFlags " |
| 4361 | "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s", |
| 4362 | i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str()); |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 4363 | } |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4364 | |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4365 | if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) { |
Mike Schuchardt | 360165e | 2022-09-02 11:19:04 -0700 | [diff] [blame] | 4366 | if (mutable_descriptor_type) { |
| 4367 | if (i >= mutable_descriptor_type->mutableDescriptorTypeListCount) { |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4368 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-pBindings-07303", |
Mike Schuchardt | 360165e | 2022-09-02 11:19:04 -0700 | [diff] [blame] | 4369 | "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4370 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but " |
| 4371 | "VkMutableDescriptorTypeCreateInfoEXT::mutableDescriptorTypeListCount is %" PRIu32 |
Mike Schuchardt | 360165e | 2022-09-02 11:19:04 -0700 | [diff] [blame] | 4372 | " (not large enough to contain index %" PRIu32 ")", |
| 4373 | i, mutable_descriptor_type->mutableDescriptorTypeListCount, i); |
| 4374 | } |
| 4375 | } else { |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4376 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-pBindings-07303", |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4377 | "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4378 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but " |
| 4379 | "VkMutableDescriptorTypeCreateInfoEXT is not included in the pNext chain.", |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4380 | i); |
| 4381 | } |
| 4382 | if (pCreateInfo->pBindings[i].pImmutableSamplers) { |
| 4383 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594", |
| 4384 | "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4385 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but " |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4386 | "pImmutableSamplers is not NULL.", |
| 4387 | i); |
| 4388 | } |
| 4389 | if (!mutable_descriptor_type_features_enabled) { |
| 4390 | skip |= LogError( |
| 4391 | device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595", |
| 4392 | "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4393 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but " |
| 4394 | "VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType feature is not enabled.", |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4395 | i); |
| 4396 | } |
| 4397 | } |
| 4398 | |
| 4399 | if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR && |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4400 | pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) { |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4401 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591", |
| 4402 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains " |
| 4403 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4404 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT.", |
| 4405 | i); |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4406 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4407 | } |
| 4408 | } |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4409 | |
| 4410 | if (mutable_descriptor_type) { |
paul-lunarg | ef8ed7c | 2022-07-14 13:42:53 -0600 | [diff] [blame] | 4411 | skip |= |
| 4412 | ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type, "vkDescriptorSetLayoutCreateInfo"); |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4413 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4414 | } |
sjfricke | 9c08a43 | 2022-08-20 13:45:34 +0900 | [diff] [blame] | 4415 | |
| 4416 | // TODO - Remove these 2 extension checks once the enum-to-extensions logic is generated |
| 4417 | // mostly likely will fail test trying to hit these |
| 4418 | if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR && |
| 4419 | !IsExtEnabled(device_extensions.vk_khr_push_descriptor)) { |
| 4420 | skip |= LogError( |
| 4421 | device, kVUID_Core_DrawState_ExtensionNotEnabled, |
| 4422 | "vkCreateDescriptorSetLayout(): Attempted to use %s in %s but its required extension %s has not been enabled.\n", |
| 4423 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR", "VkDescriptorSetLayoutCreateInfo::flags", |
| 4424 | VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
| 4425 | } |
| 4426 | if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT && |
| 4427 | !IsExtEnabled(device_extensions.vk_ext_descriptor_indexing)) { |
| 4428 | skip |= LogError( |
| 4429 | device, kVUID_Core_DrawState_ExtensionNotEnabled, |
| 4430 | "vkCreateDescriptorSetLayout(): Attemped to use %s in %s but its required extension %s has not been enabled.\n", |
| 4431 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT", "VkDescriptorSetLayoutCreateInfo::flags", |
| 4432 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 4433 | } |
| 4434 | |
| 4435 | if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) && |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4436 | (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT)) { |
sjfricke | 9c08a43 | 2022-08-20 13:45:34 +0900 | [diff] [blame] | 4437 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590", |
| 4438 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both " |
| 4439 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and " |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4440 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT."); |
sjfricke | 9c08a43 | 2022-08-20 13:45:34 +0900 | [diff] [blame] | 4441 | } |
| 4442 | if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) && |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4443 | (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT)) { |
sjfricke | 9c08a43 | 2022-08-20 13:45:34 +0900 | [diff] [blame] | 4444 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592", |
| 4445 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both " |
| 4446 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and " |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4447 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT."); |
sjfricke | 9c08a43 | 2022-08-20 13:45:34 +0900 | [diff] [blame] | 4448 | } |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4449 | if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT && !mutable_descriptor_type_features_enabled) { |
sjfricke | 9c08a43 | 2022-08-20 13:45:34 +0900 | [diff] [blame] | 4450 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596", |
| 4451 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains " |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 4452 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT, but " |
| 4453 | "VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType feature is not enabled."); |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4454 | } |
| 4455 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4456 | return skip; |
| 4457 | } |
| 4458 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4459 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 4460 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4461 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4462 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4463 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 4464 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4465 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 4466 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4467 | } |
| 4468 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4469 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 4470 | const VkWriteDescriptorSet *pDescriptorWrites, |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4471 | const bool isPushDescriptor) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4472 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4473 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4474 | if (pDescriptorWrites != NULL) { |
| 4475 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 4476 | // descriptorCount must be greater than 0 |
| 4477 | if (pDescriptorWrites[i].descriptorCount == 0) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4478 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 4479 | "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.", |
| 4480 | vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4481 | } |
| 4482 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4483 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4484 | if (!isPushDescriptor) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4485 | // dstSet must be a valid VkDescriptorSet handle |
| 4486 | skip |= validate_required_handle(vkCallingFunction, |
| 4487 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 4488 | pDescriptorWrites[i].dstSet); |
| 4489 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4490 | |
| 4491 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 4492 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 4493 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 4494 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 4495 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4496 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4497 | if (!isPushDescriptor) { |
| 4498 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 4499 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or |
| 4500 | // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid |
| 4501 | // VkDescriptorImageInfo structures. Valid imageView handles are checked in |
| 4502 | // ObjectLifetimes::ValidateDescriptorWrite. |
| 4503 | skip |= LogError( |
| 4504 | device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493", |
| 4505 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4506 | "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 4507 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 4508 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.", |
| 4509 | vkCallingFunction, i, i); |
| 4510 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 4511 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 4512 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 4513 | // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types |
| 4514 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and |
| 4515 | // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT |
| 4516 | skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494", |
| 4517 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4518 | "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE " |
| 4519 | "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 |
| 4520 | "].pImageInfo must not be NULL.", |
| 4521 | vkCallingFunction, i, i); |
| 4522 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4523 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 4524 | // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4525 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout |
| 4526 | // member of any given element of pImageInfo must be a valid VkImageLayout |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4527 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 4528 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4529 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4530 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 4531 | ParameterName::IndexVector{i, descriptor_index}), |
| 4532 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 4533 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4534 | } |
| 4535 | } |
| 4536 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 4537 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 4538 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 4539 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 4540 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 4541 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 4542 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4543 | // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4544 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4545 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4546 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4547 | "].descriptorType is " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4548 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 4549 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4550 | "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4551 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4552 | } else { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4553 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4554 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4555 | if (robustness2_features && robustness2_features->nullDescriptor) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4556 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 4557 | ++descriptor_index) { |
| 4558 | if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE && |
| 4559 | (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 || |
| 4560 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4561 | skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4562 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4563 | "].buffer is VK_NULL_HANDLE, " |
baldurk | 751594b | 2020-09-09 09:41:02 +0100 | [diff] [blame] | 4564 | "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4565 | vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset, |
| 4566 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4567 | } |
| 4568 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4569 | } |
| 4570 | } |
| 4571 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 4572 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4573 | // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4574 | } |
| 4575 | |
| 4576 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 4577 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4578 | VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4579 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 4580 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4581 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4582 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4583 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4584 | "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4585 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4586 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4587 | } |
| 4588 | } |
| 4589 | } |
| 4590 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 4591 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4592 | VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4593 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 4594 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4595 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4596 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4597 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4598 | "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4599 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4600 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4601 | } |
| 4602 | } |
| 4603 | } |
| 4604 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4605 | // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR |
| 4606 | // or VkWriteDescriptorSetInlineUniformBlockEX |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4607 | if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4608 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4609 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 4610 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382", |
| 4611 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext" |
| 4612 | "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4613 | "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".", |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4614 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 4615 | pDescriptorWrites[i].descriptorCount); |
| 4616 | } |
| 4617 | // further checks only if we have right structtype |
| 4618 | if (pnext_struct) { |
| 4619 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 4620 | skip |= LogError( |
| 4621 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4622 | "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32 |
| 4623 | " in the extended structure " |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4624 | ".", |
| 4625 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4626 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4627 | if (pnext_struct->accelerationStructureCount == 0) { |
| 4628 | skip |= LogError(device, |
| 4629 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4630 | "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4631 | } |
| 4632 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4633 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4634 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 4635 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 4636 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 4637 | skip |= LogError(device, |
| 4638 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580", |
| 4639 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4640 | "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4641 | } |
| 4642 | } |
| 4643 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4644 | } |
| 4645 | } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4646 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4647 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 4648 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817", |
| 4649 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext" |
| 4650 | "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4651 | "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".", |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4652 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 4653 | pDescriptorWrites[i].descriptorCount); |
| 4654 | } |
| 4655 | // further checks only if we have right structtype |
| 4656 | if (pnext_struct) { |
| 4657 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 4658 | skip |= LogError( |
| 4659 | device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4660 | "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32 |
| 4661 | " in the extended structure " |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4662 | ".", |
| 4663 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4664 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4665 | if (pnext_struct->accelerationStructureCount == 0) { |
| 4666 | skip |= LogError(device, |
| 4667 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4668 | "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4669 | } |
| 4670 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4671 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4672 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 4673 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 4674 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 4675 | skip |= LogError(device, |
| 4676 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749", |
| 4677 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4678 | "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4679 | } |
| 4680 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4681 | } |
| 4682 | } |
| 4683 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4684 | } |
| 4685 | } |
| 4686 | return skip; |
| 4687 | } |
| 4688 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4689 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 4690 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 4691 | uint32_t descriptorCopyCount, |
| 4692 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4693 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false); |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4694 | } |
| 4695 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4696 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4697 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4698 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4699 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 4700 | } |
| 4701 | |
sfricke-samsung | 681ab7b | 2020-10-29 01:53:35 -0700 | [diff] [blame] | 4702 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
| 4703 | const VkAllocationCallbacks *pAllocator, |
| 4704 | VkRenderPass *pRenderPass) const { |
| 4705 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 4706 | } |
| 4707 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4708 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4709 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4710 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4711 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 4712 | } |
| 4713 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4714 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 4715 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4716 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4717 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4718 | |
| 4719 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4720 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 4721 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4722 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 4723 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4724 | return skip; |
| 4725 | } |
| 4726 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4727 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4728 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4729 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 4730 | |
| 4731 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 4732 | const char *cmd_name = "vkBeginCommandBuffer"; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4733 | bool cb_is_secondary; |
| 4734 | { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 4735 | auto lock = CBReadLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4736 | cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end()); |
| 4737 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4738 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4739 | if (cb_is_secondary) { |
| 4740 | // Implicit VUs |
| 4741 | // validate only sType here; pointer has to be validated in core_validation |
| 4742 | const bool k_not_required = false; |
| 4743 | const char *k_no_vuid = nullptr; |
| 4744 | const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo; |
| 4745 | skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4746 | info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid, |
| 4747 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4748 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4749 | if (info) { |
| 4750 | const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = { |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 4751 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT, |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 4752 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR, |
| 4753 | VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD, |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 4754 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV}; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4755 | skip |= validate_struct_pnext( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4756 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", |
| 4757 | info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info), |
| 4758 | allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion, |
| 4759 | "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4760 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4761 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4762 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4763 | // Explicit VUs |
| 4764 | if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4765 | skip |= LogError( |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4766 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
| 4767 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 4768 | cmd_name); |
| 4769 | } |
| 4770 | |
| 4771 | if (physical_device_features.inheritedQueries) { |
| 4772 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4773 | AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags, |
| 4774 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
| 4775 | } else { // !inheritedQueries |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4776 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4777 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4778 | } |
| 4779 | |
| 4780 | if (physical_device_features.pipelineStatisticsQuery) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4781 | skip |= |
| 4782 | validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
| 4783 | AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags, |
| 4784 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
| 4785 | } else { // !pipelineStatisticsQuery |
| 4786 | skip |= |
| 4787 | validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics, |
| 4788 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4789 | } |
| 4790 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4791 | const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4792 | if (conditional_rendering) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4793 | const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4794 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 4795 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
| 4796 | skip |= LogError( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4797 | commandBuffer, |
| 4798 | "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4799 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 4800 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 4801 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 4802 | } |
ziga-lunarg | 9d01913 | 2021-07-19 01:05:31 +0200 | [diff] [blame] | 4803 | |
| 4804 | auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext); |
| 4805 | if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport && |
| 4806 | p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE && |
| 4807 | p_inherited_viewport_scissor_info->viewportDepthCount != 1) { |
| 4808 | skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783", |
| 4809 | "vkBeginCommandBuffer: multiViewport feature is disabled, but " |
| 4810 | "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in " |
| 4811 | "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1."); |
| 4812 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 4813 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4814 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4815 | return skip; |
| 4816 | } |
| 4817 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4818 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4819 | uint32_t viewportCount, const VkViewport *pViewports) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4820 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4821 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4822 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 4823 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4824 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 4825 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 4826 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 4827 | } |
| 4828 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4829 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 4830 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 4831 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 4832 | } |
| 4833 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 4834 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4835 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4836 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 4837 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4838 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4839 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4840 | } |
| 4841 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 4842 | |
| 4843 | if (pViewports) { |
| 4844 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 4845 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 4846 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4847 | skip |= manual_PreCallValidateViewport( |
| 4848 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 4849 | } |
| 4850 | } |
| 4851 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4852 | return skip; |
| 4853 | } |
| 4854 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4855 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4856 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4857 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4858 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4859 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4860 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4861 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 4862 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 4863 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4864 | } |
| 4865 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4866 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 4867 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 4868 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4869 | } |
| 4870 | } else { // multiViewport enabled |
| 4871 | const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4872 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4873 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 4874 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4875 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4876 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4877 | } |
| 4878 | } |
| 4879 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4880 | if (pScissors) { |
| 4881 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 4882 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4883 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4884 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4885 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 4886 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 4887 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4888 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4889 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4890 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4891 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 4892 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 4893 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4894 | } |
| 4895 | |
| 4896 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 4897 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4898 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 4899 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4900 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4901 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4902 | } |
| 4903 | |
| 4904 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 4905 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4906 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 4907 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4908 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4909 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4910 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4911 | } |
| 4912 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4913 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4914 | return skip; |
| 4915 | } |
| 4916 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4917 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4918 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4919 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4920 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4921 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 4922 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4923 | } |
| 4924 | |
| 4925 | return skip; |
| 4926 | } |
| 4927 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4928 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4929 | uint32_t drawCount, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4930 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4931 | |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4932 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 41ce65b | 2020-10-30 12:17:06 -0600 | [diff] [blame] | 4933 | skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4934 | "vkCmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4935 | drawCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4936 | } |
| 4937 | if (drawCount > device_limits.maxDrawIndirectCount) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4938 | skip |= |
| 4939 | LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4940 | "vkCmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4941 | drawCount, device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4942 | } |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4943 | if (offset & 3) { |
| 4944 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-offset-02710", |
| 4945 | "vkCmdDrawIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset); |
| 4946 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4947 | return skip; |
| 4948 | } |
| 4949 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4950 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4951 | VkDeviceSize offset, uint32_t drawCount, |
| 4952 | uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4953 | bool skip = false; |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4954 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4955 | skip |= LogError( |
| 4956 | device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718", |
| 4957 | "vkCmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "", |
| 4958 | drawCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4959 | } |
| 4960 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 4961 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4962 | "vkCmdDrawIndexedIndirect(): drawCount (%" PRIu32 |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4963 | ") is not less than or equal to the maximum allowed (%" PRIu32 ").", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4964 | drawCount, device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4965 | } |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4966 | if (offset & 3) { |
| 4967 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-offset-02710", |
| 4968 | "vkCmdDrawIndexedIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset); |
| 4969 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4970 | return skip; |
| 4971 | } |
| 4972 | |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4973 | bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4974 | VkDeviceSize countBufferOffset, CMD_TYPE cmd_type) const { |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4975 | bool skip = false; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4976 | if (offset & 3) { |
| 4977 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4978 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 4979 | CommandTypeString(cmd_type), offset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4980 | } |
| 4981 | |
| 4982 | if (countBufferOffset & 3) { |
| 4983 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4984 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 4985 | CommandTypeString(cmd_type), countBufferOffset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4986 | } |
| 4987 | return skip; |
| 4988 | } |
| 4989 | |
| 4990 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4991 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4992 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 4993 | uint32_t stride) const { |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 4994 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNT); |
| 4995 | } |
| 4996 | |
| 4997 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4998 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4999 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 5000 | uint32_t stride) const { |
| 5001 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNTAMD); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5002 | } |
| 5003 | |
| 5004 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5005 | VkDeviceSize offset, VkBuffer countBuffer, |
| 5006 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 5007 | uint32_t stride) const { |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5008 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNTKHR); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5009 | } |
| 5010 | |
| 5011 | bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5012 | VkDeviceSize countBufferOffset, CMD_TYPE cmd_type) const { |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5013 | bool skip = false; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5014 | if (offset & 3) { |
| 5015 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5016 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 5017 | CommandTypeString(cmd_type), offset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5018 | } |
| 5019 | |
| 5020 | if (countBufferOffset & 3) { |
| 5021 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5022 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 5023 | CommandTypeString(cmd_type), countBufferOffset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5024 | } |
| 5025 | return skip; |
| 5026 | } |
| 5027 | |
| 5028 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5029 | VkDeviceSize offset, VkBuffer countBuffer, |
| 5030 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 5031 | uint32_t stride) const { |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5032 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNT); |
| 5033 | } |
| 5034 | |
| 5035 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5036 | VkDeviceSize offset, VkBuffer countBuffer, |
| 5037 | VkDeviceSize countBufferOffset, |
| 5038 | uint32_t maxDrawCount, uint32_t stride) const { |
| 5039 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNTAMD); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5040 | } |
| 5041 | |
| 5042 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5043 | VkDeviceSize offset, VkBuffer countBuffer, |
| 5044 | VkDeviceSize countBufferOffset, |
| 5045 | uint32_t maxDrawCount, uint32_t stride) const { |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5046 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNTKHR); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 5047 | } |
| 5048 | |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 5049 | bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 5050 | const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount, |
| 5051 | uint32_t firstInstance, uint32_t stride) const { |
| 5052 | bool skip = false; |
| 5053 | if (stride & 3) { |
| 5054 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936", |
| 5055 | "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride); |
| 5056 | } |
| 5057 | if (drawCount && nullptr == pVertexInfo) { |
| 5058 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935", |
| 5059 | "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing " |
| 5060 | "one or more valid instances of VkMultiDrawInfoEXT structures"); |
| 5061 | } |
| 5062 | return skip; |
| 5063 | } |
| 5064 | |
| 5065 | bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 5066 | const VkMultiDrawIndexedInfoEXT *pIndexInfo, |
| 5067 | uint32_t instanceCount, uint32_t firstInstance, |
| 5068 | uint32_t stride, const int32_t *pVertexOffset) const { |
| 5069 | bool skip = false; |
| 5070 | if (stride & 3) { |
| 5071 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941", |
| 5072 | "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride); |
| 5073 | } |
| 5074 | if (drawCount && nullptr == pIndexInfo) { |
| 5075 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940", |
| 5076 | "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to " |
| 5077 | "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures"); |
| 5078 | } |
| 5079 | return skip; |
| 5080 | } |
| 5081 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 5082 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 5083 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5084 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 5085 | bool skip = false; |
| 5086 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 5087 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5088 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5089 | "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 5090 | } |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 5091 | if (pRects[rect].rect.extent.width == 0) { |
| 5092 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5093 | "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect); |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 5094 | } |
| 5095 | if (pRects[rect].rect.extent.height == 0) { |
| 5096 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5097 | "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect); |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 5098 | } |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 5099 | } |
| 5100 | return skip; |
| 5101 | } |
| 5102 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 5103 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 5104 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 5105 | VkImageFormatProperties2 *pImageFormatProperties, |
| 5106 | const char *apiName) const { |
| 5107 | bool skip = false; |
| 5108 | |
| 5109 | if (pImageFormatInfo != nullptr) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5110 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 5111 | if (image_stencil_struct != nullptr) { |
| 5112 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 5113 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 5114 | // No flags other than the legal attachment bits may be set |
| 5115 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 5116 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5117 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 5118 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 5119 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 5120 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 5121 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 5122 | } |
| 5123 | } |
| 5124 | } |
ziga-lunarg | d3da253 | 2021-08-11 11:50:12 +0200 | [diff] [blame] | 5125 | const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext); |
| 5126 | if (image_drm_format) { |
| 5127 | if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 5128 | skip |= LogError( |
| 5129 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", |
| 5130 | "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, " |
| 5131 | "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", |
| 5132 | apiName, string_VkImageTiling(pImageFormatInfo->tiling)); |
| 5133 | } |
ziga-lunarg | 27e256d | 2021-10-07 23:38:12 +0200 | [diff] [blame] | 5134 | if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) { |
| 5135 | skip |= LogError( |
| 5136 | physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315", |
| 5137 | "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, " |
| 5138 | "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".", |
| 5139 | apiName, image_drm_format->queueFamilyIndexCount); |
| 5140 | } |
ziga-lunarg | d3da253 | 2021-08-11 11:50:12 +0200 | [diff] [blame] | 5141 | } else { |
| 5142 | if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 5143 | skip |= LogError( |
| 5144 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", |
| 5145 | "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include " |
| 5146 | "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", |
| 5147 | apiName); |
| 5148 | } |
| 5149 | } |
| 5150 | if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT && |
| 5151 | (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) { |
| 5152 | const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext); |
| 5153 | if (!format_list || format_list->viewFormatCount == 0) { |
| 5154 | skip |= LogError( |
| 5155 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313", |
| 5156 | "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT " |
| 5157 | "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.", |
| 5158 | apiName); |
| 5159 | } |
| 5160 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 5161 | } |
| 5162 | |
| 5163 | return skip; |
| 5164 | } |
| 5165 | |
| 5166 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 5167 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 5168 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 5169 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 5170 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 5171 | } |
| 5172 | |
| 5173 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 5174 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 5175 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 5176 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 5177 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 5178 | } |
| 5179 | |
Lionel Landwerlin | 5fe5275 | 2020-07-22 08:18:14 +0300 | [diff] [blame] | 5180 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties( |
| 5181 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, |
| 5182 | VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const { |
| 5183 | bool skip = false; |
| 5184 | |
| 5185 | if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 5186 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248", |
| 5187 | "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT."); |
| 5188 | } |
| 5189 | |
| 5190 | return skip; |
| 5191 | } |
| 5192 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 5193 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 5194 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 5195 | bool skip = false; |
| 5196 | |
| 5197 | if (pRegions != nullptr) { |
| 5198 | for (uint32_t i = 0; i < regionCount; i++) { |
| 5199 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5200 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5201 | "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 5202 | } |
| 5203 | } |
| 5204 | } |
| 5205 | return skip; |
| 5206 | } |
| 5207 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 5208 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, |
| 5209 | const VkCopyBufferInfo2KHR *pCopyBufferInfo) const { |
| 5210 | bool skip = false; |
| 5211 | |
| 5212 | if (pCopyBufferInfo->pRegions != nullptr) { |
| 5213 | for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) { |
| 5214 | if (pCopyBufferInfo->pRegions[i].size == 0) { |
Tony-LunarG | ef03547 | 2021-11-02 10:23:33 -0600 | [diff] [blame] | 5215 | skip |= LogError(device, "VUID-VkBufferCopy2-size-01988", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5216 | "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 5217 | } |
| 5218 | } |
| 5219 | } |
| 5220 | return skip; |
| 5221 | } |
| 5222 | |
Tony-LunarG | ef03547 | 2021-11-02 10:23:33 -0600 | [diff] [blame] | 5223 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer, |
| 5224 | const VkCopyBufferInfo2 *pCopyBufferInfo) const { |
| 5225 | bool skip = false; |
| 5226 | |
| 5227 | if (pCopyBufferInfo->pRegions != nullptr) { |
| 5228 | for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) { |
| 5229 | if (pCopyBufferInfo->pRegions[i].size == 0) { |
| 5230 | skip |= LogError(device, "VUID-VkBufferCopy2-size-01988", |
| 5231 | "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i); |
| 5232 | } |
| 5233 | } |
| 5234 | } |
| 5235 | return skip; |
| 5236 | } |
| 5237 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5238 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5239 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 5240 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5241 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5242 | |
| 5243 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5244 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 5245 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 5246 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5247 | } |
| 5248 | |
| 5249 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5250 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 5251 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 5252 | "), must be greater than zero and less than or equal to 65536.", |
| 5253 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5254 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5255 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 5256 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 5257 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5258 | } |
| 5259 | return skip; |
| 5260 | } |
| 5261 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5262 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5263 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5264 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5265 | |
| 5266 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5267 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 5268 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 5269 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5270 | } |
| 5271 | |
| 5272 | if (size != VK_WHOLE_SIZE) { |
| 5273 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5274 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5275 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 5276 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5277 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5278 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 5279 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5280 | } |
| 5281 | } |
| 5282 | return skip; |
| 5283 | } |
| 5284 | |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5285 | bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5286 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5287 | |
| 5288 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5289 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 5290 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 5291 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 5292 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5293 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5294 | "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 5295 | "pCreateInfo->queueFamilyIndexCount must be greater than 1.", |
| 5296 | func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5297 | } |
| 5298 | |
| 5299 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 5300 | // queueFamilyIndexCount uint32_t values |
| 5301 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5302 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5303 | "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5304 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5305 | "pCreateInfo->queueFamilyIndexCount uint32_t values.", |
| 5306 | func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5307 | } |
| 5308 | } |
| 5309 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 5310 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5311 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5312 | |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5313 | // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo |
| 5314 | const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext); |
| 5315 | if (format_list_info) { |
| 5316 | const uint32_t viewFormatCount = format_list_info->viewFormatCount; |
| 5317 | if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) { |
| 5318 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100", |
| 5319 | "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5320 | "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 |
| 5321 | ") must be 0 or 1 if it is in the pNext chain.", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5322 | func_name, viewFormatCount); |
| 5323 | } |
| 5324 | |
| 5325 | // Using the first format, compare the rest of the formats against it that they are compatible |
| 5326 | for (uint32_t i = 1; i < viewFormatCount; i++) { |
| 5327 | if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) != |
| 5328 | FormatCompatibilityClass(format_list_info->pViewFormats[i])) { |
| 5329 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099", |
| 5330 | "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5331 | "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32 |
| 5332 | "] (%s) are not compatible in the pNext chain.", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5333 | func_name, string_VkFormat(format_list_info->pViewFormats[0]), i, |
| 5334 | string_VkFormat(format_list_info->pViewFormats[i])); |
| 5335 | } |
| 5336 | } |
| 5337 | } |
| 5338 | |
| 5339 | // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR |
| 5340 | if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) { |
| 5341 | if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) { |
| 5342 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 5343 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the " |
| 5344 | "VK_KHR_swapchain_mutable_format extension, which has not been enabled.", |
| 5345 | func_name); |
| 5346 | } else { |
| 5347 | if (format_list_info == nullptr) { |
| 5348 | skip |= LogError( |
| 5349 | device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 5350 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of " |
| 5351 | "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.", |
| 5352 | func_name); |
| 5353 | } else if (format_list_info->viewFormatCount == 0) { |
| 5354 | skip |= LogError( |
| 5355 | device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 5356 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount " |
| 5357 | "member of VkImageFormatListCreateInfo in the pNext chain is zero.", |
| 5358 | func_name); |
| 5359 | } else { |
| 5360 | bool found_base_format = false; |
| 5361 | for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) { |
| 5362 | if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) { |
| 5363 | found_base_format = true; |
| 5364 | break; |
| 5365 | } |
| 5366 | } |
| 5367 | if (!found_base_format) { |
| 5368 | skip |= |
| 5369 | LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 5370 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the " |
| 5371 | "elements of the pViewFormats member of VkImageFormatListCreateInfo match " |
| 5372 | "pCreateInfo->imageFormat.", |
| 5373 | func_name); |
| 5374 | } |
| 5375 | } |
| 5376 | } |
| 5377 | } |
| 5378 | } |
| 5379 | return skip; |
| 5380 | } |
| 5381 | |
| 5382 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 5383 | const VkAllocationCallbacks *pAllocator, |
| 5384 | VkSwapchainKHR *pSwapchain) const { |
| 5385 | bool skip = false; |
| 5386 | skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo); |
| 5387 | return skip; |
| 5388 | } |
| 5389 | |
| 5390 | bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, |
| 5391 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 5392 | const VkAllocationCallbacks *pAllocator, |
| 5393 | VkSwapchainKHR *pSwapchains) const { |
| 5394 | bool skip = false; |
| 5395 | if (pCreateInfos) { |
| 5396 | for (uint32_t i = 0; i < swapchainCount; i++) { |
| 5397 | std::stringstream func_name; |
| 5398 | func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()"; |
| 5399 | skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]); |
| 5400 | } |
| 5401 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5402 | return skip; |
| 5403 | } |
| 5404 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5405 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5406 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5407 | |
| 5408 | if (pPresentInfo && pPresentInfo->pNext) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5409 | const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5410 | if (present_regions) { |
| 5411 | // TODO: This and all other pNext extension dependencies should be added to code-generation |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 5412 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5413 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 5414 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
sfricke-samsung | a4cc4ff | 2020-08-23 22:05:49 -0700 | [diff] [blame] | 5415 | skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5416 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 5417 | "extension swapchainCount is %i. These values must be equal.", |
| 5418 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5419 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5420 | skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 5421 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 5422 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5423 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 5424 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 5425 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5426 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5427 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5428 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 5429 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5430 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5431 | } |
| 5432 | } |
| 5433 | |
| 5434 | return skip; |
| 5435 | } |
| 5436 | |
sfricke-samsung | 5c1b739 | 2020-12-13 22:17:15 -0800 | [diff] [blame] | 5437 | bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 5438 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 5439 | const VkAllocationCallbacks *pAllocator, |
| 5440 | VkDisplayModeKHR *pMode) const { |
| 5441 | bool skip = false; |
| 5442 | |
| 5443 | const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters; |
| 5444 | if (display_mode_parameters.visibleRegion.width == 0) { |
| 5445 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990", |
| 5446 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0."); |
| 5447 | } |
| 5448 | if (display_mode_parameters.visibleRegion.height == 0) { |
| 5449 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991", |
| 5450 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0."); |
| 5451 | } |
| 5452 | if (display_mode_parameters.refreshRate == 0) { |
| 5453 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992", |
| 5454 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0."); |
| 5455 | } |
| 5456 | |
| 5457 | return skip; |
| 5458 | } |
| 5459 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5460 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5461 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 5462 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 5463 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5464 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5465 | bool skip = false; |
| 5466 | |
| 5467 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5468 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 5469 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5470 | } |
| 5471 | |
| 5472 | return skip; |
| 5473 | } |
| 5474 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 5475 | |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5476 | static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) { |
| 5477 | bool partial_overlap = false; |
| 5478 | |
| 5479 | static const std::vector<VkDescriptorType> all_descriptor_types = { |
| 5480 | VK_DESCRIPTOR_TYPE_SAMPLER, |
| 5481 | VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 5482 | VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, |
| 5483 | VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, |
| 5484 | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, |
| 5485 | VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, |
| 5486 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 5487 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 5488 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, |
| 5489 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, |
| 5490 | VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, |
| 5491 | VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT, |
| 5492 | VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, |
| 5493 | VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, |
| 5494 | }; |
| 5495 | |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5496 | const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoEXT>(pCreateInfo->pNext); |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5497 | if (mutable_descriptor_type) { |
| 5498 | std::vector<VkDescriptorType> first_types, second_types; |
| 5499 | if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) { |
| 5500 | for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) { |
| 5501 | first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]); |
| 5502 | } |
| 5503 | } else { |
| 5504 | first_types = all_descriptor_types; |
| 5505 | } |
| 5506 | if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) { |
| 5507 | for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) { |
| 5508 | second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]); |
| 5509 | } |
| 5510 | } else { |
| 5511 | second_types = all_descriptor_types; |
| 5512 | } |
| 5513 | |
| 5514 | bool complete_overlap = first_types.size() == second_types.size(); |
| 5515 | bool disjoint = true; |
| 5516 | for (const auto first_type : first_types) { |
| 5517 | bool found = false; |
| 5518 | for (const auto second_type : second_types) { |
| 5519 | if (first_type == second_type) { |
| 5520 | found = true; |
| 5521 | break; |
| 5522 | } |
| 5523 | } |
| 5524 | if (found) { |
| 5525 | disjoint = false; |
| 5526 | } else { |
| 5527 | complete_overlap = false; |
| 5528 | } |
| 5529 | if (!disjoint && !complete_overlap) { |
| 5530 | partial_overlap = true; |
| 5531 | break; |
| 5532 | } |
| 5533 | } |
| 5534 | } |
| 5535 | |
| 5536 | return partial_overlap; |
| 5537 | } |
| 5538 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5539 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5540 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5541 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5542 | bool skip = false; |
| 5543 | |
| 5544 | if (pCreateInfo) { |
| 5545 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5546 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 5547 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5548 | } |
| 5549 | |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5550 | const auto *mutable_descriptor_type_features = |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5551 | LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT>(device_createinfo_pnext); |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5552 | bool mutable_descriptor_type_enabled = |
| 5553 | mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE; |
| 5554 | |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5555 | if (pCreateInfo->pPoolSizes) { |
| 5556 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 5557 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5558 | skip |= LogError( |
| 5559 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5560 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5561 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 5562 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 5563 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5564 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 5565 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 5566 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 5567 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 5568 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 5569 | } |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5570 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT && !mutable_descriptor_type_enabled) { |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5571 | skip |= |
| 5572 | LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608", |
| 5573 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5574 | "].type is VK_DESCRIPTOR_TYPE_MUTABLE_EXT " |
| 5575 | ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType is not enabled.", |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5576 | i); |
| 5577 | } |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5578 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) { |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5579 | for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) { |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5580 | if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) { |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5581 | if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) { |
| 5582 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787", |
| 5583 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 5584 | "].type and pCreateInfo->pPoolSizes[%" PRIu32 |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5585 | "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_EXT " |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5586 | " and have sets which partially overlap.", |
| 5587 | i, j); |
| 5588 | } |
| 5589 | } |
| 5590 | } |
| 5591 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5592 | } |
| 5593 | } |
ziga-lunarg | 0cf8521 | 2021-07-19 01:26:17 +0200 | [diff] [blame] | 5594 | |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5595 | if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT && (!mutable_descriptor_type_enabled)) { |
| 5596 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609", |
| 5597 | "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT, " |
| 5598 | "but VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType is not enabled."); |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5599 | } |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5600 | if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT) && |
ziga-lunarg | 0cf8521 | 2021-07-19 01:26:17 +0200 | [diff] [blame] | 5601 | (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) { |
| 5602 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607", |
| 5603 | "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both " |
Mike Schuchardt | 2d523e5 | 2022-09-15 12:25:58 -0700 | [diff] [blame] | 5604 | "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT"); |
ziga-lunarg | 0cf8521 | 2021-07-19 01:26:17 +0200 | [diff] [blame] | 5605 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5606 | } |
| 5607 | |
| 5608 | return skip; |
| 5609 | } |
| 5610 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5611 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5612 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5613 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5614 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5615 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5616 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5617 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 5618 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 5619 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5620 | } |
| 5621 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5622 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5623 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5624 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 5625 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 5626 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5627 | } |
| 5628 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5629 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5630 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5631 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 5632 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 5633 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5634 | } |
| 5635 | |
| 5636 | return skip; |
| 5637 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5638 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5639 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5640 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 5641 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 5642 | |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5643 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5644 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5645 | "vkCmdDispatchIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 5646 | } |
| 5647 | return skip; |
| 5648 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5649 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5650 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 5651 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5652 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5653 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5654 | |
| 5655 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5656 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5657 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5658 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 5659 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 5660 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 5661 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5662 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5663 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 5664 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 5665 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 5666 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5667 | } |
| 5668 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5669 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5670 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5671 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 5672 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 5673 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 5674 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5675 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5676 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 5677 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 5678 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 5679 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5680 | } |
| 5681 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5682 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5683 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5684 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 5685 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 5686 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 5687 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5688 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5689 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 5690 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 5691 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 5692 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5693 | } |
| 5694 | |
| 5695 | return skip; |
| 5696 | } |
| 5697 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 5698 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 5699 | VkPipelineBindPoint pipelineBindPoint, |
| 5700 | VkPipelineLayout layout, uint32_t set, |
| 5701 | uint32_t descriptorWriteCount, |
| 5702 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 5703 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true); |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 5704 | } |
| 5705 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5706 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 5707 | uint32_t firstExclusiveScissor, |
| 5708 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5709 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5710 | bool skip = false; |
| 5711 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5712 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5713 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5714 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5715 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 5716 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 5717 | ") is not 0.", |
| 5718 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5719 | } |
| 5720 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5721 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5722 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 5723 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 5724 | ") is not 1.", |
| 5725 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5726 | } |
| 5727 | } else { // multiViewport enabled |
| 5728 | const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5729 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5730 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 5731 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 5732 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5733 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5734 | } |
| 5735 | } |
| 5736 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5737 | if (pExclusiveScissors) { |
| 5738 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 5739 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 5740 | |
| 5741 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5742 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 5743 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 5744 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5745 | } |
| 5746 | |
| 5747 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5748 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 5749 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 5750 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5751 | } |
| 5752 | |
| 5753 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 5754 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5755 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 5756 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5757 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5758 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5759 | } |
| 5760 | |
| 5761 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 5762 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5763 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 5764 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5765 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5766 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5767 | } |
| 5768 | } |
| 5769 | } |
| 5770 | |
| 5771 | return skip; |
| 5772 | } |
| 5773 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 5774 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 5775 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5776 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 5777 | bool skip = false; |
Shannon McPherson | 169d0c7 | 2020-11-13 18:48:19 -0700 | [diff] [blame] | 5778 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 5779 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
| 5780 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 5781 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 5782 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 5783 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 5784 | } |
| 5785 | |
| 5786 | return skip; |
| 5787 | } |
| 5788 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5789 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 5790 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5791 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5792 | bool skip = false; |
| 5793 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5794 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5795 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5796 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5797 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 5798 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 5799 | ") is not 0.", |
| 5800 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5801 | } |
| 5802 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5803 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5804 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 5805 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 5806 | ") is not 1.", |
| 5807 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5808 | } |
| 5809 | } |
| 5810 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5811 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5812 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5813 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 5814 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 5815 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5816 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5817 | } |
| 5818 | |
| 5819 | return skip; |
| 5820 | } |
| 5821 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5822 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 5823 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 5824 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5825 | bool skip = false; |
| 5826 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5827 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5828 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 5829 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 5830 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5831 | } |
| 5832 | |
| 5833 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5834 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5835 | } |
| 5836 | |
| 5837 | return skip; |
| 5838 | } |
| 5839 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5840 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5841 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5842 | bool skip = false; |
| 5843 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5844 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5845 | skip |= LogError( |
| 5846 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5847 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 5848 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5849 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5850 | } |
| 5851 | |
| 5852 | return skip; |
| 5853 | } |
| 5854 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5855 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5856 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5857 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5858 | bool skip = false; |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5859 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5860 | skip |= LogError( |
| 5861 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5862 | "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5863 | } |
sjfricke | 91d9bda | 2022-08-01 21:44:17 +0900 | [diff] [blame] | 5864 | if (drawCount > 1 && ((stride & 3) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5865 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 5866 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 5867 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 5868 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 5869 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5870 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5871 | skip |= LogError( |
| 5872 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5873 | "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "", |
| 5874 | drawCount); |
Jeff Bolz | b574c34 | 2018-11-08 15:36:57 -0600 | [diff] [blame] | 5875 | } |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 5876 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 5877 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5878 | "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32 |
| 5879 | ") is not less than or equal to the maximum allowed (%" PRIu32 ").", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5880 | drawCount, device_limits.maxDrawIndirectCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 5881 | } |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5882 | return skip; |
| 5883 | } |
| 5884 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5885 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5886 | VkDeviceSize offset, VkBuffer countBuffer, |
| 5887 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5888 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5889 | bool skip = false; |
| 5890 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5891 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5892 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 5893 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 5894 | "), is not a multiple of 4.", |
| 5895 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5896 | } |
| 5897 | |
| 5898 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5899 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 5900 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 5901 | "), is not a multiple of 4.", |
| 5902 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5903 | } |
| 5904 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5905 | return skip; |
| 5906 | } |
| 5907 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5908 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5909 | const VkAllocationCallbacks *pAllocator, |
| 5910 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5911 | bool skip = false; |
| 5912 | |
| 5913 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 5914 | if (pCreateInfo != nullptr) { |
| 5915 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 5916 | // VkQueryPipelineStatisticFlagBits values |
| 5917 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 5918 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5919 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 5920 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 5921 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 5922 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5923 | } |
sfricke-samsung | 7d69d0d | 2020-04-25 10:27:27 -0700 | [diff] [blame] | 5924 | if (pCreateInfo->queryCount == 0) { |
| 5925 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763", |
| 5926 | "vkCreateQueryPool(): queryCount must be greater than zero."); |
| 5927 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 5928 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5929 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5930 | } |
| 5931 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5932 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 5933 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5934 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5935 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 5936 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5937 | } |
| 5938 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5939 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 5940 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 5941 | VkResult result) { |
| 5942 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5943 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5944 | } |
| 5945 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5946 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 5947 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 5948 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5949 | // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments) |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 5950 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5951 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5952 | } |
| 5953 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5954 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 5955 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5956 | // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments) |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 5957 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5958 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5959 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5960 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5961 | void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5962 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5963 | if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 5964 | auto lock = CBWriteLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5965 | for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) { |
Jeremy Gebben | fc6f815 | 2021-03-18 16:58:55 -0600 | [diff] [blame] | 5966 | secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5967 | } |
| 5968 | } |
| 5969 | } |
| 5970 | |
| 5971 | void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5972 | const VkCommandBuffer *pCommandBuffers) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 5973 | auto lock = CBWriteLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5974 | for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) { |
| 5975 | secondary_cb_map.erase(pCommandBuffers[cb_index]); |
| 5976 | } |
| 5977 | } |
| 5978 | |
| 5979 | void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5980 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 5981 | auto lock = CBWriteLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5982 | for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) { |
| 5983 | if (item->second == commandPool) { |
| 5984 | item = secondary_cb_map.erase(item); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5985 | } else { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5986 | ++item; |
| 5987 | } |
| 5988 | } |
| 5989 | } |
| 5990 | |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5991 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5992 | const VkAllocationCallbacks *pAllocator, |
| 5993 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5994 | bool skip = false; |
| 5995 | |
| 5996 | if (pAllocateInfo) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5997 | auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5998 | if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5999 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 6000 | "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority); |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 6001 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6002 | |
| 6003 | VkMemoryAllocateFlags flags = 0; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6004 | auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6005 | if (flags_info) { |
| 6006 | flags = flags_info->flags; |
| 6007 | } |
| 6008 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6009 | auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6010 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6011 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6012 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 6013 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6014 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6015 | } |
| 6016 | |
| 6017 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6018 | auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6019 | #endif |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6020 | auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 6021 | auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6022 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6023 | auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6024 | #endif |
| 6025 | |
| 6026 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6027 | skip |= LogError( |
| 6028 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6029 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 6030 | } |
| 6031 | if ( |
| 6032 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 6033 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 6034 | #endif |
| 6035 | (import_memory_fd && import_memory_fd->handleType) || |
| 6036 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 6037 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 6038 | #endif |
| 6039 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6040 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 6041 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6042 | } |
| 6043 | } |
| 6044 | |
ziga-lunarg | 1d5e11d | 2021-07-18 13:13:40 +0200 | [diff] [blame] | 6045 | auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext); |
| 6046 | if (export_memory) { |
| 6047 | auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext); |
| 6048 | if (export_memory_nv) { |
| 6049 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640", |
| 6050 | "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and " |
| 6051 | "VkExportMemoryAllocateInfoNV"); |
| 6052 | } |
| 6053 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 6054 | auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext); |
| 6055 | if (export_memory_win32_nv) { |
| 6056 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640", |
| 6057 | "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and " |
| 6058 | "VkExportMemoryWin32HandleInfoNV"); |
| 6059 | } |
| 6060 | #endif |
| 6061 | } |
| 6062 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6063 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 6064 | VkBool32 capture_replay = false; |
| 6065 | VkBool32 buffer_device_address = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6066 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 6067 | if (vulkan_12_features) { |
| 6068 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 6069 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 6070 | } else { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6071 | const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 6072 | if (bda_features) { |
| 6073 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 6074 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 6075 | } |
| 6076 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6077 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6078 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6079 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6080 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6081 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6082 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6083 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6084 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 6085 | } |
| 6086 | } |
Tony-LunarG | 115f89d | 2022-06-15 10:53:22 -0600 | [diff] [blame] | 6087 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 6088 | skip |= ExportMetalObjectsPNextUtil( |
| 6089 | VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkMemoryAllocateInfo-pNext-06780", |
| 6090 | "vkAllocateMemory():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pAllocateInfo->pNext); |
| 6091 | #endif // VK_USE_PLATFORM_METAL_EXT |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 6092 | } |
| 6093 | return skip; |
| 6094 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6095 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6096 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6097 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6098 | bool skip = false; |
| 6099 | |
| 6100 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 6101 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 6102 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6103 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6104 | } else { |
| 6105 | uint32_t vertex_component_size = 0; |
| 6106 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 6107 | vertex_component_size = 4; |
| 6108 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 6109 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 6110 | vertex_component_size = 2; |
| 6111 | } |
| 6112 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6113 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6114 | } |
| 6115 | } |
| 6116 | |
| 6117 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 6118 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6119 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6120 | } else { |
| 6121 | uint32_t index_element_size = 0; |
| 6122 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 6123 | index_element_size = 4; |
| 6124 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 6125 | index_element_size = 2; |
| 6126 | } |
| 6127 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6128 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6129 | } |
| 6130 | } |
| 6131 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 6132 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6133 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6134 | } |
| 6135 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6136 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6137 | } |
| 6138 | } |
| 6139 | |
| 6140 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6141 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6142 | } |
| 6143 | |
| 6144 | return skip; |
| 6145 | } |
| 6146 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6147 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 6148 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6149 | bool skip = false; |
| 6150 | |
| 6151 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6152 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6153 | } |
| 6154 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6155 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6156 | } |
| 6157 | |
| 6158 | return skip; |
| 6159 | } |
| 6160 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6161 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 6162 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6163 | bool skip = false; |
| 6164 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6165 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6166 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6167 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6168 | } |
| 6169 | return skip; |
| 6170 | } |
| 6171 | |
| 6172 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6173 | VkAccelerationStructureNV object_handle, const char *func_name, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 6174 | bool is_cmd) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6175 | bool skip = false; |
| 6176 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6177 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 6178 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 6179 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6180 | } |
| 6181 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6182 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 6183 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 6184 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6185 | } |
ziga-lunarg | 10309ee | 2021-08-02 13:11:21 +0200 | [diff] [blame] | 6186 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 6187 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623", |
| 6188 | "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR."); |
| 6189 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6190 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 6191 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6192 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 6193 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 6194 | "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV bit set."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6195 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6196 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6197 | skip |= LogError(object_handle, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 6198 | is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241" |
| 6199 | : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6200 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 6201 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6202 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6203 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6204 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 6205 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 6206 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6207 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 6208 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6209 | uint64_t total_triangle_count = 0; |
| 6210 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 6211 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6212 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6213 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 6214 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6215 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 6216 | continue; |
| 6217 | } |
| 6218 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 6219 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6220 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6221 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 6222 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 6223 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6224 | } |
| 6225 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 6226 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 6227 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 6228 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 6229 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 6230 | if (geometry.geometryType != first_geometry_type) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6231 | skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6232 | "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32 |
| 6233 | "].geometryType does not match " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6234 | "info.pGeometries[0].geometryType.", |
| 6235 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 6236 | } |
| 6237 | } |
| 6238 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6239 | for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) { |
| 6240 | if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV || |
| 6241 | info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) { |
| 6242 | skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503", |
| 6243 | "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV" |
| 6244 | "or VK_GEOMETRY_TYPE_AABBS_NV."); |
| 6245 | } |
| 6246 | } |
| 6247 | skip |= |
| 6248 | validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV, |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6249 | info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6250 | return skip; |
| 6251 | } |
| 6252 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6253 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 6254 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6255 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6256 | bool skip = false; |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6257 | if (pCreateInfo) { |
| 6258 | if ((pCreateInfo->compactedSize != 0) && |
| 6259 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6260 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 6261 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 6262 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 6263 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6264 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6265 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6266 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6267 | "vkCreateAccelerationStructureNV()", false); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6268 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6269 | return skip; |
| 6270 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6271 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6272 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 6273 | const VkAccelerationStructureInfoNV *pInfo, |
| 6274 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 6275 | VkBool32 update, VkAccelerationStructureNV dst, |
| 6276 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 6277 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6278 | bool skip = false; |
| 6279 | |
| 6280 | if (pInfo != nullptr) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6281 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6282 | } |
| 6283 | |
| 6284 | return skip; |
| 6285 | } |
| 6286 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6287 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR( |
| 6288 | VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 6289 | VkAccelerationStructureKHR *pAccelerationStructure) const { |
| 6290 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6291 | const auto *acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6292 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6293 | if (!acceleration_structure_features || |
| 6294 | (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) { |
| 6295 | skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611", |
| 6296 | "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled"); |
| 6297 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6298 | if (pCreateInfo) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6299 | if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR && |
| 6300 | (!acceleration_structure_features || |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6301 | (acceleration_structure_features && |
| 6302 | acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6303 | skip |= |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6304 | LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613", |
| 6305 | "vkCreateAccelerationStructureKHR(): If createFlags includes " |
| 6306 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, " |
| 6307 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6308 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6309 | if (pCreateInfo->deviceAddress && |
| 6310 | !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
| 6311 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612", |
| 6312 | "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include " |
| 6313 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR"); |
| 6314 | } |
ziga-lunarg | 8ddbe46 | 2021-09-06 16:14:17 +0200 | [diff] [blame] | 6315 | if (pCreateInfo->deviceAddress && (!acceleration_structure_features || |
| 6316 | (acceleration_structure_features && |
| 6317 | acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
| 6318 | skip |= LogError( |
| 6319 | device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488", |
| 6320 | "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but " |
| 6321 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled."); |
| 6322 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6323 | if (SafeModulo(pCreateInfo->offset, 256) != 0) { |
| 6324 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734", |
ziga-lunarg | 8ddbe46 | 2021-09-06 16:14:17 +0200 | [diff] [blame] | 6325 | "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", |
| 6326 | pCreateInfo->offset); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6327 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6328 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6329 | return skip; |
| 6330 | } |
| 6331 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6332 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 6333 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6334 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6335 | bool skip = false; |
| 6336 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6337 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 6338 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6339 | } |
| 6340 | return skip; |
| 6341 | } |
| 6342 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6343 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV( |
| 6344 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures, |
| 6345 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 6346 | bool skip = false; |
Mark Lobodzinski | c0df6b6 | 2021-01-08 12:34:11 -0700 | [diff] [blame] | 6347 | if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 6348 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6349 | "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be " |
Mark Lobodzinski | c0df6b6 | 2021-01-08 12:34:11 -0700 | [diff] [blame] | 6350 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6351 | } |
| 6352 | return skip; |
| 6353 | } |
| 6354 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6355 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 6356 | uint32_t createInfoCount, |
| 6357 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 6358 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6359 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6360 | bool skip = false; |
| 6361 | |
| 6362 | for (uint32_t i = 0; i < createInfoCount; i++) { |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 6363 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 6364 | std::stringstream msg; |
| 6365 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 6366 | ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]); |
| 6367 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6368 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6369 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 6370 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6371 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 6372 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 6373 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 6374 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6375 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6376 | |
ziga-lunarg | 22589cf | 2022-09-16 19:58:56 +0200 | [diff] [blame] | 6377 | const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6378 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6379 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
ziga-lunarg | 22589cf | 2022-09-16 19:58:56 +0200 | [diff] [blame] | 6380 | if ((!vulkan_13_features || vulkan_13_features->pipelineCreationCacheControl == VK_FALSE) && |
| 6381 | (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE)) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6382 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 6383 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 6384 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905", |
| 6385 | "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled," |
| 6386 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 6387 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 6388 | } |
| 6389 | } |
| 6390 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6391 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 6392 | skip |= |
| 6393 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904", |
| 6394 | "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 6395 | } |
| 6396 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) && |
| 6397 | (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) { |
| 6398 | skip |= |
| 6399 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957", |
| 6400 | "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and" |
| 6401 | "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time."); |
| 6402 | } |
| 6403 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 6404 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6405 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 6406 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423", |
| 6407 | "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be " |
| 6408 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 6409 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 6410 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6411 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6412 | skip |= |
| 6413 | LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415", |
| 6414 | "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the" |
| 6415 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element" |
| 6416 | "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to " |
| 6417 | "that element."); |
| 6418 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6419 | } |
| 6420 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 6421 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6422 | skip |= |
| 6423 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422", |
| 6424 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 6425 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling" |
| 6426 | "commands pCreateInfos parameter."); |
| 6427 | } |
| 6428 | } else { |
| 6429 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6430 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424", |
| 6431 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 6432 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 6433 | } |
| 6434 | } |
| 6435 | } |
| 6436 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 6437 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456", |
| 6438 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR."); |
| 6439 | } |
| 6440 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) { |
| 6441 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458", |
| 6442 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6443 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR."); |
| 6444 | } |
| 6445 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) { |
| 6446 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459", |
| 6447 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6448 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR."); |
| 6449 | } |
| 6450 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) { |
| 6451 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460", |
| 6452 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6453 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR."); |
| 6454 | } |
| 6455 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) { |
| 6456 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461", |
| 6457 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6458 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR."); |
| 6459 | } |
| 6460 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 6461 | skip |= LogError( |
| 6462 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462", |
| 6463 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 6464 | } |
| 6465 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 6466 | skip |= LogError( |
| 6467 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463", |
| 6468 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 6469 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6470 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) { |
| 6471 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588", |
| 6472 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6473 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 6474 | } |
| 6475 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 6476 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816", |
| 6477 | "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
| 6478 | } |
ziga-lunarg | dfffee4 | 2021-10-10 11:49:59 +0200 | [diff] [blame] | 6479 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) { |
| 6480 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948", |
| 6481 | "vkCreateRayTracingPipelinesNV: flags must not contain the " |
| 6482 | "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag."); |
| 6483 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6484 | } |
| 6485 | |
| 6486 | return skip; |
| 6487 | } |
| 6488 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6489 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR( |
| 6490 | VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 6491 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6492 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6493 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6494 | if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) { |
| 6495 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586", |
| 6496 | "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6497 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6498 | for (uint32_t i = 0; i < createInfoCount; i++) { |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 6499 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 6500 | std::stringstream msg; |
| 6501 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 6502 | ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(), |
aitor-lunarg | dbd9e65 | 2022-02-23 19:12:53 +0100 | [diff] [blame] | 6503 | &pCreateInfos[i].pStages[stage_index]); |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 6504 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6505 | if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) { |
| 6506 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 6507 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596", |
| 6508 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 6509 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 6510 | } |
| 6511 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 6512 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597", |
| 6513 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 6514 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR."); |
| 6515 | } |
| 6516 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6517 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6518 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 6519 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6520 | "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32 |
| 6521 | "], When chained to VkRayTracingPipelineCreateInfoKHR, " |
| 6522 | "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6523 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").", |
| 6524 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
| 6525 | } |
ziga-lunarg | 22589cf | 2022-09-16 19:58:56 +0200 | [diff] [blame] | 6526 | const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6527 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6528 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
ziga-lunarg | 22589cf | 2022-09-16 19:58:56 +0200 | [diff] [blame] | 6529 | if ((!vulkan_13_features || vulkan_13_features->pipelineCreationCacheControl == VK_FALSE) && |
| 6530 | (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE)) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6531 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 6532 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 6533 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6534 | "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled," |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6535 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 6536 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 6537 | } |
| 6538 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6539 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6540 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904", |
| 6541 | "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6542 | } |
| 6543 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6544 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6545 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6546 | "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, " |
| 6547 | "pLibraryInterface must not be NULL."); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6548 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6549 | } |
| 6550 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 6551 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816", |
| 6552 | "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6553 | } |
| 6554 | for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) { |
| 6555 | if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) || |
| 6556 | (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) { |
| 6557 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) && |
| 6558 | (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) { |
| 6559 | skip |= LogError( |
| 6560 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6561 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 6562 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6563 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 6564 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element " |
| 6565 | "must not be VK_SHADER_UNUSED_KHR"); |
| 6566 | } |
| 6567 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) && |
| 6568 | (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) { |
| 6569 | skip |= LogError( |
| 6570 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6571 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 6572 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6573 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 6574 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that " |
| 6575 | "element must not be VK_SHADER_UNUSED_KHR"); |
| 6576 | } |
| 6577 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6578 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE && |
| 6579 | pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) { |
| 6580 | if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) { |
| 6581 | skip |= LogError( |
| 6582 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599", |
| 6583 | "vkCreateRayTracingPipelinesKHR: If " |
| 6584 | "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is " |
| 6585 | "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must " |
| 6586 | "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 6587 | } |
| 6588 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6589 | } |
| 6590 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 6591 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6592 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 6593 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6594 | "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be " |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6595 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 6596 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 6597 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6598 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6599 | skip |= |
| 6600 | LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415", |
| 6601 | "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the" |
| 6602 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is" |
| 6603 | "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that " |
| 6604 | "element."); |
| 6605 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6606 | } |
| 6607 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 6608 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6609 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6610 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6611 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32 |
| 6612 | ") must be a valid into the calling" |
| 6613 | "commands pCreateInfos parameter %" PRIu32 ".", |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6614 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 6615 | } |
| 6616 | } else { |
| 6617 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6618 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6619 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6620 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 6621 | } |
| 6622 | } |
| 6623 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6624 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR && |
| 6625 | (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) { |
| 6626 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598", |
| 6627 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 6628 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, " |
| 6629 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled."); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6630 | } |
| 6631 | bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library); |
| 6632 | if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) { |
| 6633 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595", |
| 6634 | "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, " |
| 6635 | "pLibraryInfo and pLibraryInterface must be NULL."); |
| 6636 | } |
| 6637 | if (pCreateInfos[i].pLibraryInfo) { |
| 6638 | if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) { |
| 6639 | if (pCreateInfos[i].stageCount == 0) { |
| 6640 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600", |
| 6641 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 6642 | "stageCount must not be 0."); |
| 6643 | } |
| 6644 | if (pCreateInfos[i].groupCount == 0) { |
| 6645 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601", |
| 6646 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 6647 | "groupCount must not be 0."); |
| 6648 | } |
| 6649 | } else { |
| 6650 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
| 6651 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590", |
| 6652 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member " |
| 6653 | "is greater than 0, its " |
| 6654 | "pLibraryInterface member must not be NULL."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6655 | } |
| 6656 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6657 | } |
| 6658 | if (pCreateInfos[i].pLibraryInterface) { |
| 6659 | if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize > |
| 6660 | phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) { |
| 6661 | skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605", |
| 6662 | "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to " |
| 6663 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize."); |
| 6664 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6665 | } |
| 6666 | if (deferredOperation != VK_NULL_HANDLE) { |
| 6667 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) { |
| 6668 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587", |
| 6669 | "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of " |
| 6670 | "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6671 | } |
| 6672 | } |
ziga-lunarg | dea7658 | 2021-09-17 14:38:08 +0200 | [diff] [blame] | 6673 | if (pCreateInfos[i].pDynamicState) { |
| 6674 | for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) { |
| 6675 | if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) { |
| 6676 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602", |
| 6677 | "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32 |
| 6678 | "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.", |
| 6679 | i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j])); |
| 6680 | } |
| 6681 | } |
| 6682 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6683 | } |
| 6684 | |
| 6685 | return skip; |
| 6686 | } |
| 6687 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6688 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 6689 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 6690 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6691 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6692 | bool skip = false; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6693 | if (!IsExtEnabled(device_extensions.vk_khr_swapchain)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6694 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6695 | if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6696 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6697 | if (!IsExtEnabled(device_extensions.vk_khr_surface)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6698 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6699 | if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6700 | skip |= |
| 6701 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6702 | if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6703 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 6704 | skip |= validate_struct_type( |
| 6705 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 6706 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 6707 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 6708 | if (pSurfaceInfo != NULL) { |
| 6709 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 6710 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 6711 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 6712 | |
| 6713 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 6714 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 6715 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 6716 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 6717 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 6718 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6719 | |
Mike Schuchardt | 05b028d | 2022-01-05 14:15:00 -0800 | [diff] [blame] | 6720 | if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 6721 | skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521", |
| 6722 | "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 6723 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 6724 | } |
| 6725 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6726 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 6727 | } |
| 6728 | return skip; |
| 6729 | } |
| 6730 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 6731 | |
| 6732 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 6733 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6734 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 6735 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 6736 | bool skip = false; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6737 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 6738 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 6739 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 6740 | } |
| 6741 | return skip; |
| 6742 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 6743 | |
| 6744 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6745 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 6746 | bool skip = false; |
| 6747 | |
| 6748 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6749 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6750 | "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 6751 | } |
| 6752 | |
| 6753 | return skip; |
| 6754 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 6755 | |
| 6756 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6757 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 6758 | bool skip = false; |
| 6759 | |
| 6760 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6761 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 6762 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 6763 | } |
| 6764 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6765 | const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext); |
Mark Lobodzinski | 804fde8 | 2020-05-08 07:49:25 -0600 | [diff] [blame] | 6766 | if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6767 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 6768 | "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 6769 | } |
| 6770 | |
| 6771 | return skip; |
| 6772 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6773 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6774 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 6775 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 6776 | const VkDeviceSize *pOffsets) const { |
| 6777 | bool skip = false; |
| 6778 | if (firstBinding > device_limits.maxVertexInputBindings) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6779 | skip |= |
| 6780 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 6781 | "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", |
| 6782 | firstBinding, device_limits.maxVertexInputBindings); |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6783 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 6784 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6785 | "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32 |
| 6786 | ") must be less than " |
| 6787 | "maxVertexInputBindings (%" PRIu32 ")", |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6788 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 6789 | } |
| 6790 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6791 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 6792 | if (pBuffers[i] == VK_NULL_HANDLE) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6793 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6794 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6795 | skip |= |
| 6796 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001", |
| 6797 | "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6798 | } else { |
| 6799 | if (pOffsets[i] != 0) { |
| 6800 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6801 | "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 |
| 6802 | "] is not 0", |
| 6803 | i, i); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6804 | } |
| 6805 | } |
| 6806 | } |
| 6807 | } |
| 6808 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6809 | return skip; |
| 6810 | } |
| 6811 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6812 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6813 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6814 | bool skip = false; |
| 6815 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6816 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 6817 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6818 | } |
| 6819 | return skip; |
| 6820 | } |
| 6821 | |
| 6822 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6823 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6824 | bool skip = false; |
| 6825 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6826 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 6827 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6828 | } |
| 6829 | return skip; |
| 6830 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 6831 | |
| 6832 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 6833 | VkSemaphore semaphore, VkFence fence, |
| 6834 | uint32_t *pImageIndex) const { |
| 6835 | bool skip = false; |
| 6836 | |
| 6837 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6838 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 6839 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 6840 | } |
| 6841 | |
| 6842 | return skip; |
| 6843 | } |
| 6844 | |
| 6845 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 6846 | uint32_t *pImageIndex) const { |
| 6847 | bool skip = false; |
| 6848 | |
| 6849 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6850 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 6851 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 6852 | } |
| 6853 | |
| 6854 | return skip; |
| 6855 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6856 | |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 6857 | bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, |
| 6858 | uint32_t firstBinding, uint32_t bindingCount, |
| 6859 | const VkBuffer *pBuffers, |
| 6860 | const VkDeviceSize *pOffsets, |
| 6861 | const VkDeviceSize *pSizes) const { |
| 6862 | bool skip = false; |
| 6863 | |
| 6864 | char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT"; |
| 6865 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 6866 | if (pOffsets[i] & 3) { |
| 6867 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359", |
| 6868 | "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]); |
| 6869 | } |
| 6870 | } |
| 6871 | |
| 6872 | if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6873 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356", |
| 6874 | "%s: The firstBinding(%" PRIu32 |
| 6875 | ") index is greater than or equal to " |
| 6876 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6877 | cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6878 | } |
| 6879 | |
| 6880 | if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6881 | skip |= |
| 6882 | LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357", |
| 6883 | "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32 |
| 6884 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6885 | cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6886 | } |
| 6887 | |
| 6888 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 6889 | // pSizes is optional and may be nullptr. |
| 6890 | if (pSizes != nullptr) { |
| 6891 | if (pSizes[i] != VK_WHOLE_SIZE && |
| 6892 | pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) { |
| 6893 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361", |
| 6894 | "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64 |
| 6895 | ") is not VK_WHOLE_SIZE and is greater than " |
| 6896 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.", |
| 6897 | cmd_name, i, pSizes[i]); |
| 6898 | } |
| 6899 | } |
| 6900 | } |
| 6901 | |
| 6902 | return skip; |
| 6903 | } |
| 6904 | |
| 6905 | bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 6906 | uint32_t firstCounterBuffer, |
| 6907 | uint32_t counterBufferCount, |
| 6908 | const VkBuffer *pCounterBuffers, |
| 6909 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 6910 | bool skip = false; |
| 6911 | |
| 6912 | char const *const cmd_name = "CmdBeginTransformFeedbackEXT"; |
| 6913 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6914 | skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368", |
| 6915 | "%s: The firstCounterBuffer(%" PRIu32 |
| 6916 | ") index is greater than or equal to " |
| 6917 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6918 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6919 | } |
| 6920 | |
| 6921 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6922 | skip |= |
| 6923 | LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369", |
| 6924 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 6925 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6926 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 6927 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6928 | } |
| 6929 | |
| 6930 | return skip; |
| 6931 | } |
| 6932 | |
| 6933 | bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 6934 | uint32_t firstCounterBuffer, uint32_t counterBufferCount, |
| 6935 | const VkBuffer *pCounterBuffers, |
| 6936 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 6937 | bool skip = false; |
| 6938 | |
| 6939 | char const *const cmd_name = "CmdEndTransformFeedbackEXT"; |
| 6940 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6941 | skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376", |
| 6942 | "%s: The firstCounterBuffer(%" PRIu32 |
| 6943 | ") index is greater than or equal to " |
| 6944 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6945 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6946 | } |
| 6947 | |
| 6948 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6949 | skip |= |
| 6950 | LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377", |
| 6951 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 6952 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6953 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 6954 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6955 | } |
| 6956 | |
| 6957 | return skip; |
| 6958 | } |
| 6959 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6960 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 6961 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 6962 | VkDeviceSize counterBufferOffset, |
| 6963 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 6964 | bool skip = false; |
| 6965 | |
| 6966 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6967 | skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
| 6968 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32 |
| 6969 | ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").", |
| 6970 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6971 | } |
| 6972 | |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 6973 | if ((counterOffset % 4) != 0) { |
sfricke-samsung | 6886c4b | 2021-01-16 08:37:35 -0800 | [diff] [blame] | 6974 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 6975 | "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset); |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 6976 | } |
| 6977 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6978 | return skip; |
| 6979 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6980 | |
| 6981 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 6982 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 6983 | const VkAllocationCallbacks *pAllocator, |
| 6984 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 6985 | const char *apiName) const { |
| 6986 | bool skip = false; |
| 6987 | |
| 6988 | // Check samplerYcbcrConversion feature is set |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6989 | const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6990 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6991 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 6992 | if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) { |
| 6993 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6994 | "%s: samplerYcbcrConversion must be enabled.", apiName); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 6995 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6996 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6997 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6998 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6999 | const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 7000 | const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7001 | #else |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 7002 | const bool is_external_format = false; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7003 | #endif |
| 7004 | |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 7005 | const VkFormat format = pCreateInfo->format; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7006 | |
| 7007 | // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored. |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 7008 | if (!is_external_format) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7009 | const VkComponentMapping components = pCreateInfo->components; |
| 7010 | // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec |
| 7011 | if (FormatIsXChromaSubsampled(format) == true) { |
| 7012 | if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) { |
| 7013 | skip |= |
| 7014 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7015 | "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G " |
| 7016 | "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 7017 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7018 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7019 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7020 | if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 7021 | (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) { |
| 7022 | skip |= LogError( |
| 7023 | device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582", |
| 7024 | "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or " |
| 7025 | "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.", |
| 7026 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a)); |
| 7027 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7028 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7029 | if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 7030 | (components.r != VK_COMPONENT_SWIZZLE_B)) { |
| 7031 | skip |= |
| 7032 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7033 | "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R " |
| 7034 | "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 7035 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7036 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7037 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7038 | if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 7039 | (components.b != VK_COMPONENT_SWIZZLE_R)) { |
| 7040 | skip |= |
| 7041 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7042 | "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B " |
| 7043 | "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 7044 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7045 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7046 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7047 | // If one is identity, both need to be |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 7048 | const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 7049 | const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 7050 | if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7051 | skip |= |
| 7052 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7053 | "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) " |
| 7054 | "are an identity swizzle, then both need to be an identity swizzle.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 7055 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r), |
| 7056 | string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7057 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 7058 | } |
| 7059 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7060 | if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) { |
| 7061 | // Checks same VU multiple ways in order to give a more useful error message |
| 7062 | const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655"; |
| 7063 | if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) || |
| 7064 | (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) || |
| 7065 | (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) { |
| 7066 | skip |= LogError( |
| 7067 | device, vuid, |
| 7068 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 7069 | "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.", |
| 7070 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 7071 | string_VkComponentSwizzle(components.b)); |
| 7072 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 7073 | |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 7074 | // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA" |
| 7075 | // 4 component format = no issue |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7076 | // 3 = no [a] |
| 7077 | // 2 = no [b,a] |
| 7078 | // 1 = no [g,b,a] |
| 7079 | // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it) |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 7080 | const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7081 | |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 7082 | if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) || |
| 7083 | (components.b == VK_COMPONENT_SWIZZLE_A))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7084 | skip |= LogError(device, vuid, |
| 7085 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 7086 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.", |
| 7087 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 7088 | string_VkComponentSwizzle(components.b)); |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 7089 | } else if ((component_count < 3) && |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7090 | ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) || |
| 7091 | (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) { |
| 7092 | skip |= LogError(device, vuid, |
| 7093 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 7094 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B " |
| 7095 | "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 7096 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 7097 | string_VkComponentSwizzle(components.b)); |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 7098 | } else if ((component_count < 2) && |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 7099 | ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) || |
| 7100 | (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) { |
| 7101 | skip |= LogError(device, vuid, |
| 7102 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 7103 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G " |
| 7104 | "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 7105 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 7106 | string_VkComponentSwizzle(components.b)); |
| 7107 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 7108 | } |
| 7109 | } |
| 7110 | |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 7111 | return skip; |
| 7112 | } |
| 7113 | |
| 7114 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 7115 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 7116 | const VkAllocationCallbacks *pAllocator, |
| 7117 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 7118 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 7119 | "vkCreateSamplerYcbcrConversion"); |
| 7120 | } |
| 7121 | |
| 7122 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 7123 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 7124 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 7125 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 7126 | "vkCreateSamplerYcbcrConversionKHR"); |
| 7127 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 7128 | |
Jeremy Gebben | 284b68f | 2022-09-21 15:43:16 -0600 | [diff] [blame] | 7129 | bool StatelessValidation::ValidateExternalSemaphoreHandleType(VkSemaphore semaphore, const char *vuid, const char *caller, |
| 7130 | VkExternalSemaphoreHandleTypeFlagBits handle_type, |
| 7131 | VkExternalSemaphoreHandleTypeFlags allowed_types) const { |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 7132 | bool skip = false; |
Jeremy Gebben | 284b68f | 2022-09-21 15:43:16 -0600 | [diff] [blame] | 7133 | if (0 == (handle_type & allowed_types)) { |
| 7134 | skip |= LogError(semaphore, vuid, "%s(): handleType %s is not one of the supported handleTypes (%s).", caller, |
| 7135 | string_VkExternalSemaphoreHandleTypeFlagBits(handle_type), |
| 7136 | string_VkExternalSemaphoreHandleTypeFlags(allowed_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 7137 | } |
| 7138 | return skip; |
| 7139 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7140 | |
Jeremy Gebben | 284b68f | 2022-09-21 15:43:16 -0600 | [diff] [blame] | 7141 | bool StatelessValidation::ValidateExternalFenceHandleType(VkFence fence, const char *vuid, const char *caller, |
| 7142 | VkExternalFenceHandleTypeFlagBits handle_type, |
| 7143 | VkExternalFenceHandleTypeFlags allowed_types) const { |
| 7144 | bool skip = false; |
| 7145 | if (0 == (handle_type & allowed_types)) { |
| 7146 | skip |= LogError(fence, vuid, "%s(): handleType %s is not one of the supported handleTypes (%s).", caller, |
| 7147 | string_VkExternalFenceHandleTypeFlagBits(handle_type), |
| 7148 | string_VkExternalFenceHandleTypeFlags(allowed_types).c_str()); |
| 7149 | } |
| 7150 | return skip; |
| 7151 | } |
| 7152 | |
| 7153 | static constexpr VkExternalSemaphoreHandleTypeFlags kSemFdHandleTypes = |
| 7154 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 7155 | |
| 7156 | bool StatelessValidation::manual_PreCallValidateGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR *info, |
| 7157 | int *pFd) const { |
| 7158 | return ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkSemaphoreGetFdInfoKHR-handleType-01136", |
| 7159 | "vkGetSemaphoreFdKHR", info->handleType, kSemFdHandleTypes); |
| 7160 | } |
| 7161 | |
| 7162 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(VkDevice device, |
| 7163 | const VkImportSemaphoreFdInfoKHR *info) const { |
| 7164 | bool skip = false; |
| 7165 | const char *func_name = "vkImportSemaphoreFdKHR"; |
| 7166 | |
| 7167 | skip |= ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", func_name, |
| 7168 | info->handleType, kSemFdHandleTypes); |
| 7169 | |
| 7170 | if (info->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT && |
| 7171 | (info->flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT) == 0) { |
| 7172 | skip |= LogError(info->semaphore, "VUID-VkImportSemaphoreFdInfoKHR-handleType-07307", |
| 7173 | "%s(): handleType is VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT so" |
| 7174 | " VK_SEMAPHORE_IMPORT_TEMPORARY_BIT must be set, but flags is 0x%x", |
| 7175 | func_name, info->flags); |
| 7176 | } |
| 7177 | return skip; |
| 7178 | } |
| 7179 | |
| 7180 | static constexpr VkExternalFenceHandleTypeFlags kFenceFdHandleTypes = |
| 7181 | VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT; |
| 7182 | |
| 7183 | bool StatelessValidation::manual_PreCallValidateGetFenceFdKHR(VkDevice device, const VkFenceGetFdInfoKHR *info, int *pFd) const { |
| 7184 | return ValidateExternalFenceHandleType(info->fence, "VUID-VkFenceGetFdInfoKHR-handleType-01456", "vkGetFenceFdKHR", |
| 7185 | info->handleType, kFenceFdHandleTypes); |
| 7186 | } |
| 7187 | |
| 7188 | bool StatelessValidation::manual_PreCallValidateImportFenceFdKHR(VkDevice device, const VkImportFenceFdInfoKHR *info) const { |
| 7189 | bool skip = false; |
| 7190 | const char *func_name = "vkImportFenceFdKHR"; |
| 7191 | |
| 7192 | skip |= ValidateExternalFenceHandleType(info->fence, "VUID-VkImportFenceFdInfoKHR-handleType-01464", func_name, |
| 7193 | info->handleType, kFenceFdHandleTypes); |
| 7194 | |
| 7195 | if (info->handleType == VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT && (info->flags & VK_FENCE_IMPORT_TEMPORARY_BIT) == 0) { |
| 7196 | skip |= LogError(info->fence, "VUID-VkImportFenceFdInfoKHR-handleType-07306", |
| 7197 | "%s(): handleType is VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT so" |
| 7198 | " VK_FENCE_IMPORT_TEMPORARY_BIT must be set, but flags is 0x%x", |
| 7199 | func_name, info->flags); |
| 7200 | } |
| 7201 | return skip; |
| 7202 | } |
| 7203 | |
| 7204 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 7205 | static constexpr VkExternalSemaphoreHandleTypeFlags kSemWin32HandleTypes = |
| 7206 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT | |
| 7207 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT; |
| 7208 | |
| 7209 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreWin32HandleKHR( |
| 7210 | VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR *info) const { |
| 7211 | bool skip = false; |
| 7212 | const char *func_name = "vkImportSemaphoreWin32HandleKHR"; |
| 7213 | |
| 7214 | skip |= ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01140", |
| 7215 | func_name, info->handleType, kSemWin32HandleTypes); |
| 7216 | |
| 7217 | static constexpr auto kNameAllowedTypes = |
| 7218 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT; |
| 7219 | if ((info->handleType & kNameAllowedTypes) == 0 && info->name) { |
| 7220 | skip |= LogError(info->semaphore, "VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01466", |
| 7221 | "%s(): name (%p) must be NULL if handleType is %s", func_name, info->name, |
| 7222 | string_VkExternalSemaphoreHandleTypeFlagBits(info->handleType)); |
| 7223 | } |
| 7224 | if (info->handle && info->name) { |
| 7225 | skip |= LogError(info->semaphore, "VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01469", |
| 7226 | "%s(): both handle (%p) and name (%p) are non-NULL", func_name, info->handle, info->name); |
| 7227 | } |
| 7228 | return skip; |
| 7229 | } |
| 7230 | |
| 7231 | bool StatelessValidation::manual_PreCallValidateGetSemaphoreWin32HandleKHR(VkDevice device, |
| 7232 | const VkSemaphoreGetWin32HandleInfoKHR *info, |
| 7233 | HANDLE *pHandle) const { |
| 7234 | return ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01131", |
| 7235 | "vkGetSemaphoreWin32HandleKHR", info->handleType, kSemWin32HandleTypes); |
| 7236 | } |
| 7237 | |
| 7238 | static constexpr VkExternalFenceHandleTypeFlags kFenceWin32HandleTypes = |
| 7239 | VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT | VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; |
| 7240 | |
| 7241 | bool StatelessValidation::manual_PreCallValidateImportFenceWin32HandleKHR(VkDevice device, |
| 7242 | const VkImportFenceWin32HandleInfoKHR *info) const { |
| 7243 | bool skip = false; |
| 7244 | const char *func_name = "vkImportFenceWin32HandleKHR"; |
| 7245 | |
| 7246 | skip |= ValidateExternalFenceHandleType(info->fence, func_name, "VUID-VkImportFenceWin32HandleInfoKHR-handleType-01457", |
| 7247 | info->handleType, kFenceWin32HandleTypes); |
| 7248 | |
| 7249 | static constexpr auto kNameAllowedTypes = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT; |
| 7250 | if ((info->handleType & kNameAllowedTypes) == 0 && info->name) { |
| 7251 | skip |= LogError(info->fence, "VUID-VkImportFenceWin32HandleInfoKHR-handleType-01459", |
| 7252 | "%s(): name (%p) must be NULL if handleType is %s", func_name, info->name, |
| 7253 | string_VkExternalFenceHandleTypeFlagBits(info->handleType)); |
| 7254 | } |
| 7255 | if (info->handle && info->name) { |
| 7256 | skip |= LogError(info->fence, "VUID-VkImportFenceWin32HandleInfoKHR-handle-01462", |
| 7257 | "%s(): both handle (%p) and name (%p) are non-NULL", func_name, info->handle, info->name); |
| 7258 | } |
| 7259 | return skip; |
| 7260 | } |
| 7261 | |
| 7262 | bool StatelessValidation::manual_PreCallValidateGetFenceWin32HandleKHR(VkDevice device, const VkFenceGetWin32HandleInfoKHR *info, |
| 7263 | HANDLE *pHandle) const { |
| 7264 | return ValidateExternalFenceHandleType(info->fence, "vkGetFenceWin32HandleKHR", |
| 7265 | "VUID-VkFenceGetWin32HandleInfoKHR-handleType-01452", info->handleType, |
| 7266 | kFenceWin32HandleTypes); |
| 7267 | } |
| 7268 | #endif |
| 7269 | |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7270 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7271 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7272 | bool skip = false; |
| 7273 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 7274 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 7275 | "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 7276 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7277 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7278 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 7279 | skip |= LogError( |
| 7280 | device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584", |
| 7281 | "vkCopyAccelerationStructureToMemoryKHR: The " |
| 7282 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 7283 | } |
| 7284 | skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress, |
| 7285 | "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732"); |
| 7286 | if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) { |
| 7287 | skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751", |
| 7288 | "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes."); |
| 7289 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7290 | return skip; |
| 7291 | } |
| 7292 | |
| 7293 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR( |
| 7294 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 7295 | bool skip = false; |
| 7296 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 7297 | skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update |
| 7298 | LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 7299 | "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 7300 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7301 | if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) { |
| 7302 | skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 7303 | "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7304 | pInfo->dst.deviceAddress); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7305 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7306 | return skip; |
| 7307 | } |
| 7308 | |
| 7309 | bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 7310 | const char *api_name) const { |
| 7311 | bool skip = false; |
| 7312 | if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR || |
| 7313 | pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) { |
| 7314 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410", |
| 7315 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR" |
| 7316 | "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.", |
| 7317 | api_name); |
| 7318 | } |
| 7319 | return skip; |
| 7320 | } |
| 7321 | |
| 7322 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7323 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7324 | bool skip = false; |
| 7325 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()"); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7326 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7327 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7328 | skip |= LogError( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7329 | device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582", |
| 7330 | "vkCopyAccelerationStructureKHR: The " |
| 7331 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7332 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7333 | return skip; |
| 7334 | } |
| 7335 | |
| 7336 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR( |
| 7337 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 7338 | bool skip = false; |
| 7339 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()"); |
| 7340 | return skip; |
| 7341 | } |
| 7342 | |
| 7343 | bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 7344 | const char *api_name, bool is_cmd) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7345 | bool skip = false; |
| 7346 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7347 | skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413", |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7348 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name); |
| 7349 | } |
| 7350 | return skip; |
| 7351 | } |
| 7352 | |
| 7353 | bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7354 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7355 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7356 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7357 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7358 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 7359 | skip |= LogError( |
| 7360 | device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583", |
| 7361 | "vkCopyMemoryToAccelerationStructureKHR: The " |
| 7362 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7363 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7364 | skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress, |
| 7365 | "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7366 | return skip; |
| 7367 | } |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 7368 | |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 7369 | bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR( |
| 7370 | VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 7371 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7372 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7373 | if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) { |
| 7374 | skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 7375 | "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7376 | pInfo->src.deviceAddress); |
| 7377 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7378 | return skip; |
| 7379 | } |
| 7380 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR( |
| 7381 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 7382 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 7383 | bool skip = false; |
| 7384 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 7385 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7386 | if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) { |
| 7387 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 7388 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be " |
| 7389 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 7390 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType)); |
| 7391 | } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR || |
| 7392 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) { |
| 7393 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742", |
| 7394 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be " |
| 7395 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or " |
| 7396 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or " |
| 7397 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 7398 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType)); |
| 7399 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7400 | } |
| 7401 | return skip; |
| 7402 | } |
| 7403 | bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR( |
| 7404 | VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 7405 | VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const { |
| 7406 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7407 | const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7408 | if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 7409 | skip |= LogError( |
| 7410 | device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585", |
| 7411 | "vkCmdWriteAccelerationStructuresPropertiesKHR: The " |
| 7412 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 7413 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7414 | if (dataSize < accelerationStructureCount * stride) { |
| 7415 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452", |
| 7416 | "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 7417 | "accelerationStructureCount (%" PRIu32 ") *stride(%zu).", |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7418 | dataSize, accelerationStructureCount, stride); |
| 7419 | } |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7420 | |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7421 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 7422 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7423 | if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) { |
| 7424 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 7425 | "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be " |
| 7426 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 7427 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType)); |
| 7428 | } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR || |
| 7429 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) { |
| 7430 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742", |
| 7431 | "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be " |
| 7432 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or " |
| 7433 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or " |
| 7434 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 7435 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType)); |
| 7436 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7437 | } |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7438 | |
| 7439 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 7440 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7441 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448", |
| 7442 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 7443 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR," |
| 7444 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 7445 | stride); |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7446 | } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7447 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450", |
| 7448 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 7449 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR," |
| 7450 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 7451 | stride); |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7452 | } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) { |
| 7453 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731", |
| 7454 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 7455 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR," |
| 7456 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 7457 | stride); |
| 7458 | } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) { |
| 7459 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733", |
| 7460 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 7461 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR," |
| 7462 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 7463 | stride); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7464 | } |
| 7465 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7466 | return skip; |
| 7467 | } |
| 7468 | bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR( |
| 7469 | VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const { |
| 7470 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7471 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7472 | if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) { |
| 7473 | skip |= LogError( |
| 7474 | device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606", |
| 7475 | "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::" |
| 7476 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7477 | } |
| 7478 | return skip; |
| 7479 | } |
| 7480 | |
| 7481 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7482 | const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 7483 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, |
| 7484 | const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 7485 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7486 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 7487 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7488 | // RayGen |
| 7489 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 7490 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023", |
| 7491 | "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7492 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7493 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7494 | 0) { |
| 7495 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682", |
| 7496 | "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 7497 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7498 | } |
| 7499 | // Callable |
| 7500 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7501 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694", |
| 7502 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 7503 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7504 | } |
| 7505 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7506 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041", |
| 7507 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7508 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7509 | } |
| 7510 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7511 | 0) { |
| 7512 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693", |
| 7513 | "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 7514 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7515 | } |
| 7516 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7517 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7518 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690", |
| 7519 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 7520 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7521 | } |
| 7522 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7523 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7524 | "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to " |
| 7525 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7526 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7527 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7528 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689", |
| 7529 | "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 7530 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7531 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7532 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7533 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7534 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686", |
| 7535 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of " |
| 7536 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7537 | } |
| 7538 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7539 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029", |
| 7540 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7541 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7542 | } |
| 7543 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7544 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685", |
| 7545 | "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 7546 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7547 | } |
| 7548 | if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) { |
Mike Schuchardt | 840f125 | 2022-05-11 11:31:25 -0700 | [diff] [blame] | 7549 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7550 | "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to " |
| 7551 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount"); |
| 7552 | } |
| 7553 | if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) { |
| 7554 | skip |= |
Mike Schuchardt | 840f125 | 2022-05-11 11:31:25 -0700 | [diff] [blame] | 7555 | LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7556 | "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] " |
| 7557 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7558 | } |
| 7559 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7560 | if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) { |
| 7561 | skip |= |
Mike Schuchardt | 840f125 | 2022-05-11 11:31:25 -0700 | [diff] [blame] | 7562 | LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7563 | "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] " |
| 7564 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]"); |
| 7565 | } |
| 7566 | |
| 7567 | if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) { |
| 7568 | skip |= |
Mike Schuchardt | 840f125 | 2022-05-11 11:31:25 -0700 | [diff] [blame] | 7569 | LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7570 | "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] " |
| 7571 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7572 | } |
| 7573 | return skip; |
| 7574 | } |
| 7575 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7576 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR( |
| 7577 | VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 7578 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 7579 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7580 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7581 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7582 | if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) { |
| 7583 | skip |= LogError( |
| 7584 | device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637", |
| 7585 | "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect " |
| 7586 | "feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7587 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7588 | // RayGen |
| 7589 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 7590 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023", |
| 7591 | "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7592 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7593 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7594 | 0) { |
| 7595 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682", |
| 7596 | "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 7597 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7598 | } |
| 7599 | // Callabe |
| 7600 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7601 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694", |
| 7602 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 7603 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7604 | } |
| 7605 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7606 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7607 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal " |
| 7608 | "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7609 | } |
| 7610 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7611 | 0) { |
| 7612 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693", |
| 7613 | "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 7614 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7615 | } |
| 7616 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7617 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7618 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690", |
| 7619 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 7620 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7621 | } |
| 7622 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7623 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7624 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to " |
| 7625 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7626 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7627 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7628 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689", |
| 7629 | "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 7630 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7631 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7632 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7633 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7634 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686", |
| 7635 | "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of " |
| 7636 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7637 | } |
| 7638 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7639 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7640 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to " |
| 7641 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7642 | } |
| 7643 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7644 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685", |
| 7645 | "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 7646 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7647 | } |
| 7648 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7649 | if (SafeModulo(indirectDeviceAddress, 4) != 0) { |
| 7650 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634", |
| 7651 | "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7652 | } |
| 7653 | return skip; |
| 7654 | } |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7655 | |
| 7656 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer, |
| 7657 | VkDeviceAddress indirectDeviceAddress) const { |
| 7658 | bool skip = false; |
| 7659 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 7660 | if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) { |
| 7661 | skip |= LogError( |
Mike Schuchardt | ac73fbe | 2022-05-24 10:37:52 -0700 | [diff] [blame] | 7662 | device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637", |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 7663 | "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect " |
| 7664 | "feature must be enabled."); |
| 7665 | } |
| 7666 | |
| 7667 | if (SafeModulo(indirectDeviceAddress, 4) != 0) { |
| 7668 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634", |
| 7669 | "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4."); |
| 7670 | } |
| 7671 | return skip; |
| 7672 | } |
| 7673 | |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7674 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV( |
| 7675 | VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, |
| 7676 | VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 7677 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, |
| 7678 | VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 7679 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 7680 | bool skip = false; |
| 7681 | if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7682 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462", |
| 7683 | "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of " |
| 7684 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7685 | } |
| 7686 | if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 7687 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465", |
| 7688 | "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of " |
| 7689 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 7690 | } |
| 7691 | if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 7692 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468", |
| 7693 | "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to " |
| 7694 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. "); |
| 7695 | } |
| 7696 | |
| 7697 | // hitShader |
| 7698 | if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7699 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460", |
| 7700 | "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of " |
| 7701 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7702 | } |
| 7703 | if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 7704 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464", |
| 7705 | "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of " |
| 7706 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 7707 | } |
| 7708 | if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 7709 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467", |
| 7710 | "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to " |
| 7711 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 7712 | } |
| 7713 | |
| 7714 | // missShader |
| 7715 | if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7716 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458", |
| 7717 | "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of " |
| 7718 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7719 | } |
| 7720 | if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 7721 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463", |
| 7722 | "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of " |
| 7723 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 7724 | } |
| 7725 | if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 7726 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466", |
| 7727 | "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to " |
| 7728 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 7729 | } |
| 7730 | |
| 7731 | // raygenShader |
| 7732 | if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7733 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456", |
| 7734 | "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of " |
sourav parmar | d152180 | 2020-06-07 21:49:02 -0700 | [diff] [blame] | 7735 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7736 | } |
| 7737 | if (width > device_limits.maxComputeWorkGroupCount[0]) { |
| 7738 | skip |= |
| 7739 | LogError(device, "VUID-vkCmdTraceRaysNV-width-02469", |
| 7740 | "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o]."); |
| 7741 | } |
| 7742 | if (height > device_limits.maxComputeWorkGroupCount[1]) { |
| 7743 | skip |= |
| 7744 | LogError(device, "VUID-vkCmdTraceRaysNV-height-02470", |
| 7745 | "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1]."); |
| 7746 | } |
| 7747 | if (depth > device_limits.maxComputeWorkGroupCount[2]) { |
| 7748 | skip |= |
| 7749 | LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471", |
| 7750 | "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2]."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7751 | } |
| 7752 | return skip; |
| 7753 | } |
| 7754 | |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7755 | bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7756 | VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo, |
| 7757 | VkAccelerationStructureCompatibilityKHR *pCompatibility) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7758 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7759 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
| 7760 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 7761 | if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) || |
| 7762 | (raytracing_features && !raytracing_features->rayTracingPipeline))) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7763 | skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661", |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7764 | "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled."); |
| 7765 | } |
| 7766 | return skip; |
| 7767 | } |
| 7768 | |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7769 | bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 7770 | const VkViewport *pViewports, bool is_ext) const { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7771 | bool skip = false; |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7772 | const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount"; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7773 | |
| 7774 | if (!physical_device_features.multiViewport) { |
| 7775 | if (viewportCount != 1) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7776 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395", |
| 7777 | "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call, |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7778 | viewportCount); |
| 7779 | } |
| 7780 | } else { // multiViewport enabled |
| 7781 | if (viewportCount < 1 || viewportCount > device_limits.maxViewports) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7782 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394", |
| 7783 | "%s: viewportCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7784 | ") must " |
| 7785 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7786 | api_call, viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7787 | } |
| 7788 | } |
| 7789 | |
| 7790 | if (pViewports) { |
| 7791 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 7792 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7793 | skip |= manual_PreCallValidateViewport( |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7794 | viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7795 | } |
| 7796 | } |
| 7797 | |
| 7798 | return skip; |
| 7799 | } |
| 7800 | |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7801 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 7802 | const VkViewport *pViewports) const { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7803 | bool skip = false; |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7804 | skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true); |
| 7805 | return skip; |
| 7806 | } |
| 7807 | |
| 7808 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 7809 | const VkViewport *pViewports) const { |
| 7810 | bool skip = false; |
| 7811 | skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false); |
| 7812 | return skip; |
| 7813 | } |
| 7814 | |
| 7815 | bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 7816 | const VkRect2D *pScissors, bool is_ext) const { |
| 7817 | bool skip = false; |
| 7818 | const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount"; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7819 | |
| 7820 | if (!physical_device_features.multiViewport) { |
| 7821 | if (scissorCount != 1) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7822 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398", |
| 7823 | "%s: scissorCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7824 | ") must " |
| 7825 | "be 1 when the multiViewport feature is disabled.", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7826 | api_call, scissorCount); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7827 | } |
| 7828 | } else { // multiViewport enabled |
| 7829 | if (scissorCount == 0) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7830 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397", |
| 7831 | "%s: scissorCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7832 | ") must " |
| 7833 | "be great than zero.", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7834 | api_call, scissorCount); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7835 | } else if (scissorCount > device_limits.maxViewports) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7836 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397", |
| 7837 | "%s: scissorCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7838 | ") must " |
| 7839 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7840 | api_call, scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7841 | } |
| 7842 | } |
| 7843 | |
| 7844 | if (pScissors) { |
| 7845 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 7846 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
| 7847 | |
| 7848 | if (scissor.offset.x < 0) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7849 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call, |
| 7850 | scissor_i, scissor.offset.x); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7851 | } |
| 7852 | |
| 7853 | if (scissor.offset.y < 0) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7854 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call, |
| 7855 | scissor_i, scissor.offset.y); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7856 | } |
| 7857 | |
| 7858 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 7859 | if (x_sum > INT32_MAX) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7860 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400", |
| 7861 | "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32 |
| 7862 | "] will overflow int32_t.", |
| 7863 | api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7864 | } |
| 7865 | |
| 7866 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 7867 | if (y_sum > INT32_MAX) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7868 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401", |
| 7869 | "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32 |
| 7870 | "] will overflow int32_t.", |
| 7871 | api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
| 7872 | } |
| 7873 | } |
| 7874 | } |
| 7875 | |
| 7876 | return skip; |
| 7877 | } |
| 7878 | |
| 7879 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 7880 | const VkRect2D *pScissors) const { |
| 7881 | bool skip = false; |
| 7882 | skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true); |
| 7883 | return skip; |
| 7884 | } |
| 7885 | |
| 7886 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 7887 | const VkRect2D *pScissors) const { |
| 7888 | bool skip = false; |
| 7889 | skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false); |
| 7890 | return skip; |
| 7891 | } |
| 7892 | |
| 7893 | bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, |
| 7894 | const VkBuffer *pBuffers, const VkDeviceSize *pOffsets, |
| 7895 | const VkDeviceSize *pSizes, const VkDeviceSize *pStrides, |
| 7896 | bool is_2ext) const { |
| 7897 | bool skip = false; |
| 7898 | const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()"; |
arno-lunarg | a759e4b | 2022-09-05 15:40:30 +0200 | [diff] [blame] | 7899 | |
| 7900 | // Check VUID-vkCmdBindVertexBuffers2-bindingCount-arraylength |
| 7901 | { |
| 7902 | const bool vuidCondition = (pSizes != nullptr) || (pStrides != nullptr); |
| 7903 | const bool vuidExpectation = bindingCount > 0; |
| 7904 | if (vuidCondition) { |
| 7905 | if (!vuidExpectation) { |
| 7906 | const char *not_null_msg = ""; |
| 7907 | if ((pSizes != nullptr) && (pStrides != nullptr)) |
| 7908 | not_null_msg = "pSizes and pStrides are not NULL"; |
| 7909 | else if (pSizes != nullptr) |
| 7910 | not_null_msg = "pSizes is not NULL"; |
| 7911 | else |
| 7912 | not_null_msg = "pStrides is not NULL"; |
| 7913 | const char *vuid_breach_msg = "%s: %s, so bindingCount must be greater that 0."; |
| 7914 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-bindingCount-arraylength", vuid_breach_msg, api_call, |
| 7915 | not_null_msg); |
| 7916 | } |
| 7917 | } |
| 7918 | } |
| 7919 | |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7920 | if (firstBinding >= device_limits.maxVertexInputBindings) { |
| 7921 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355", |
| 7922 | "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call, |
| 7923 | firstBinding, device_limits.maxVertexInputBindings); |
| 7924 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 7925 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356", |
| 7926 | "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32 |
| 7927 | ") must be less than " |
| 7928 | "maxVertexInputBindings (%" PRIu32 ")", |
| 7929 | api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 7930 | } |
| 7931 | |
| 7932 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 7933 | if (pBuffers[i] == VK_NULL_HANDLE) { |
| 7934 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 7935 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 7936 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111", |
| 7937 | "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i); |
| 7938 | } else { |
| 7939 | if (pOffsets[i] != 0) { |
| 7940 | skip |= |
| 7941 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112", |
| 7942 | "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i); |
| 7943 | } |
| 7944 | } |
| 7945 | } |
| 7946 | if (pStrides) { |
| 7947 | if (pStrides[i] > device_limits.maxVertexInputBindingStride) { |
| 7948 | skip |= |
| 7949 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362", |
| 7950 | "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")", |
| 7951 | api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7952 | } |
| 7953 | } |
| 7954 | } |
| 7955 | |
| 7956 | return skip; |
| 7957 | } |
| 7958 | |
| 7959 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 7960 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 7961 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 7962 | const VkDeviceSize *pStrides) const { |
| 7963 | bool skip = false; |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7964 | skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true); |
| 7965 | return skip; |
| 7966 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7967 | |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7968 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 7969 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 7970 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 7971 | const VkDeviceSize *pStrides) const { |
| 7972 | bool skip = false; |
| 7973 | skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7974 | return skip; |
| 7975 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7976 | |
| 7977 | bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR( |
| 7978 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const { |
| 7979 | bool skip = false; |
| 7980 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 7981 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 7982 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654", |
| 7983 | "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name); |
| 7984 | } |
| 7985 | if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR && |
| 7986 | pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) { |
| 7987 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796", |
| 7988 | "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set," |
| 7989 | "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.", |
| 7990 | api_name); |
| 7991 | } |
| 7992 | if (pInfos[i].pGeometries && pInfos[i].ppGeometries) { |
| 7993 | skip |= |
| 7994 | LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788", |
| 7995 | "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name); |
| 7996 | } |
| 7997 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) { |
| 7998 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790", |
| 7999 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name); |
| 8000 | } |
| 8001 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && |
| 8002 | pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) { |
| 8003 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793", |
| 8004 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be" |
| 8005 | " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount", |
| 8006 | api_name); |
| 8007 | } |
| 8008 | if (pInfos[i].pGeometries) { |
| 8009 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 8010 | skip |= validate_ranged_enum( |
| 8011 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}), |
| 8012 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType, |
| 8013 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 8014 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8015 | skip |= validate_struct_type( |
| 8016 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}), |
| 8017 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 8018 | &(pInfos[i].pGeometries[j].geometry.triangles), |
| 8019 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 8020 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 8021 | skip |= validate_struct_pnext( |
| 8022 | api_name, |
| 8023 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 8024 | NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 8025 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 8026 | skip |= |
| 8027 | validate_ranged_enum(api_name, |
| 8028 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat", |
| 8029 | ParameterName::IndexVector{i, j}), |
| 8030 | "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat, |
| 8031 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 8032 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 8033 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 8034 | &pInfos[i].pGeometries[j].geometry.triangles, |
| 8035 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 8036 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 8037 | skip |= validate_ranged_enum( |
| 8038 | api_name, |
| 8039 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}), |
| 8040 | "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType, |
| 8041 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 8042 | |
| 8043 | if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) { |
| 8044 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 8045 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 8046 | } |
| 8047 | if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 8048 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 8049 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 8050 | skip |= |
| 8051 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 8052 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 8053 | api_name); |
| 8054 | } |
| 8055 | } |
| 8056 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8057 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 8058 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 8059 | &pInfos[i].pGeometries[j].geometry.instances, |
| 8060 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 8061 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 8062 | skip |= validate_struct_type( |
| 8063 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}), |
| 8064 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 8065 | &(pInfos[i].pGeometries[j].geometry.instances), |
| 8066 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 8067 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 8068 | skip |= validate_struct_pnext( |
| 8069 | api_name, |
| 8070 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 8071 | NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 8072 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 8073 | |
| 8074 | skip |= validate_bool32(api_name, |
| 8075 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers", |
| 8076 | ParameterName::IndexVector{i, j}), |
| 8077 | pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers); |
| 8078 | } |
| 8079 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 8080 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 8081 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 8082 | &pInfos[i].pGeometries[j].geometry.aabbs, |
| 8083 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 8084 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 8085 | skip |= validate_struct_type( |
| 8086 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 8087 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 8088 | &(pInfos[i].pGeometries[j].geometry.aabbs), |
| 8089 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 8090 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 8091 | skip |= validate_struct_pnext( |
| 8092 | api_name, |
| 8093 | ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 8094 | pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 8095 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 8096 | if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) { |
| 8097 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 8098 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 8099 | } |
| 8100 | } |
| 8101 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 8102 | pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8103 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 8104 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 8105 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 8106 | api_name); |
| 8107 | } |
| 8108 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 8109 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8110 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 8111 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 8112 | "of elements of" |
| 8113 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 8114 | api_name); |
| 8115 | } |
| 8116 | if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) { |
| 8117 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 8118 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 8119 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 8120 | api_name); |
| 8121 | } |
| 8122 | } |
| 8123 | } |
| 8124 | } |
| 8125 | if (pInfos[i].ppGeometries != NULL) { |
| 8126 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 8127 | skip |= validate_ranged_enum( |
| 8128 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}), |
| 8129 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType, |
| 8130 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 8131 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8132 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 8133 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 8134 | &pInfos[i].ppGeometries[j]->geometry.triangles, |
| 8135 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 8136 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 8137 | skip |= validate_struct_type( |
| 8138 | api_name, |
| 8139 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}), |
| 8140 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 8141 | &(pInfos[i].ppGeometries[j]->geometry.triangles), |
| 8142 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 8143 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 8144 | skip |= validate_struct_pnext( |
| 8145 | api_name, |
| 8146 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 8147 | NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 8148 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 8149 | skip |= validate_ranged_enum(api_name, |
| 8150 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat", |
| 8151 | ParameterName::IndexVector{i, j}), |
| 8152 | "VkFormat", AllVkFormatEnums, |
| 8153 | pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat, |
| 8154 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 8155 | skip |= validate_ranged_enum(api_name, |
| 8156 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType", |
| 8157 | ParameterName::IndexVector{i, j}), |
| 8158 | "VkIndexType", AllVkIndexTypeEnums, |
| 8159 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType, |
| 8160 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 8161 | if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) { |
| 8162 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 8163 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 8164 | } |
| 8165 | if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 8166 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 8167 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 8168 | skip |= |
| 8169 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 8170 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 8171 | api_name); |
| 8172 | } |
| 8173 | } |
| 8174 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8175 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 8176 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 8177 | &pInfos[i].ppGeometries[j]->geometry.instances, |
| 8178 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 8179 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 8180 | skip |= validate_struct_type( |
| 8181 | api_name, |
| 8182 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}), |
| 8183 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 8184 | &(pInfos[i].ppGeometries[j]->geometry.instances), |
| 8185 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 8186 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 8187 | skip |= validate_struct_pnext( |
| 8188 | api_name, |
| 8189 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 8190 | NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 8191 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 8192 | skip |= validate_bool32(api_name, |
| 8193 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers", |
| 8194 | ParameterName::IndexVector{i, j}), |
| 8195 | pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers); |
| 8196 | } |
| 8197 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 8198 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 8199 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 8200 | &pInfos[i].ppGeometries[j]->geometry.aabbs, |
| 8201 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 8202 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 8203 | skip |= validate_struct_type( |
| 8204 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 8205 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 8206 | &(pInfos[i].ppGeometries[j]->geometry.aabbs), |
| 8207 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 8208 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 8209 | skip |= validate_struct_pnext( |
| 8210 | api_name, |
| 8211 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 8212 | pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 8213 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 8214 | if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) { |
| 8215 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 8216 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 8217 | } |
| 8218 | } |
| 8219 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 8220 | pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8221 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 8222 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 8223 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 8224 | api_name); |
| 8225 | } |
| 8226 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 8227 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8228 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 8229 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 8230 | "of elements of" |
| 8231 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 8232 | api_name); |
| 8233 | } |
| 8234 | if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) { |
| 8235 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 8236 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 8237 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 8238 | api_name); |
| 8239 | } |
| 8240 | } |
| 8241 | } |
| 8242 | } |
| 8243 | } |
| 8244 | return skip; |
| 8245 | } |
| 8246 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR( |
| 8247 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 8248 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 8249 | bool skip = false; |
| 8250 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR"); |
| 8251 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 8252 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 8253 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 8254 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710", |
| 8255 | "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its " |
| 8256 | "scratchData.deviceAddress member must be a multiple of " |
| 8257 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 8258 | } |
| 8259 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 8260 | if (i == k) continue; |
| 8261 | bool found = false; |
| 8262 | if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8263 | skip |= |
| 8264 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 8265 | "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32 |
| 8266 | ") of pInfos must " |
| 8267 | "not be " |
| 8268 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 8269 | ") of pInfos.", |
| 8270 | i, k); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8271 | found = true; |
| 8272 | } |
| 8273 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8274 | skip |= |
| 8275 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403", |
| 8276 | "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32 |
| 8277 | ") of pInfos must " |
| 8278 | "not be " |
| 8279 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 8280 | ") of pInfos.", |
| 8281 | i, k); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8282 | found = true; |
| 8283 | } |
| 8284 | if (found) break; |
| 8285 | } |
| 8286 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 8287 | if (pInfos[i].pGeometries) { |
| 8288 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8289 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 8290 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 8291 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 8292 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 8293 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 8294 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8295 | } |
| 8296 | } else { |
| 8297 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 8298 | skip |= |
| 8299 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 8300 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 8301 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 8302 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 8303 | } |
| 8304 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 8305 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8306 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 8307 | skip |= LogError( |
| 8308 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 8309 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 8310 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8311 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 8312 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 8313 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8314 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 8315 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 8316 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 8317 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 8318 | } |
| 8319 | } |
| 8320 | } else if (pInfos[i].ppGeometries) { |
| 8321 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8322 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 8323 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 8324 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 8325 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 8326 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 8327 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8328 | } |
| 8329 | } else { |
| 8330 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 8331 | skip |= |
| 8332 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 8333 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 8334 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 8335 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 8336 | } |
| 8337 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 8338 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8339 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 8340 | skip |= LogError( |
| 8341 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 8342 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 8343 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8344 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 8345 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 8346 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8347 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 8348 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 8349 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 8350 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 8351 | } |
| 8352 | } |
| 8353 | } |
| 8354 | } |
| 8355 | } |
| 8356 | return skip; |
| 8357 | } |
| 8358 | |
| 8359 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR( |
| 8360 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 8361 | const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides, |
| 8362 | const uint32_t *const *ppMaxPrimitiveCounts) const { |
| 8363 | bool skip = false; |
| 8364 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR"); |
| 8365 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 8366 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8367 | if (!ray_tracing_acceleration_structure_features || |
| 8368 | ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) { |
| 8369 | skip |= LogError( |
| 8370 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650", |
| 8371 | "vkCmdBuildAccelerationStructuresIndirectKHR: The " |
| 8372 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled."); |
| 8373 | } |
| 8374 | for (uint32_t i = 0; i < infoCount; ++i) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8375 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 8376 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 8377 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710", |
| 8378 | "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its " |
| 8379 | "scratchData.deviceAddress member must be a multiple of " |
| 8380 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 8381 | } |
| 8382 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 8383 | if (i == k) continue; |
| 8384 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8385 | skip |= LogError( |
| 8386 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403", |
| 8387 | "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32 |
| 8388 | ") " |
| 8389 | "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of " |
| 8390 | "any other element [%" PRIu32 ") of pInfos.", |
| 8391 | i, k); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8392 | break; |
| 8393 | } |
| 8394 | } |
| 8395 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 8396 | if (pInfos[i].pGeometries) { |
| 8397 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8398 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 8399 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 8400 | skip |= LogError( |
| 8401 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 8402 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 8403 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 8404 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8405 | } |
| 8406 | } else { |
| 8407 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 8408 | skip |= LogError( |
| 8409 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 8410 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 8411 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 8412 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 8413 | } |
| 8414 | } |
| 8415 | } |
| 8416 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 8417 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 8418 | skip |= LogError( |
| 8419 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 8420 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 8421 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8422 | } |
| 8423 | } |
| 8424 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 8425 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 8426 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 8427 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 8428 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 8429 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 8430 | } |
| 8431 | } |
| 8432 | } else if (pInfos[i].ppGeometries) { |
| 8433 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 8434 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 8435 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 8436 | skip |= LogError( |
| 8437 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 8438 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 8439 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 8440 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8441 | } |
| 8442 | } else { |
| 8443 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 8444 | skip |= LogError( |
| 8445 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 8446 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 8447 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 8448 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 8449 | } |
| 8450 | } |
| 8451 | } |
| 8452 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 8453 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 8454 | skip |= LogError( |
| 8455 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 8456 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 8457 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 8458 | } |
| 8459 | } |
| 8460 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 8461 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 8462 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 8463 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 8464 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 8465 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 8466 | } |
| 8467 | } |
| 8468 | } |
| 8469 | } |
| 8470 | } |
| 8471 | return skip; |
| 8472 | } |
| 8473 | |
| 8474 | bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR( |
| 8475 | VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, |
| 8476 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 8477 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 8478 | bool skip = false; |
| 8479 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR"); |
| 8480 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 8481 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8482 | if (!ray_tracing_acceleration_structure_features || |
| 8483 | ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 8484 | skip |= |
| 8485 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581", |
| 8486 | "vkBuildAccelerationStructuresKHR: The " |
| 8487 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled"); |
| 8488 | } |
| 8489 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 8490 | for (uint32_t j = 0; j < infoCount; ++j) { |
| 8491 | if (i == j) continue; |
| 8492 | bool found = false; |
| 8493 | if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8494 | skip |= |
| 8495 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 8496 | "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32 |
| 8497 | ") of pInfos must " |
| 8498 | "not be " |
| 8499 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 8500 | ") of pInfos.", |
| 8501 | i, j); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8502 | found = true; |
| 8503 | } |
| 8504 | if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8505 | skip |= |
| 8506 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403", |
| 8507 | "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32 |
| 8508 | ") of pInfos must " |
| 8509 | "not be " |
| 8510 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 8511 | ") of pInfos.", |
| 8512 | i, j); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8513 | found = true; |
| 8514 | } |
| 8515 | if (found) break; |
| 8516 | } |
| 8517 | } |
| 8518 | return skip; |
| 8519 | } |
| 8520 | |
| 8521 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR( |
| 8522 | VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo, |
| 8523 | const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const { |
| 8524 | bool skip = false; |
| 8525 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR"); |
| 8526 | const auto *ray_tracing_pipeline_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 8527 | LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 8528 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
ziga-lunarg | bcfba98 | 2022-03-19 17:49:55 +0100 | [diff] [blame] | 8529 | if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) || |
| 8530 | (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8531 | skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617", |
Lars-Ivar Hesselberg Simonsen | dcd1e40 | 2021-11-23 17:14:03 +0100 | [diff] [blame] | 8532 | "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled"); |
| 8533 | } |
| 8534 | if (pBuildInfo != nullptr) { |
| 8535 | if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) { |
| 8536 | skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619", |
| 8537 | "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts " |
| 8538 | "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values"); |
| 8539 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8540 | } |
| 8541 | return skip; |
| 8542 | } |
sfricke-samsung | ecafb19 | 2021-01-17 08:21:14 -0800 | [diff] [blame] | 8543 | |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8544 | bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT( |
| 8545 | VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount, |
| 8546 | const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount, |
| 8547 | const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const { |
| 8548 | bool skip = false; |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8549 | const auto *vertex_attribute_divisor_features = |
| 8550 | LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext); |
| 8551 | |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8552 | // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791 |
| 8553 | if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
| 8554 | skip |= |
| 8555 | LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791", |
| 8556 | "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit"); |
| 8557 | } |
| 8558 | |
| 8559 | // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792 |
| 8560 | if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
| 8561 | skip |= LogError( |
| 8562 | device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792", |
| 8563 | "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit"); |
| 8564 | } |
| 8565 | |
| 8566 | // VUID-vkCmdSetVertexInputEXT-binding-04793 |
| 8567 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) { |
| 8568 | bool binding_found = false; |
| 8569 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) { |
| 8570 | if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) { |
| 8571 | binding_found = true; |
| 8572 | break; |
| 8573 | } |
| 8574 | } |
| 8575 | if (!binding_found) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8576 | skip |= LogError( |
| 8577 | device, "VUID-vkCmdSetVertexInputEXT-binding-04793", |
| 8578 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8579 | } |
| 8580 | } |
| 8581 | |
| 8582 | // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794 |
| 8583 | if (vertexBindingDescriptionCount > 1) { |
| 8584 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) { |
| 8585 | uint32_t binding_value = pVertexBindingDescriptions[binding].binding; |
| 8586 | for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) { |
| 8587 | if (binding_value == pVertexBindingDescriptions[next_binding].binding) { |
| 8588 | skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8589 | "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified", |
| 8590 | binding_value); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8591 | } |
| 8592 | } |
| 8593 | } |
| 8594 | } |
| 8595 | |
| 8596 | // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795 |
| 8597 | if (vertexAttributeDescriptionCount > 1) { |
| 8598 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) { |
| 8599 | uint32_t location = pVertexAttributeDescriptions[attribute].location; |
| 8600 | for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) { |
| 8601 | if (location == pVertexAttributeDescriptions[next_attribute].location) { |
| 8602 | skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8603 | "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified", |
| 8604 | location); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8605 | } |
| 8606 | } |
| 8607 | } |
| 8608 | } |
| 8609 | |
| 8610 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) { |
| 8611 | // VUID-VkVertexInputBindingDescription2EXT-binding-04796 |
| 8612 | if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8613 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796", |
| 8614 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8615 | "].binding is greater than maxVertexInputBindings", |
| 8616 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8617 | } |
| 8618 | |
| 8619 | // VUID-VkVertexInputBindingDescription2EXT-stride-04797 |
| 8620 | if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8621 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797", |
| 8622 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8623 | "].stride is greater than maxVertexInputBindingStride", |
| 8624 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8625 | } |
| 8626 | |
| 8627 | // VUID-VkVertexInputBindingDescription2EXT-divisor-04798 |
| 8628 | if (pVertexBindingDescriptions[binding].divisor == 0 && |
| 8629 | (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) { |
| 8630 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8631 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8632 | "].divisor is zero but " |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8633 | "vertexAttributeInstanceRateZeroDivisor is not enabled", |
| 8634 | binding); |
| 8635 | } |
| 8636 | |
| 8637 | if (pVertexBindingDescriptions[binding].divisor > 1) { |
| 8638 | // VUID-VkVertexInputBindingDescription2EXT-divisor-04799 |
| 8639 | if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) { |
| 8640 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8641 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8642 | "].divisor is greater than one but " |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8643 | "vertexAttributeInstanceRateDivisor is not enabled", |
| 8644 | binding); |
| 8645 | } else { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8646 | // VUID-VkVertexInputBindingDescription2EXT-divisor-06226 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8647 | if (pVertexBindingDescriptions[binding].divisor > |
| 8648 | phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8649 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226", |
| 8650 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8651 | "].divisor is greater than maxVertexAttribDivisor", |
| 8652 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8653 | } |
| 8654 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8655 | // VUID-VkVertexInputBindingDescription2EXT-divisor-06227 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8656 | if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8657 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227", |
| 8658 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8659 | "].divisor is greater than 1 but inputRate " |
| 8660 | "is not VK_VERTEX_INPUT_RATE_INSTANCE", |
| 8661 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8662 | } |
| 8663 | } |
| 8664 | } |
| 8665 | } |
| 8666 | |
| 8667 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8668 | // VUID-VkVertexInputAttributeDescription2EXT-location-06228 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8669 | if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8670 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228", |
| 8671 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8672 | "].location is greater than maxVertexInputAttributes", |
| 8673 | attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8674 | } |
| 8675 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8676 | // VUID-VkVertexInputAttributeDescription2EXT-binding-06229 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8677 | if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8678 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229", |
| 8679 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8680 | "].binding is greater than maxVertexInputBindings", |
| 8681 | attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8682 | } |
| 8683 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8684 | // VUID-VkVertexInputAttributeDescription2EXT-offset-06230 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8685 | if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8686 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230", |
| 8687 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8688 | "].offset is greater than maxVertexInputAttributeOffset", |
| 8689 | attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8690 | } |
| 8691 | |
| 8692 | // VUID-VkVertexInputAttributeDescription2EXT-format-04805 |
| 8693 | VkFormatProperties properties; |
| 8694 | DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties); |
| 8695 | if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) { |
| 8696 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8697 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8698 | "].format is not a " |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8699 | "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format", |
| 8700 | attribute); |
| 8701 | } |
| 8702 | } |
| 8703 | |
| 8704 | return skip; |
| 8705 | } |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8706 | |
| 8707 | bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, |
| 8708 | VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, |
| 8709 | const void *pValues) const { |
| 8710 | bool skip = false; |
| 8711 | const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize; |
| 8712 | // Check that offset + size don't exceed the max. |
| 8713 | // Prevent arithetic overflow here by avoiding addition and testing in this order. |
| 8714 | if (offset >= max_push_constants_size) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8715 | skip |= |
| 8716 | LogError(device, "VUID-vkCmdPushConstants-offset-00370", |
| 8717 | "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".", |
| 8718 | offset, max_push_constants_size); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8719 | } |
| 8720 | if (size > max_push_constants_size - offset) { |
| 8721 | skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8722 | "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32 |
| 8723 | ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8724 | offset, size, max_push_constants_size); |
| 8725 | } |
| 8726 | |
| 8727 | // size needs to be non-zero and a multiple of 4. |
| 8728 | if (size & 0x3) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8729 | skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", |
| 8730 | "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8731 | } |
| 8732 | |
| 8733 | // offset needs to be a multiple of 4. |
| 8734 | if ((offset & 0x3) != 0) { |
| 8735 | skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8736 | "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8737 | } |
| 8738 | return skip; |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 8739 | } |
ziga-lunarg | b1dd8a2 | 2021-07-15 17:47:19 +0200 | [diff] [blame] | 8740 | |
| 8741 | bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, |
| 8742 | uint32_t srcCacheCount, |
| 8743 | const VkPipelineCache *pSrcCaches) const { |
| 8744 | bool skip = false; |
| 8745 | if (pSrcCaches) { |
| 8746 | for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) { |
| 8747 | if (pSrcCaches[index0] == dstCache) { |
| 8748 | skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770", |
| 8749 | "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.", |
| 8750 | report_data->FormatHandle(dstCache).c_str()); |
| 8751 | break; |
| 8752 | } |
| 8753 | } |
| 8754 | } |
| 8755 | return skip; |
| 8756 | } |
Nathaniel Cesario | 298d3cb | 2021-08-03 13:49:02 -0600 | [diff] [blame] | 8757 | |
| 8758 | bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, |
| 8759 | VkImageLayout imageLayout, const VkClearColorValue *pColor, |
| 8760 | uint32_t rangeCount, |
| 8761 | const VkImageSubresourceRange *pRanges) const { |
| 8762 | bool skip = false; |
| 8763 | if (!pColor) { |
| 8764 | skip |= |
| 8765 | LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null"); |
| 8766 | } |
| 8767 | return skip; |
| 8768 | } |
| 8769 | |
| 8770 | bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name, |
| 8771 | const VkRenderPassBeginInfo *const rp_begin) const { |
| 8772 | bool skip = false; |
| 8773 | if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) { |
| 8774 | skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962", |
| 8775 | "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32 |
ziga-lunarg | 47109fb | 2021-09-03 18:41:12 +0200 | [diff] [blame] | 8776 | "), but VkRenderPassBeginInfo::pClearValues is null.", |
Nathaniel Cesario | 298d3cb | 2021-08-03 13:49:02 -0600 | [diff] [blame] | 8777 | func_name, rp_begin->clearValueCount); |
| 8778 | } |
| 8779 | return skip; |
| 8780 | } |
| 8781 | |
| 8782 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 8783 | VkSubpassContents) const { |
| 8784 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin); |
| 8785 | return skip; |
| 8786 | } |
| 8787 | |
| 8788 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer, |
| 8789 | const VkRenderPassBeginInfo *pRenderPassBegin, |
| 8790 | const VkSubpassBeginInfo *) const { |
| 8791 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin); |
| 8792 | return skip; |
| 8793 | } |
| 8794 | |
| 8795 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 8796 | const VkSubpassBeginInfo *) const { |
| 8797 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin); |
| 8798 | return skip; |
| 8799 | } |
ziga-lunarg | c7bb56a | 2021-08-10 09:28:52 +0200 | [diff] [blame] | 8800 | |
| 8801 | bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer, |
| 8802 | uint32_t firstDiscardRectangle, |
| 8803 | uint32_t discardRectangleCount, |
| 8804 | const VkRect2D *pDiscardRectangles) const { |
| 8805 | bool skip = false; |
| 8806 | |
| 8807 | if (pDiscardRectangles) { |
| 8808 | for (uint32_t i = 0; i < discardRectangleCount; ++i) { |
| 8809 | const int64_t x_sum = |
| 8810 | static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width); |
| 8811 | if (x_sum > std::numeric_limits<int32_t>::max()) { |
| 8812 | skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588", |
| 8813 | "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 8814 | ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.", |
| 8815 | pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i); |
| 8816 | } |
| 8817 | |
| 8818 | const int64_t y_sum = |
| 8819 | static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height); |
| 8820 | if (y_sum > std::numeric_limits<int32_t>::max()) { |
| 8821 | skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589", |
| 8822 | "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 8823 | ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.", |
| 8824 | pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i); |
| 8825 | } |
| 8826 | } |
| 8827 | } |
| 8828 | |
| 8829 | return skip; |
| 8830 | } |
ziga-lunarg | 3c37dfb | 2021-08-24 12:51:07 +0200 | [diff] [blame] | 8831 | |
| 8832 | bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, |
| 8833 | uint32_t queryCount, size_t dataSize, void *pData, |
| 8834 | VkDeviceSize stride, VkQueryResultFlags flags) const { |
| 8835 | bool skip = false; |
| 8836 | |
| 8837 | if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) { |
| 8838 | skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811", |
| 8839 | "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit."); |
| 8840 | } |
| 8841 | |
| 8842 | return skip; |
| 8843 | } |
ziga-lunarg | cf340c4 | 2021-08-19 00:13:38 +0200 | [diff] [blame] | 8844 | |
| 8845 | bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT( |
| 8846 | VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const { |
| 8847 | bool skip = false; |
| 8848 | |
| 8849 | if ((pConditionalRenderingBegin->offset & 3) != 0) { |
| 8850 | skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984", |
| 8851 | "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64 |
| 8852 | ") is not a multiple of 4.", |
| 8853 | pConditionalRenderingBegin->offset); |
| 8854 | } |
| 8855 | |
| 8856 | return skip; |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 8857 | } |
Mike Schuchardt | 05b028d | 2022-01-05 14:15:00 -0800 | [diff] [blame] | 8858 | |
| 8859 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, |
| 8860 | VkSurfaceKHR surface, |
| 8861 | uint32_t *pSurfaceFormatCount, |
| 8862 | VkSurfaceFormatKHR *pSurfaceFormats) const { |
| 8863 | bool skip = false; |
| 8864 | if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8865 | skip |= LogError( |
| 8866 | physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524", |
| 8867 | "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled."); |
| 8868 | } |
| 8869 | return skip; |
| 8870 | } |
| 8871 | |
| 8872 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, |
| 8873 | VkSurfaceKHR surface, |
| 8874 | uint32_t *pPresentModeCount, |
| 8875 | VkPresentModeKHR *pPresentModes) const { |
| 8876 | bool skip = false; |
| 8877 | if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8878 | skip |= LogError( |
| 8879 | physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524", |
| 8880 | "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled."); |
| 8881 | } |
| 8882 | return skip; |
| 8883 | } |
| 8884 | |
| 8885 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR( |
| 8886 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 8887 | VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const { |
| 8888 | bool skip = false; |
| 8889 | if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8890 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520", |
| 8891 | "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 8892 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 8893 | } |
| 8894 | return skip; |
| 8895 | } |
| 8896 | |
| 8897 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR( |
| 8898 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount, |
| 8899 | VkSurfaceFormat2KHR *pSurfaceFormats) const { |
| 8900 | bool skip = false; |
| 8901 | if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8902 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521", |
| 8903 | "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 8904 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 8905 | } |
| 8906 | return skip; |
| 8907 | } |
| 8908 | |
| 8909 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 8910 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT( |
| 8911 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount, |
| 8912 | VkPresentModeKHR *pPresentModes) const { |
| 8913 | bool skip = false; |
| 8914 | if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8915 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521", |
| 8916 | "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 8917 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 8918 | } |
| 8919 | return skip; |
| 8920 | } |
ziga-lunarg | 50f8e6b | 2021-12-18 20:24:35 +0100 | [diff] [blame] | 8921 | |
Mike Schuchardt | 05b028d | 2022-01-05 14:15:00 -0800 | [diff] [blame] | 8922 | #endif // VK_USE_PLATFORM_WIN32_KHR |
ziga-lunarg | 50f8e6b | 2021-12-18 20:24:35 +0100 | [diff] [blame] | 8923 | |
| 8924 | bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo, |
| 8925 | const char *func_name) const { |
| 8926 | bool skip = false; |
| 8927 | |
| 8928 | if (pInfo && pInfo->pCreateInfo) { |
| 8929 | const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo); |
| 8930 | if (image_swapchain_create_info) { |
| 8931 | skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416", |
| 8932 | "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name); |
| 8933 | } |
sjfricke | 7f73fbd | 2022-05-27 06:33:36 +0900 | [diff] [blame] | 8934 | const auto *drm_format_modifier_create_info = |
| 8935 | LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pInfo->pCreateInfo); |
| 8936 | if (drm_format_modifier_create_info) { |
Mike Schuchardt | 75a4db5 | 2022-06-02 14:01:11 -0700 | [diff] [blame] | 8937 | skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirements-pCreateInfo-06776", |
sjfricke | 7f73fbd | 2022-05-27 06:33:36 +0900 | [diff] [blame] | 8938 | "%s(): pInfo->pCreateInfo->pNext chain contains VkImageDrmFormatModifierExplicitCreateInfoEXT.", |
| 8939 | func_name); |
| 8940 | } |
ziga-lunarg | 50f8e6b | 2021-12-18 20:24:35 +0100 | [diff] [blame] | 8941 | } |
| 8942 | |
| 8943 | return skip; |
| 8944 | } |
| 8945 | |
| 8946 | bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR( |
| 8947 | VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const { |
| 8948 | bool skip = false; |
| 8949 | |
| 8950 | skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR"); |
| 8951 | |
| 8952 | return skip; |
| 8953 | } |
| 8954 | |
| 8955 | bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR( |
| 8956 | VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount, |
| 8957 | VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const { |
| 8958 | bool skip = false; |
| 8959 | |
| 8960 | skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR"); |
| 8961 | |
| 8962 | return skip; |
| 8963 | } |
Tony-LunarG | 115f89d | 2022-06-15 10:53:22 -0600 | [diff] [blame] | 8964 | |
| 8965 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 8966 | bool StatelessValidation::manual_PreCallValidateExportMetalObjectsEXT(VkDevice device, |
| 8967 | VkExportMetalObjectsInfoEXT *pMetalObjectsInfo) const { |
| 8968 | bool skip = false; |
| 8969 | const VkStructureType allowed_structs_vk_export_metal_objects_info[] = { |
| 8970 | VK_STRUCTURE_TYPE_EXPORT_METAL_BUFFER_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_COMMAND_QUEUE_INFO_EXT, |
| 8971 | VK_STRUCTURE_TYPE_EXPORT_METAL_DEVICE_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_IO_SURFACE_INFO_EXT, |
| 8972 | VK_STRUCTURE_TYPE_EXPORT_METAL_SHARED_EVENT_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_TEXTURE_INFO_EXT, |
| 8973 | }; |
| 8974 | skip |= validate_struct_pnext("vkExportMetalObjectsEXT", "pMetalObjectsInfo->pNext", |
| 8975 | "VkExportMetalBufferInfoEXT, VkExportMetalCommandQueueInfoEXT, VkExportMetalDeviceInfoEXT, " |
| 8976 | "VkExportMetalIOSurfaceInfoEXT, VkExportMetalSharedEventInfoEXT, VkExportMetalTextureInfoEXT", |
| 8977 | pMetalObjectsInfo->pNext, ARRAY_SIZE(allowed_structs_vk_export_metal_objects_info), |
| 8978 | allowed_structs_vk_export_metal_objects_info, GeneratedVulkanHeaderVersion, |
| 8979 | "VUID-VkExportMetalObjectsInfoEXT-pNext-pNext", "VUID-VkExportMetalObjectsInfoEXT-sType-unique", |
| 8980 | false, true); |
| 8981 | return skip; |
| 8982 | } |
| 8983 | #endif // VK_USE_PLATFORM_METAL_EXT |