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 | } |
| 93 | |
| 94 | return skip; |
| 95 | } |
| 96 | |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 97 | 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] | 98 | if (instance_extensions.vk_khr_get_physical_device_properties2) { |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 99 | // Struct is legal IF it's supported |
| 100 | const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device); |
| 101 | if (dev_exts_enumerated == device_extensions_enumerated.end()) return true; |
| 102 | auto enum_iter = dev_exts_enumerated->second.find(ext_name); |
| 103 | if (enum_iter != dev_exts_enumerated->second.cend()) { |
| 104 | return true; |
| 105 | } |
| 106 | } |
| 107 | return false; |
| 108 | } |
| 109 | |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 110 | bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo, |
| 111 | const VkValidationFeaturesEXT *validation_features) const { |
| 112 | bool skip = false; |
| 113 | bool debug_printf = false; |
| 114 | bool gpu_assisted = false; |
| 115 | bool reserve_slot = false; |
| 116 | for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) { |
| 117 | switch (validation_features->pEnabledValidationFeatures[i]) { |
| 118 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT: |
| 119 | gpu_assisted = true; |
| 120 | break; |
| 121 | |
| 122 | case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT: |
| 123 | debug_printf = true; |
| 124 | break; |
| 125 | |
| 126 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT: |
| 127 | reserve_slot = true; |
| 128 | break; |
| 129 | |
| 130 | default: |
| 131 | break; |
| 132 | } |
| 133 | } |
| 134 | if (reserve_slot && !gpu_assisted) { |
| 135 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967", |
| 136 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, " |
| 137 | "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures."); |
| 138 | } |
| 139 | if (gpu_assisted && debug_printf) { |
| 140 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968", |
| 141 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, " |
| 142 | "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures."); |
| 143 | } |
| 144 | |
| 145 | return skip; |
| 146 | } |
| 147 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 148 | template <typename ExtensionState> |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 149 | ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) { |
| 150 | if (!extension_name) return kNotEnabled; // null strings specify nothing |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 151 | auto info = ExtensionState::get_info(extension_name); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 152 | ExtEnabled state = |
| 153 | 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] | 154 | return state; |
| 155 | } |
| 156 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 157 | bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 158 | const VkAllocationCallbacks *pAllocator, |
| 159 | VkInstance *pInstance) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 160 | bool skip = false; |
| 161 | // Note: From the spec-- |
| 162 | // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing |
| 163 | // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0) |
| 164 | uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion) |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 165 | ? pCreateInfo->pApplicationInfo->apiVersion |
| 166 | : VK_API_VERSION_1_0; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 167 | skip |= validate_api_version(local_api_version, api_version); |
| 168 | skip |= validate_instance_extensions(pCreateInfo); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 169 | const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext); |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 170 | if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features); |
| 171 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 172 | return skip; |
| 173 | } |
| 174 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 175 | void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 176 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, |
| 177 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 178 | auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 179 | // Copy extension data into local object |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 180 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 181 | this->instance_extensions = instance_data->instance_extensions; |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 182 | } |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 183 | |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 184 | void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) { |
| 185 | // Assume phys_devices is valid |
| 186 | assert(phys_devices); |
| 187 | for (int i = 0; i < count; ++i) { |
| 188 | const auto &phys_device = phys_devices[i]; |
| 189 | if (0 == physical_device_properties_map.count(phys_device)) { |
| 190 | auto phys_dev_props = new VkPhysicalDeviceProperties; |
| 191 | DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props); |
| 192 | physical_device_properties_map[phys_device] = phys_dev_props; |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 193 | |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 194 | // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state |
| 195 | uint32_t ext_count = 0; |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 196 | layer_data::unordered_set<std::string> dev_exts_enumerated{}; |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 197 | std::vector<VkExtensionProperties> ext_props{}; |
| 198 | instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr); |
| 199 | ext_props.resize(ext_count); |
| 200 | instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data()); |
| 201 | for (uint32_t j = 0; j < ext_count; j++) { |
| 202 | dev_exts_enumerated.insert(ext_props[j].extensionName); |
| 203 | } |
| 204 | device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated); |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 205 | } |
Nathaniel Cesario | 645a15b | 2021-01-08 22:40:21 -0700 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | |
| 209 | void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 210 | VkPhysicalDevice *pPhysicalDevices, VkResult result) { |
| 211 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) { |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | if (pPhysicalDeviceCount && pPhysicalDevices) { |
| 216 | CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups( |
| 221 | VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties, |
| 222 | VkResult result) { |
| 223 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) { |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) { |
| 228 | for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) { |
| 229 | const auto &group = pPhysicalDeviceGroupProperties[i]; |
| 230 | CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount); |
| 231 | } |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 232 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 235 | void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 236 | for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) { |
| 237 | delete (it->second); |
| 238 | it = physical_device_properties_map.erase(it); |
| 239 | } |
| 240 | }; |
| 241 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 242 | void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 243 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 244 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 245 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 246 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); |
| 247 | StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 248 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 249 | // Parmeter validation also uses extension data |
| 250 | stateless_validation->device_extensions = this->device_extensions; |
| 251 | |
| 252 | VkPhysicalDeviceProperties device_properties = {}; |
| 253 | // Need to get instance and do a getlayerdata call... |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 254 | DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 255 | memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 256 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 257 | if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 258 | // Get the needed shading rate image limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 259 | auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); |
| 260 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 261 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 262 | phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; |
| 263 | } |
| 264 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 265 | if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 266 | // Get the needed mesh shader limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 267 | auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>(); |
| 268 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 269 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 270 | phys_dev_ext_props.mesh_shader_props = mesh_shader_props; |
| 271 | } |
| 272 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 273 | if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 274 | // Get the needed ray tracing limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 275 | auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>(); |
| 276 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 277 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 278 | phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props; |
| 279 | } |
| 280 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 281 | if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 282 | // Get the needed ray tracing limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 283 | auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>(); |
| 284 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 285 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 286 | phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props; |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 287 | } |
| 288 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 289 | if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 290 | // Get the needed ray tracing acc structure limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 291 | auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>(); |
| 292 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 293 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 294 | phys_dev_ext_props.acc_structure_props = acc_structure_props; |
| 295 | } |
| 296 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 297 | if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) { |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 298 | // Get the needed transform feedback limits |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 299 | auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
| 300 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props); |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 301 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 302 | phys_dev_ext_props.transform_feedback_props = transform_feedback_props; |
| 303 | } |
| 304 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 305 | if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) { |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 306 | // Get the needed vertex attribute divisor limits |
| 307 | auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>(); |
| 308 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props); |
| 309 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 310 | phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props; |
| 311 | } |
| 312 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 313 | if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) { |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 314 | // Get the needed blend operation advanced properties |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 315 | auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>(); |
| 316 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props); |
| 317 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 318 | phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props; |
| 319 | } |
| 320 | |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 321 | if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) { |
| 322 | // Get the needed maintenance4 properties |
| 323 | auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>(); |
| 324 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props); |
| 325 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 326 | phys_dev_ext_props.maintenance4_props = maintance4_props; |
| 327 | } |
| 328 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 329 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 330 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 331 | // Save app-enabled features in this device's validation object |
| 332 | // 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] | 333 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 334 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 335 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 336 | if (features2) { |
| 337 | tmp_features2_state.features = features2->features; |
| 338 | } else if (pCreateInfo->pEnabledFeatures) { |
| 339 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 340 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 341 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 342 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 343 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 344 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 345 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 346 | } |
| 347 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 348 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 349 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 350 | bool skip = false; |
| 351 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 352 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 353 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 354 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 355 | } |
| 356 | |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 357 | // If this device supports VK_KHR_portability_subset, it must be enabled |
| 358 | const std::string portability_extension_name("VK_KHR_portability_subset"); |
| 359 | const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice); |
| 360 | const bool portability_supported = dev_extensions.count(portability_extension_name) != 0; |
| 361 | bool portability_requested = false; |
| 362 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 363 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 364 | skip |= |
| 365 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 366 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 367 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 368 | pCreateInfo->ppEnabledExtensionNames[i]); |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 369 | if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) { |
| 370 | portability_requested = true; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | if (portability_supported && !portability_requested) { |
| 375 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451", |
| 376 | "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it", |
| 377 | report_data->FormatHandle(physicalDevice).c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 378 | } |
| 379 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 380 | { |
aitor-lunarg | d530159 | 2022-01-05 22:38:16 +0100 | [diff] [blame] | 381 | 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] | 382 | bool negative_viewport = |
aitor-lunarg | d530159 | 2022-01-05 22:38:16 +0100 | [diff] [blame] | 383 | IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME)); |
| 384 | if (negative_viewport) { |
| 385 | // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to |
| 386 | // integration into api version 1.1 |
| 387 | if (api_version >= VK_API_VERSION_1_1) { |
| 388 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840", |
| 389 | "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not include " |
| 390 | "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1."); |
| 391 | } else if (maint1) { |
| 392 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 393 | "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include " |
| 394 | "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height."); |
| 395 | } |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 396 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 397 | } |
| 398 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 399 | { |
ziga-lunarg | 9271a7c | 2021-07-19 16:37:06 +0200 | [diff] [blame] | 400 | bool khr_bda = |
| 401 | IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 402 | bool ext_bda = |
| 403 | 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] | 404 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 405 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 406 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 407 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 408 | } |
| 409 | } |
| 410 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 411 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 412 | // Check for get_physical_device_properties2 struct |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 413 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 414 | if (features2) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 415 | // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 416 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 417 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 418 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 419 | } |
| 420 | } |
| 421 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 422 | auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 423 | const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 424 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 425 | if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { |
| 426 | skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", |
| 427 | "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); |
| 428 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 429 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 430 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed && |
| 431 | !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) { |
| 432 | skip |= LogError( |
| 433 | device, |
| 434 | "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575", |
| 435 | "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay " |
| 436 | "must also be VK_TRUE."); |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 437 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 438 | auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 439 | 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] | 440 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 441 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 442 | "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] | 443 | } |
| 444 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 445 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 446 | if (vulkan_11_features) { |
| 447 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 448 | while (current) { |
| 449 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 450 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 451 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 452 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 453 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 454 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 455 | skip |= LogError( |
| 456 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 457 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 458 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 459 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 460 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 461 | break; |
| 462 | } |
| 463 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 464 | } |
sfricke-samsung | ebda679 | 2021-01-16 08:57:52 -0800 | [diff] [blame] | 465 | |
| 466 | // Check features are enabled if matching extension is passed in as well |
| 467 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 468 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 469 | if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 470 | (vulkan_11_features->shaderDrawParameters == VK_FALSE)) { |
| 471 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 472 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476", |
sfricke-samsung | ebda679 | 2021-01-16 08:57:52 -0800 | [diff] [blame] | 473 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.", |
| 474 | VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME); |
| 475 | } |
| 476 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 479 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 480 | if (vulkan_12_features) { |
| 481 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 482 | while (current) { |
| 483 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 484 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 485 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 486 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 487 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 488 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 489 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 490 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 491 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 492 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 493 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 494 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 495 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 496 | skip |= LogError( |
| 497 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 498 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 499 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 500 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 501 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 502 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 503 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 504 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 505 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 506 | break; |
| 507 | } |
| 508 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 509 | } |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 510 | // Check features are enabled if matching extension is passed in as well |
| 511 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 512 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 513 | if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 514 | (vulkan_12_features->drawIndirectCount == VK_FALSE)) { |
| 515 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 516 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 517 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", |
| 518 | VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 519 | } |
| 520 | if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 521 | (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 522 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 523 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " |
| 524 | "is not VK_TRUE.", |
| 525 | VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); |
| 526 | } |
| 527 | if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 528 | (vulkan_12_features->descriptorIndexing == VK_FALSE)) { |
| 529 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 530 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 531 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", |
| 532 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 533 | } |
| 534 | if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 535 | (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { |
| 536 | skip |= LogError( |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 537 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 538 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", |
| 539 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 540 | } |
| 541 | if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 542 | ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || |
| 543 | (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { |
| 544 | skip |= |
Mike Schuchardt | 9969d02 | 2021-12-20 15:51:55 -0800 | [diff] [blame] | 545 | LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835", |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 546 | "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " |
| 547 | "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", |
| 548 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); |
| 549 | } |
| 550 | } |
ziga-lunarg | 27f88fd | 2021-08-01 15:47:30 +0200 | [diff] [blame] | 551 | if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) { |
| 552 | if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) { |
| 553 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748", |
| 554 | "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress " |
| 555 | "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address"); |
| 556 | } |
| 557 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 558 | } |
| 559 | |
Tony-LunarG | 273f32f | 2021-09-28 08:56:30 -0600 | [diff] [blame] | 560 | const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(pCreateInfo->pNext); |
| 561 | if (vulkan_13_features) { |
| 562 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 563 | while (current) { |
| 564 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES || |
| 565 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES || |
| 566 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES || |
| 567 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES || |
| 568 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES || |
| 569 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES || |
| 570 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES || |
| 571 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES || |
| 572 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES || |
| 573 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES || |
| 574 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES || |
| 575 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES || |
| 576 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES) { |
| 577 | skip |= LogError( |
| 578 | instance, "VUID-VkDeviceCreateInfo-pNext-06532", |
| 579 | "If the pNext chain includes a VkPhysicalDeviceVulkan13Features structure, then it must not include a " |
| 580 | "VkPhysicalDeviceDynamicRenderingFeatures, VkPhysicalDeviceImageRobustnessFeatures, " |
| 581 | "VkPhysicalDeviceInlineUniformBlockFeatures, VkPhysicalDeviceMaintenance4Features, " |
| 582 | "VkPhysicalDevicePipelineCreationCacheControlFeatures, VkPhysicalDevicePrivateDataFeatures, " |
| 583 | "VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures, VkPhysicalDeviceShaderIntegerDotProductFeatures, " |
| 584 | "VkPhysicalDeviceShaderTerminateInvocationFeatures, VkPhysicalDeviceSubgroupSizeControlFeatures, " |
| 585 | "VkPhysicalDeviceSynchronization2Features, VkPhysicalDeviceTextureCompressionASTCHDRFeatures, or " |
| 586 | "VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures structure"); |
| 587 | break; |
| 588 | } |
| 589 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 590 | } |
| 591 | } |
| 592 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 593 | // Validate pCreateInfo->pQueueCreateInfos |
| 594 | if (pCreateInfo->pQueueCreateInfos) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 595 | |
| 596 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 597 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
| 598 | const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 599 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 600 | skip |= |
| 601 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 602 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 603 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 604 | "index value.", |
| 605 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 606 | } |
| 607 | |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 608 | if (queue_create_info.pQueuePriorities != nullptr) { |
| 609 | for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { |
| 610 | const float queue_priority = queue_create_info.pQueuePriorities[j]; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 611 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 612 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 613 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 614 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 615 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 616 | } |
| 617 | } |
| 618 | } |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 619 | |
| 620 | // 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] | 621 | VkBool32 protected_memory = VK_FALSE; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 622 | const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 623 | LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 624 | if (protected_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 625 | protected_memory = protected_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 626 | } else if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 627 | protected_memory = vulkan_11_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 628 | } |
Mike Schuchardt | a9101d3 | 2021-11-12 12:24:08 -0800 | [diff] [blame] | 629 | 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] | 630 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", |
Mike Schuchardt | a9101d3 | 2021-11-12 12:24:08 -0800 | [diff] [blame] | 631 | "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " |
| 632 | "protectedMemory feature being enabled as well."); |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 633 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 634 | } |
| 635 | } |
| 636 | |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 637 | // feature dependencies for VK_KHR_variable_pointers |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 638 | const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 639 | VkBool32 variable_pointers = VK_FALSE; |
| 640 | VkBool32 variable_pointers_storage_buffer = VK_FALSE; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 641 | if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 642 | variable_pointers = vulkan_11_features->variablePointers; |
| 643 | variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 644 | } else if (variable_pointers_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 645 | variable_pointers = variable_pointers_features->variablePointers; |
| 646 | variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 647 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 648 | if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) { |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 649 | skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431", |
| 650 | "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE"); |
| 651 | } |
| 652 | |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 653 | // feature dependencies for VK_KHR_multiview |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 654 | const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 655 | VkBool32 multiview = VK_FALSE; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 656 | VkBool32 multiview_geometry_shader = VK_FALSE; |
| 657 | VkBool32 multiview_tessellation_shader = VK_FALSE; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 658 | if (vulkan_11_features) { |
| 659 | multiview = vulkan_11_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 660 | multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader; |
| 661 | multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 662 | } else if (multiview_features) { |
| 663 | multiview = multiview_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 664 | multiview_geometry_shader = multiview_features->multiviewGeometryShader; |
| 665 | multiview_tessellation_shader = multiview_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 666 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 667 | if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 668 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580", |
| 669 | "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 670 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 671 | if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 672 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581", |
| 673 | "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 674 | } |
| 675 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 676 | return skip; |
| 677 | } |
| 678 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 679 | 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] | 680 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 681 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 682 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 683 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 684 | } |
| 685 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 686 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 687 | } |
| 688 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 689 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 690 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 691 | bool skip = false; |
| 692 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 693 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 694 | skip |= |
| 695 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 696 | |
| 697 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 698 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 699 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 700 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 701 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 702 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 703 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 707 | // queueFamilyIndexCount uint32_t values |
| 708 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 709 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 710 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 711 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 712 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 713 | } |
| 714 | } |
| 715 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 716 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
| 717 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915", |
| 718 | "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the " |
| 719 | "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set."); |
| 720 | } |
| 721 | |
| 722 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) { |
| 723 | skip |= |
| 724 | LogError(device, "VUID-VkBufferCreateInfo-flags-00916", |
| 725 | "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with " |
| 726 | "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set."); |
| 727 | } |
| 728 | |
| 729 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 730 | skip |= |
| 731 | LogError(device, "VUID-VkBufferCreateInfo-flags-00917", |
| 732 | "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with " |
| 733 | "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set."); |
| 734 | } |
| 735 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 736 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 737 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 738 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 739 | ((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] | 740 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 741 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 742 | "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] | 743 | } |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 744 | |
| 745 | const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext); |
| 746 | if (maintenance4_features && maintenance4_features->maintenance4) { |
| 747 | if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) { |
| 748 | skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409", |
| 749 | "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size " |
| 750 | "VkPhysicalDeviceMaintenance4Properties.maxBufferSize"); |
| 751 | } |
| 752 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | return skip; |
| 756 | } |
| 757 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 758 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 759 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 760 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 761 | |
| 762 | if (pCreateInfo != nullptr) { |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 763 | const VkFormat image_format = pCreateInfo->format; |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 764 | const VkImageCreateFlags image_flags = pCreateInfo->flags; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 765 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 766 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 767 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 768 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 769 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942", |
| 770 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 771 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 775 | // queueFamilyIndexCount uint32_t values |
| 776 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 777 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941", |
| 778 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 779 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 780 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 781 | } |
| 782 | } |
| 783 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 784 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 785 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 786 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 787 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 788 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 789 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 790 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 791 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 792 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 793 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 794 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 795 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 796 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 797 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 798 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 799 | skip |= LogError( |
| 800 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 801 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 802 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 803 | } |
| 804 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 805 | // 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] | 806 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 807 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 808 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 809 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 810 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 814 | if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 815 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 816 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 817 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 818 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 819 | ") are not equal.", |
| 820 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 824 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 825 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 826 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 827 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 828 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 832 | skip |= LogError( |
| 833 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 834 | "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] | 835 | } |
| 836 | } |
| 837 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 838 | // 3D image may have only 1 layer |
| 839 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 840 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 841 | "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] | 842 | } |
| 843 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 844 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 845 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 846 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 847 | // At least one of the legal attachment bits must be set |
| 848 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 849 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 850 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 851 | } |
| 852 | // No flags other than the legal attachment bits may be set |
| 853 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 854 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 855 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 856 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 857 | } |
| 858 | } |
| 859 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 860 | // 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] | 861 | 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] | 862 | // Max mip levels is different for corner-sampled images vs normal images. |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 863 | 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] | 864 | ? static_cast<uint32_t>(ceil(log2(max_dim))) |
| 865 | : static_cast<uint32_t>(floor(log2(max_dim)) + 1); |
| 866 | if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 867 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 868 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 869 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 870 | "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] | 871 | } |
| 872 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 873 | 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] | 874 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 875 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 876 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 877 | } |
| 878 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 879 | 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] | 880 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 881 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 882 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 883 | } |
| 884 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 885 | 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] | 886 | skip |= LogError( |
| 887 | device, "VUID-VkImageCreateInfo-flags-01924", |
| 888 | "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the " |
| 889 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set."); |
| 890 | } |
| 891 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 892 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 893 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 894 | if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 895 | ((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] | 896 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 897 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 898 | "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] | 899 | } |
| 900 | |
| 901 | // 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] | 902 | if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 903 | // Linear tiling is unsupported |
| 904 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
sfricke-samsung | 9801d75 | 2020-08-23 22:00:16 -0700 | [diff] [blame] | 905 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 906 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 907 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | // Sparse 1D image isn't valid |
| 911 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 912 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 913 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 917 | 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] | 918 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 919 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 920 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 924 | 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] | 925 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 926 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 927 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | // Multi-sample 2D image when device doesn't support it |
| 931 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 932 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 933 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 934 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 935 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 936 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 937 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 938 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 939 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 940 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 941 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 942 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 943 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 944 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 945 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 946 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 947 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 948 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 949 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 950 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 951 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 952 | } |
| 953 | } |
| 954 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 955 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 956 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 957 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 958 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 959 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 960 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 961 | } |
| 962 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 963 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 964 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 965 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 966 | } |
| 967 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 968 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 969 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 970 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 971 | } |
| 972 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 973 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 974 | if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 975 | 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] | 976 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 977 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 978 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 979 | } |
| 980 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 981 | if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 982 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 983 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 984 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a " |
| 985 | "depth/stencil format.", |
| 986 | string_VkFormat(image_format)); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 987 | } |
| 988 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 989 | 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] | 990 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 991 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 992 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 993 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 994 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 995 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 996 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 997 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 998 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 999 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1000 | } |
| 1001 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1002 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1003 | 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] | 1004 | (FormatHasDepth(image_format) == false)) { |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 1005 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533", |
| 1006 | "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] | 1007 | "format (%s) must be a depth or depth/stencil format.", |
| 1008 | string_VkFormat(image_format)); |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 1009 | } |
| 1010 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1011 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1012 | if (image_stencil_struct != nullptr) { |
| 1013 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 1014 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 1015 | // No flags other than the legal attachment bits may be set |
| 1016 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 1017 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1018 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 1019 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 1020 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 1021 | "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] | 1022 | } |
| 1023 | } |
| 1024 | |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1025 | if (FormatIsDepthOrStencil(image_format)) { |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1026 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 1027 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1028 | skip |= |
| 1029 | LogError(device, "VUID-VkImageCreateInfo-Format-02536", |
| 1030 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 1031 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32 |
| 1032 | ") exceeds device " |
| 1033 | "maxFramebufferWidth (%" PRIu32 ")", |
| 1034 | pCreateInfo->extent.width, device_limits.maxFramebufferWidth); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1038 | skip |= |
| 1039 | LogError(device, "VUID-VkImageCreateInfo-format-02537", |
| 1040 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 1041 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32 |
| 1042 | ") exceeds device " |
| 1043 | "maxFramebufferHeight (%" PRIu32 ")", |
| 1044 | pCreateInfo->extent.height, device_limits.maxFramebufferHeight); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | if (!physical_device_features.shaderStorageImageMultisample && |
| 1049 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 1050 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 1051 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1052 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 1053 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 1054 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 1055 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 1059 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1060 | skip |= LogError( |
| 1061 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1062 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 1063 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1064 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 1065 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 1066 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1067 | skip |= LogError( |
| 1068 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1069 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 1070 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 1071 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1072 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 1073 | } |
| 1074 | |
| 1075 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 1076 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1077 | skip |= LogError( |
| 1078 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1079 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 1080 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1081 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 1082 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 1083 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1084 | skip |= LogError( |
| 1085 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1086 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 1087 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 1088 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1089 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 1090 | } |
| 1091 | } |
| 1092 | } |
Spencer Fricke | ca52b5c | 2020-03-16 17:34:00 -0700 | [diff] [blame] | 1093 | |
| 1094 | if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 1095 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 1096 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968", |
| 1097 | "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images " |
| 1098 | "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
| 1099 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1100 | |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1101 | std::vector<uint64_t> image_create_drm_format_modifiers; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1102 | if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1103 | const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext); |
| 1104 | const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext); |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1105 | if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1106 | if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) || |
| 1107 | ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) { |
| 1108 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261", |
| 1109 | "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have " |
| 1110 | "either VkImageDrmFormatModifierListCreateInfoEXT or " |
| 1111 | "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain"); |
Martin Freebody | 0ec2c7a | 2021-03-03 16:48:00 +0000 | [diff] [blame] | 1112 | } else if (drm_format_mod_explict != nullptr) { |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1113 | image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier); |
| 1114 | } else if (drm_format_mod_list != nullptr) { |
| 1115 | for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) { |
| 1116 | image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers); |
| 1117 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1118 | } |
| 1119 | } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) { |
| 1120 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262", |
| 1121 | "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a " |
| 1122 | "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT " |
| 1123 | "in the pNext chain"); |
| 1124 | } |
| 1125 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1126 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1127 | static const uint64_t drm_format_mod_linear = 0; |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1128 | bool image_create_maybe_linear = false; |
| 1129 | if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) { |
| 1130 | image_create_maybe_linear = true; |
| 1131 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) { |
| 1132 | image_create_maybe_linear = false; |
| 1133 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1134 | image_create_maybe_linear = |
| 1135 | (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] | 1136 | drm_format_mod_linear) != image_create_drm_format_modifiers.end()); |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 1140 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1141 | ((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] | 1142 | (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) { |
| 1143 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 1144 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
| 1145 | } |
| 1146 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1147 | if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) && |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1148 | ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || |
| 1149 | image_create_maybe_linear)) { |
| 1150 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259", |
| 1151 | "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips."); |
| 1152 | } |
| 1153 | |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1154 | if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) { |
| 1155 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1156 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557", |
| 1157 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1158 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1159 | } |
| 1160 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1161 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558", |
| 1162 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1163 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
| 1164 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1165 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1166 | if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) { |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1167 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1168 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565", |
| 1169 | "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1170 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 1171 | } |
| 1172 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1173 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566", |
| 1174 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1175 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1176 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1177 | if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1178 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567", |
| 1179 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1180 | "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT."); |
| 1181 | } |
| 1182 | if (pCreateInfo->mipLevels != 1) { |
| 1183 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1184 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32 |
| 1185 | ") must be 1.", |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1186 | pCreateInfo->mipLevels); |
| 1187 | } |
| 1188 | } |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1189 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1190 | const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1191 | if (swapchain_create_info != nullptr) { |
| 1192 | if (swapchain_create_info->swapchain != VK_NULL_HANDLE) { |
| 1193 | // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the |
| 1194 | // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information |
| 1195 | // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation |
| 1196 | const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995"; |
| 1197 | const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image"; |
| 1198 | |
| 1199 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1200 | // also implicitly forces the check above that extent.depth is 1 |
| 1201 | skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message, |
| 1202 | string_VkImageType(pCreateInfo->imageType)); |
| 1203 | } |
| 1204 | if (pCreateInfo->mipLevels != 1) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1205 | 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] | 1206 | pCreateInfo->mipLevels); |
| 1207 | } |
| 1208 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1209 | skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.", |
| 1210 | base_message, string_VkSampleCountFlagBits(pCreateInfo->samples)); |
| 1211 | } |
| 1212 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1213 | skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.", |
| 1214 | base_message, string_VkImageTiling(pCreateInfo->tiling)); |
| 1215 | } |
| 1216 | if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) { |
| 1217 | skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.", |
| 1218 | base_message, string_VkImageLayout(pCreateInfo->initialLayout)); |
| 1219 | } |
| 1220 | const VkImageCreateFlags valid_flags = |
| 1221 | (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] | 1222 | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT); |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1223 | if ((image_flags & ~valid_flags) != 0) { |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1224 | 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] | 1225 | image_flags); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1226 | } |
| 1227 | } |
| 1228 | } |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1229 | |
| 1230 | // If Chroma subsampled format ( _420_ or _422_ ) |
| 1231 | if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) { |
| 1232 | skip |= |
| 1233 | LogError(device, "VUID-VkImageCreateInfo-format-04712", |
| 1234 | "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32 |
| 1235 | ") must be a multiple of 2.", |
| 1236 | string_VkFormat(image_format), pCreateInfo->extent.width); |
| 1237 | } |
| 1238 | if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) { |
| 1239 | skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713", |
| 1240 | "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32 |
| 1241 | ") must be a multiple of 2.", |
| 1242 | string_VkFormat(image_format), pCreateInfo->extent.height); |
| 1243 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1244 | |
| 1245 | const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext); |
| 1246 | if (format_list_info) { |
| 1247 | const uint32_t viewFormatCount = format_list_info->viewFormatCount; |
| 1248 | if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) { |
| 1249 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738", |
| 1250 | "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] | 1251 | "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.", |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1252 | viewFormatCount); |
| 1253 | } |
| 1254 | // Check if viewFormatCount is not zero that it is all compatible |
| 1255 | for (uint32_t i = 0; i < viewFormatCount; i++) { |
Mike Schuchardt | b060849 | 2022-04-05 18:52:48 -0700 | [diff] [blame] | 1256 | const bool class_compatible = |
| 1257 | FormatCompatibilityClass(format_list_info->pViewFormats[i]) == FormatCompatibilityClass(image_format); |
| 1258 | if (!class_compatible) { |
| 1259 | if (image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) { |
| 1260 | const bool size_compatible = |
| 1261 | FormatIsCompressed(format_list_info->pViewFormats[i]) |
| 1262 | ? false |
| 1263 | : FormatElementSize(format_list_info->pViewFormats[i]) == FormatElementSize(image_format); |
| 1264 | if (!size_compatible) { |
| 1265 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722", |
| 1266 | "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32 |
| 1267 | "] (%s) and VkImageCreateInfo::format (%s) are not compatible or size-compatible.", |
| 1268 | i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format)); |
| 1269 | } |
| 1270 | } else { |
| 1271 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722", |
| 1272 | "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32 |
| 1273 | "] (%s) and VkImageCreateInfo::format (%s) are not compatible.", |
| 1274 | i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format)); |
| 1275 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1276 | } |
| 1277 | } |
| 1278 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1279 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1280 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1281 | return skip; |
| 1282 | } |
| 1283 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1284 | bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 1285 | const VkAllocationCallbacks *pAllocator, VkImageView *pView) const { |
| 1286 | bool skip = false; |
| 1287 | |
| 1288 | if (pCreateInfo != nullptr) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1289 | // Validate feature set if using CUBE_ARRAY |
| 1290 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) { |
| 1291 | skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004", |
| 1292 | "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without " |
| 1293 | "enabling the imageCubeArray feature."); |
| 1294 | } |
| 1295 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1296 | if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 1297 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) { |
| 1298 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1299 | "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32 |
| 1300 | ") must be 6 or VK_REMAINING_ARRAY_LAYERS.", |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1301 | pCreateInfo->subresourceRange.layerCount); |
| 1302 | } |
| 1303 | 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] | 1304 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961", |
| 1305 | "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32 |
| 1306 | ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.", |
| 1307 | pCreateInfo->subresourceRange.layerCount); |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1308 | } |
| 1309 | } |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1310 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1311 | auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1312 | 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] | 1313 | if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) && |
| 1314 | (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) && |
| 1315 | (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) { |
| 1316 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230", |
| 1317 | "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be " |
| 1318 | "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32."); |
| 1319 | } |
sfricke-samsung | e308629 | 2021-11-18 23:02:35 -0800 | [diff] [blame] | 1320 | if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) && |
| 1321 | (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) { |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1322 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084", |
| 1323 | "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and " |
| 1324 | "not an ASTC format.", |
| 1325 | string_VkFormat(pCreateInfo->format)); |
| 1326 | } |
| 1327 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1328 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1329 | auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1330 | if (ycbcr_conversion != nullptr) { |
| 1331 | if (ycbcr_conversion->conversion != VK_NULL_HANDLE) { |
| 1332 | if (IsIdentitySwizzle(pCreateInfo->components) == false) { |
| 1333 | skip |= LogError( |
| 1334 | device, "VUID-VkImageViewCreateInfo-pNext-01970", |
| 1335 | "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must " |
| 1336 | "be created with the identity swizzle. Here are the actual swizzle values:\n" |
| 1337 | "r swizzle = %s\n" |
| 1338 | "g swizzle = %s\n" |
| 1339 | "b swizzle = %s\n" |
| 1340 | "a swizzle = %s\n", |
| 1341 | string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g), |
| 1342 | string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a)); |
| 1343 | } |
| 1344 | } |
| 1345 | } |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1346 | } |
| 1347 | return skip; |
| 1348 | } |
| 1349 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1350 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1351 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1352 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1353 | |
| 1354 | // Note: for numerical correctness |
| 1355 | // - float comparisons should expect NaN (comparison always false). |
| 1356 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 1357 | |
| 1358 | 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] | 1359 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1360 | if (v1_f <= 0.0f) return true; |
| 1361 | |
| 1362 | float intpart; |
| 1363 | const float fract = modff(v1_f, &intpart); |
| 1364 | |
| 1365 | assert(std::numeric_limits<float>::radix == 2); |
| 1366 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 1367 | if (intpart >= u32_max_plus1) return false; |
| 1368 | |
| 1369 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1370 | if (v1_u32 < v2_u32) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1371 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1372 | } else if (v1_u32 == v2_u32 && fract == 0.0f) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1373 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1374 | } else { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1375 | return false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1376 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1377 | }; |
| 1378 | |
| 1379 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 1380 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 1381 | return (v1_f <= v2_f); |
| 1382 | }; |
| 1383 | |
| 1384 | // width |
| 1385 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1386 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1387 | |
| 1388 | if (!(viewport.width > 0.0f)) { |
| 1389 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1390 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 1391 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1392 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 1393 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1394 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 1395 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 1396 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | // height |
| 1400 | bool height_healthy = true; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1401 | const bool negative_height_enabled = |
| 1402 | 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] | 1403 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1404 | |
| 1405 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1406 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1407 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 1408 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1409 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1410 | height_healthy = false; |
| 1411 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1412 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 1413 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 1414 | ").", |
| 1415 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1416 | } |
| 1417 | |
| 1418 | // x |
| 1419 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1420 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1421 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1422 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 1423 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1424 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | // x + width |
| 1428 | if (x_healthy && width_healthy) { |
| 1429 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1430 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1431 | skip |= LogError( |
| 1432 | object, "VUID-VkViewport-x-01232", |
| 1433 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1434 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 1435 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | // y |
| 1440 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1441 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1442 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1443 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 1444 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1445 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1446 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1447 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1448 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 1449 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1450 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1451 | } |
| 1452 | |
| 1453 | // y + height |
| 1454 | if (y_healthy && height_healthy) { |
| 1455 | const float boundary = viewport.y + viewport.height; |
| 1456 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1457 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1458 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 1459 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1460 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 1461 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1462 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1463 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1464 | LogError(object, "VUID-VkViewport-y-01777", |
| 1465 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 1466 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 1467 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1468 | } |
| 1469 | } |
| 1470 | |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1471 | // 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] | 1472 | if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1473 | // minDepth |
| 1474 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1475 | // Also VUID-VkViewport-minDepth-02540 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1476 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1477 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 1478 | "[0.0, 1.0] range.", |
| 1479 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | // maxDepth |
| 1483 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1484 | // Also VUID-VkViewport-maxDepth-02541 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1485 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1486 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 1487 | "[0.0, 1.0] range.", |
| 1488 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1489 | } |
| 1490 | } |
| 1491 | |
| 1492 | return skip; |
| 1493 | } |
| 1494 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1495 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1496 | VkShadingRatePaletteEntryNV shadingRate; |
| 1497 | uint32_t width; |
| 1498 | uint32_t height; |
| 1499 | }; |
| 1500 | |
| 1501 | // All palette entries with more than one pixel per fragment |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1502 | static SampleOrderInfo sample_order_infos[] = { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1503 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 1504 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 1505 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 1506 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 1507 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 1508 | {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] | 1509 | }; |
| 1510 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 1511 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1512 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1513 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1514 | SampleOrderInfo *sample_order_info; |
| 1515 | uint32_t info_idx = 0; |
| 1516 | for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) { |
| 1517 | if (sample_order_infos[info_idx].shadingRate == order->shadingRate) { |
| 1518 | sample_order_info = &sample_order_infos[info_idx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1519 | break; |
| 1520 | } |
| 1521 | } |
| 1522 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1523 | if (sample_order_info == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1524 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 1525 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 1526 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1527 | return skip; |
| 1528 | } |
| 1529 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1530 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1531 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1532 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 1533 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 1534 | ") must " |
| 1535 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 1536 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 1537 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1538 | } |
| 1539 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1540 | 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] | 1541 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 1542 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1543 | ") must " |
| 1544 | "be equal to the product of sampleCount (=%" PRIu32 |
| 1545 | "), the fragment width for shadingRate " |
| 1546 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1547 | order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1548 | } |
| 1549 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1550 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1551 | skip |= LogError( |
| 1552 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1553 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1554 | ") must " |
| 1555 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1556 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1557 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1558 | |
| 1559 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1560 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 1561 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 1562 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1563 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1564 | uint64_t sample_locations_mask = 0; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1565 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1566 | const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i]; |
| 1567 | if (sample_loc->pixelX >= sample_order_info->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1568 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 1569 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1570 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1571 | if (sample_loc->pixelY >= sample_order_info->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1572 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 1573 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1574 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1575 | if (sample_loc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1576 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 1577 | "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] | 1578 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1579 | uint32_t idx = |
| 1580 | sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY); |
| 1581 | sample_locations_mask |= 1ULL << idx; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1582 | } |
| 1583 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1584 | uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 1585 | if (sample_locations_mask != expected_mask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1586 | skip |= LogError( |
| 1587 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1588 | "The array pSampleLocations must contain exactly one entry for " |
| 1589 | "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] | 1590 | } |
| 1591 | |
| 1592 | return skip; |
| 1593 | } |
| 1594 | |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1595 | bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, |
| 1596 | const VkAllocationCallbacks *pAllocator, |
| 1597 | VkPipelineLayout *pPipelineLayout) const { |
| 1598 | bool skip = false; |
| 1599 | // Validate layout count against device physical limit |
| 1600 | if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) { |
| 1601 | skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1602 | "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32 |
| 1603 | ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1604 | pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets); |
| 1605 | } |
| 1606 | |
Nathaniel Cesario | db38b7a | 2022-03-10 22:16:51 -0700 | [diff] [blame] | 1607 | const bool has_independent_sets = (pCreateInfo->flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT) != 0; |
| 1608 | const bool graphics_pipeline_library = IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library); |
| 1609 | const char *const valid_dsl_vuid = (!graphics_pipeline_library) |
| 1610 | ? "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561" |
| 1611 | : ((!has_independent_sets) ? "VUID-VkPipelineLayoutCreateInfo-flags-06562" : nullptr); |
| 1612 | if (valid_dsl_vuid) { |
| 1613 | for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) { |
| 1614 | if (!pCreateInfo->pSetLayouts[i]) { |
| 1615 | skip |= |
| 1616 | LogError(device, valid_dsl_vuid, "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32 "] is VK_NULL_HANDLE.", i); |
| 1617 | } |
| 1618 | } |
| 1619 | } |
| 1620 | |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1621 | // Validate Push Constant ranges |
| 1622 | for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) { |
| 1623 | const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset; |
| 1624 | const uint32_t size = pCreateInfo->pPushConstantRanges[i].size; |
| 1625 | const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize; |
| 1626 | // Check that offset + size don't exceed the max. |
| 1627 | // Prevent arithetic overflow here by avoiding addition and testing in this order. |
| 1628 | if (offset >= max_push_constants_size) { |
| 1629 | skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1630 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32 |
| 1631 | ") that exceeds this " |
| 1632 | "device's maxPushConstantSize of %" PRIu32 ".", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1633 | i, offset, max_push_constants_size); |
| 1634 | } |
| 1635 | if (size > max_push_constants_size - offset) { |
| 1636 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00298", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1637 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32 |
| 1638 | ") and size (%" PRIu32 |
| 1639 | ") " |
| 1640 | "together exceeds this device's maxPushConstantSize of %" PRIu32 ".", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1641 | i, offset, size, max_push_constants_size); |
| 1642 | } |
| 1643 | |
| 1644 | // size needs to be non-zero and a multiple of 4. |
| 1645 | if (size == 0) { |
| 1646 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00296", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1647 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32 |
| 1648 | ") is not greater than zero.", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1649 | i, size); |
| 1650 | } |
| 1651 | if (size & 0x3) { |
| 1652 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00297", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1653 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32 |
| 1654 | ") is not a multiple of 4.", |
| 1655 | i, size); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1656 | } |
| 1657 | |
| 1658 | // offset needs to be a multiple of 4. |
| 1659 | if ((offset & 0x3) != 0) { |
| 1660 | skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1661 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32 |
| 1662 | ") is not a multiple of 4.", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1663 | i, offset); |
| 1664 | } |
| 1665 | } |
| 1666 | |
| 1667 | // 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. |
| 1668 | for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) { |
| 1669 | for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) { |
| 1670 | if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1671 | skip |= |
| 1672 | LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292", |
| 1673 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1674 | } |
| 1675 | } |
| 1676 | } |
| 1677 | return skip; |
| 1678 | } |
| 1679 | |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 1680 | bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg, |
| 1681 | const VkPipelineShaderStageCreateInfo *pCreateInfo) const { |
| 1682 | bool skip = false; |
| 1683 | |
| 1684 | const auto *required_subgroup_size_features = |
| 1685 | LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext); |
| 1686 | |
| 1687 | if (required_subgroup_size_features) { |
| 1688 | if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) { |
| 1689 | skip |= LogError( |
| 1690 | device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754", |
| 1691 | "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while " |
| 1692 | "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.", |
| 1693 | func_name, msg, pCreateInfo->flags); |
| 1694 | } |
| 1695 | } |
| 1696 | |
| 1697 | return skip; |
| 1698 | } |
| 1699 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1700 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 1701 | uint32_t createInfoCount, |
| 1702 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1703 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1704 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1705 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1706 | |
| 1707 | if (pCreateInfos != nullptr) { |
| 1708 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1709 | bool has_dynamic_viewport = false; |
| 1710 | bool has_dynamic_scissor = false; |
| 1711 | bool has_dynamic_line_width = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1712 | bool has_dynamic_depth_bias = false; |
| 1713 | bool has_dynamic_blend_constant = false; |
| 1714 | bool has_dynamic_depth_bounds = false; |
| 1715 | bool has_dynamic_stencil_compare = false; |
| 1716 | bool has_dynamic_stencil_write = false; |
| 1717 | bool has_dynamic_stencil_reference = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1718 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1719 | bool has_dynamic_discard_rectangle_ext = false; |
| 1720 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1721 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1722 | bool has_dynamic_shading_rate_palette_nv = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1723 | bool has_dynamic_viewport_course_sample_order_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1724 | bool has_dynamic_line_stipple = false; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1725 | bool has_dynamic_cull_mode = false; |
| 1726 | bool has_dynamic_front_face = false; |
| 1727 | bool has_dynamic_primitive_topology = false; |
| 1728 | bool has_dynamic_viewport_with_count = false; |
| 1729 | bool has_dynamic_scissor_with_count = false; |
| 1730 | bool has_dynamic_vertex_input_binding_stride = false; |
| 1731 | bool has_dynamic_depth_test_enable = false; |
| 1732 | bool has_dynamic_depth_write_enable = false; |
| 1733 | bool has_dynamic_depth_compare_op = false; |
| 1734 | bool has_dynamic_depth_bounds_test_enable = false; |
| 1735 | bool has_dynamic_stencil_test_enable = false; |
| 1736 | bool has_dynamic_stencil_op = false; |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 1737 | bool has_patch_control_points = false; |
| 1738 | bool has_rasterizer_discard_enable = false; |
| 1739 | bool has_depth_bias_enable = false; |
| 1740 | bool has_logic_op = false; |
| 1741 | bool has_primitive_restart_enable = false; |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 1742 | bool has_dynamic_vertex_input = false; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 1743 | |
| 1744 | // Create a copy of create_info and set non-included sub-state to null |
| 1745 | auto create_info = pCreateInfos[i]; |
| 1746 | const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext); |
| 1747 | if (graphics_lib_info) { |
Nathaniel Cesario | bcb7968 | 2022-03-31 21:13:52 -0600 | [diff] [blame] | 1748 | // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries |
| 1749 | if (enabled[gpu_validation]) { |
| 1750 | skip |= |
| 1751 | LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported"); |
| 1752 | } |
| 1753 | if (enabled[gpu_validation]) { |
| 1754 | skip |= LogError(device, kVUIDUndefined, |
| 1755 | "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported"); |
| 1756 | } |
| 1757 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 1758 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) { |
| 1759 | create_info.pVertexInputState = nullptr; |
| 1760 | create_info.pInputAssemblyState = nullptr; |
| 1761 | } |
| 1762 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) { |
| 1763 | create_info.pViewportState = nullptr; |
| 1764 | create_info.pRasterizationState = nullptr; |
| 1765 | create_info.pTessellationState = nullptr; |
| 1766 | } |
| 1767 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) { |
| 1768 | create_info.pDepthStencilState = nullptr; |
| 1769 | } |
| 1770 | if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) { |
| 1771 | create_info.pColorBlendState = nullptr; |
| 1772 | } |
| 1773 | if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT | |
| 1774 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) { |
| 1775 | create_info.pMultisampleState = nullptr; |
| 1776 | } |
| 1777 | if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT | |
| 1778 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) { |
| 1779 | create_info.layout = VK_NULL_HANDLE; |
| 1780 | } |
| 1781 | if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT | |
| 1782 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT | |
| 1783 | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) { |
| 1784 | create_info.renderPass = VK_NULL_HANDLE; |
| 1785 | create_info.subpass = 0; |
| 1786 | } |
| 1787 | } |
| 1788 | |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1789 | if (!create_info.renderPass) { |
| 1790 | if (create_info.pColorBlendState && create_info.pMultisampleState) { |
| 1791 | // Pipeline has fragment outout state |
| 1792 | const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext); |
| 1793 | if (rendering_struct) { |
| 1794 | if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) { |
| 1795 | skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat", |
| 1796 | AllVkFormatEnums, rendering_struct->stencilAttachmentFormat, |
| 1797 | "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583"); |
Nathaniel Cesario | e77320e | 2022-04-11 17:32:33 -0600 | [diff] [blame] | 1798 | |
| 1799 | if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) { |
| 1800 | skip |= LogError( |
| 1801 | device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587", |
| 1802 | "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32 |
| 1803 | "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.", |
| 1804 | i, string_VkFormat(rendering_struct->depthAttachmentFormat)); |
| 1805 | } |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1806 | } |
| 1807 | |
| 1808 | if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) { |
| 1809 | skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat", |
| 1810 | AllVkFormatEnums, rendering_struct->stencilAttachmentFormat, |
| 1811 | "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584"); |
Nathaniel Cesario | e77320e | 2022-04-11 17:32:33 -0600 | [diff] [blame] | 1812 | if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) { |
Nathaniel Cesario | 1ba7ca5 | 2022-04-18 12:35:00 -0600 | [diff] [blame] | 1813 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588", |
| 1814 | "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32 |
| 1815 | "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a " |
| 1816 | "stencil aspect.", |
| 1817 | i, string_VkFormat(rendering_struct->stencilAttachmentFormat)); |
Nathaniel Cesario | e77320e | 2022-04-11 17:32:33 -0600 | [diff] [blame] | 1818 | } |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1819 | } |
Nathaniel Cesario | 45efaac | 2022-04-11 17:04:33 -0600 | [diff] [blame] | 1820 | |
| 1821 | if (rendering_struct->colorAttachmentCount != 0) { |
| 1822 | skip |= validate_ranged_enum_array( |
| 1823 | "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579", |
| 1824 | "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums, |
| 1825 | rendering_struct->colorAttachmentCount, rendering_struct->pColorAttachmentFormats, true, true); |
| 1826 | } |
Nathaniel Cesario | 72f2955 | 2022-03-24 05:11:11 -0600 | [diff] [blame] | 1827 | } |
| 1828 | } |
| 1829 | } |
| 1830 | |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1831 | if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) { |
| 1832 | if (create_info.stageCount == 0) { |
| 1833 | skip |= |
| 1834 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604", |
| 1835 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i, |
| 1836 | VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME); |
| 1837 | } |
| 1838 | // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to |
| 1839 | // ParameterName::IndexFormatSpecifier |
| 1840 | skip |= validate_struct_type_array( |
| 1841 | "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}), |
| 1842 | ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}), |
| 1843 | "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages, |
| 1844 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true, |
| 1845 | "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600", |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 1846 | "VUID-VkGraphicsPipelineCreateInfo-pStages-06600"); |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1847 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 1848 | ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}), |
| 1849 | "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO", |
| 1850 | pCreateInfos[i].pRasterizationState, |
| 1851 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true, |
| 1852 | "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601", |
| 1853 | "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType"); |
Nathaniel Cesario | 617ffdc | 2022-03-11 17:02:45 -0700 | [diff] [blame] | 1854 | } |
| 1855 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 1856 | // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline" |
| 1857 | if (create_info.pDynamicState != nullptr) { |
| 1858 | const auto &dynamic_state_info = *create_info.pDynamicState; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1859 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1860 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1861 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1862 | if (has_dynamic_viewport == true) { |
| 1863 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1864 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1865 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1866 | i); |
| 1867 | } |
| 1868 | has_dynamic_viewport = true; |
| 1869 | } |
| 1870 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) { |
| 1871 | if (has_dynamic_scissor == true) { |
| 1872 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1873 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1874 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1875 | i); |
| 1876 | } |
| 1877 | has_dynamic_scissor = true; |
| 1878 | } |
| 1879 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) { |
| 1880 | if (has_dynamic_line_width == true) { |
| 1881 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1882 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1883 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1884 | i); |
| 1885 | } |
| 1886 | has_dynamic_line_width = true; |
| 1887 | } |
| 1888 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) { |
| 1889 | if (has_dynamic_depth_bias == true) { |
| 1890 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1891 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1892 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1893 | i); |
| 1894 | } |
| 1895 | has_dynamic_depth_bias = true; |
| 1896 | } |
| 1897 | if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) { |
| 1898 | if (has_dynamic_blend_constant == true) { |
| 1899 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1900 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1901 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1902 | i); |
| 1903 | } |
| 1904 | has_dynamic_blend_constant = true; |
| 1905 | } |
| 1906 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) { |
| 1907 | if (has_dynamic_depth_bounds == true) { |
| 1908 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1909 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1910 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1911 | i); |
| 1912 | } |
| 1913 | has_dynamic_depth_bounds = true; |
| 1914 | } |
| 1915 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) { |
| 1916 | if (has_dynamic_stencil_compare == true) { |
| 1917 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1918 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1919 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1920 | i); |
| 1921 | } |
| 1922 | has_dynamic_stencil_compare = true; |
| 1923 | } |
| 1924 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) { |
| 1925 | if (has_dynamic_stencil_write == true) { |
| 1926 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1927 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1928 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1929 | i); |
| 1930 | } |
| 1931 | has_dynamic_stencil_write = true; |
| 1932 | } |
| 1933 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) { |
| 1934 | if (has_dynamic_stencil_reference == true) { |
| 1935 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1936 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1937 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1938 | i); |
| 1939 | } |
| 1940 | has_dynamic_stencil_reference = true; |
| 1941 | } |
| 1942 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) { |
| 1943 | if (has_dynamic_viewport_w_scaling_nv == true) { |
| 1944 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1945 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1946 | "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1947 | i); |
| 1948 | } |
| 1949 | has_dynamic_viewport_w_scaling_nv = true; |
| 1950 | } |
| 1951 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) { |
| 1952 | if (has_dynamic_discard_rectangle_ext == true) { |
| 1953 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1954 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1955 | "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1956 | i); |
| 1957 | } |
| 1958 | has_dynamic_discard_rectangle_ext = true; |
| 1959 | } |
| 1960 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) { |
| 1961 | if (has_dynamic_sample_locations_ext == true) { |
| 1962 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1963 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1964 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1965 | i); |
| 1966 | } |
| 1967 | has_dynamic_sample_locations_ext = true; |
| 1968 | } |
| 1969 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) { |
| 1970 | if (has_dynamic_exclusive_scissor_nv == true) { |
| 1971 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1972 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1973 | "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1974 | i); |
| 1975 | } |
| 1976 | has_dynamic_exclusive_scissor_nv = true; |
| 1977 | } |
| 1978 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) { |
| 1979 | if (has_dynamic_shading_rate_palette_nv == true) { |
| 1980 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1981 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1982 | "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1983 | i); |
| 1984 | } |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1985 | has_dynamic_shading_rate_palette_nv = true; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1986 | } |
| 1987 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) { |
| 1988 | if (has_dynamic_viewport_course_sample_order_nv == true) { |
| 1989 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1990 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 1991 | "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1992 | i); |
| 1993 | } |
| 1994 | has_dynamic_viewport_course_sample_order_nv = true; |
| 1995 | } |
| 1996 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) { |
| 1997 | if (has_dynamic_line_stipple == true) { |
| 1998 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1999 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2000 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 2001 | i); |
| 2002 | } |
| 2003 | has_dynamic_line_stipple = true; |
| 2004 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2005 | if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) { |
| 2006 | if (has_dynamic_cull_mode) { |
| 2007 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2008 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2009 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2010 | i); |
| 2011 | } |
| 2012 | has_dynamic_cull_mode = true; |
| 2013 | } |
| 2014 | if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) { |
| 2015 | if (has_dynamic_front_face) { |
| 2016 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2017 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2018 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2019 | i); |
| 2020 | } |
| 2021 | has_dynamic_front_face = true; |
| 2022 | } |
| 2023 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) { |
| 2024 | if (has_dynamic_primitive_topology) { |
| 2025 | skip |= LogError( |
| 2026 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2027 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2028 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2029 | i); |
| 2030 | } |
| 2031 | has_dynamic_primitive_topology = true; |
| 2032 | } |
| 2033 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) { |
| 2034 | if (has_dynamic_viewport_with_count) { |
| 2035 | skip |= LogError( |
| 2036 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2037 | "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] | 2038 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2039 | i); |
| 2040 | } |
| 2041 | has_dynamic_viewport_with_count = true; |
| 2042 | } |
| 2043 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) { |
| 2044 | if (has_dynamic_scissor_with_count) { |
| 2045 | skip |= LogError( |
| 2046 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2047 | "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] | 2048 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2049 | i); |
| 2050 | } |
| 2051 | has_dynamic_scissor_with_count = true; |
| 2052 | } |
| 2053 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) { |
| 2054 | if (has_dynamic_vertex_input_binding_stride) { |
| 2055 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2056 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was " |
| 2057 | "listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2058 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2059 | i); |
| 2060 | } |
| 2061 | has_dynamic_vertex_input_binding_stride = true; |
| 2062 | } |
| 2063 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) { |
| 2064 | if (has_dynamic_depth_test_enable) { |
| 2065 | skip |= LogError( |
| 2066 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2067 | "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] | 2068 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2069 | i); |
| 2070 | } |
| 2071 | has_dynamic_depth_test_enable = true; |
| 2072 | } |
| 2073 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) { |
| 2074 | if (has_dynamic_depth_write_enable) { |
| 2075 | skip |= LogError( |
| 2076 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2077 | "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] | 2078 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2079 | i); |
| 2080 | } |
| 2081 | has_dynamic_depth_write_enable = true; |
| 2082 | } |
| 2083 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) { |
| 2084 | if (has_dynamic_depth_compare_op) { |
| 2085 | skip |= |
| 2086 | LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2087 | "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] | 2088 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2089 | i); |
| 2090 | } |
| 2091 | has_dynamic_depth_compare_op = true; |
| 2092 | } |
| 2093 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) { |
| 2094 | if (has_dynamic_depth_bounds_test_enable) { |
| 2095 | skip |= LogError( |
| 2096 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2097 | "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] | 2098 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2099 | i); |
| 2100 | } |
| 2101 | has_dynamic_depth_bounds_test_enable = true; |
| 2102 | } |
| 2103 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) { |
| 2104 | if (has_dynamic_stencil_test_enable) { |
| 2105 | skip |= LogError( |
| 2106 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2107 | "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] | 2108 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2109 | i); |
| 2110 | } |
| 2111 | has_dynamic_stencil_test_enable = true; |
| 2112 | } |
| 2113 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) { |
| 2114 | if (has_dynamic_stencil_op) { |
| 2115 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2116 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2117 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2118 | i); |
| 2119 | } |
| 2120 | has_dynamic_stencil_op = true; |
| 2121 | } |
sfricke-samsung | 5f8f970 | 2021-01-29 23:30:30 -0800 | [diff] [blame] | 2122 | if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) { |
| 2123 | // Not allowed for graphics pipelines |
| 2124 | skip |= LogError( |
| 2125 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578", |
| 2126 | "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] | 2127 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32 |
| 2128 | "] but not allowed in graphic pipelines.", |
sfricke-samsung | 5f8f970 | 2021-01-29 23:30:30 -0800 | [diff] [blame] | 2129 | i, state_index); |
| 2130 | } |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2131 | if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) { |
| 2132 | if (has_patch_control_points) { |
| 2133 | skip |= LogError( |
| 2134 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2135 | "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] | 2136 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2137 | i); |
| 2138 | } |
| 2139 | has_patch_control_points = true; |
| 2140 | } |
| 2141 | if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) { |
| 2142 | if (has_rasterizer_discard_enable) { |
| 2143 | skip |= LogError( |
| 2144 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2145 | "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] | 2146 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2147 | i); |
| 2148 | } |
| 2149 | has_rasterizer_discard_enable = true; |
| 2150 | } |
| 2151 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) { |
| 2152 | if (has_depth_bias_enable) { |
| 2153 | skip |= LogError( |
| 2154 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2155 | "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] | 2156 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2157 | i); |
| 2158 | } |
| 2159 | has_depth_bias_enable = true; |
| 2160 | } |
| 2161 | if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) { |
| 2162 | if (has_logic_op) { |
| 2163 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2164 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2165 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2166 | i); |
| 2167 | } |
| 2168 | has_logic_op = true; |
| 2169 | } |
| 2170 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) { |
| 2171 | if (has_primitive_restart_enable) { |
| 2172 | skip |= LogError( |
| 2173 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 2174 | "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] | 2175 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 2176 | i); |
| 2177 | } |
| 2178 | has_primitive_restart_enable = true; |
| 2179 | } |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 2180 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) { |
| 2181 | if (has_dynamic_vertex_input) { |
| 2182 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2183 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the " |
| 2184 | "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
| 2185 | i); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 2186 | } |
| 2187 | has_dynamic_vertex_input = true; |
| 2188 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2189 | } |
| 2190 | } |
| 2191 | |
sfricke-samsung | 3b94442 | 2021-01-23 02:15:19 -0800 | [diff] [blame] | 2192 | if (has_dynamic_viewport_with_count && has_dynamic_viewport) { |
| 2193 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132", |
| 2194 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2195 | "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32 |
| 2196 | "].pDynamicState->pDynamicStates array", |
sfricke-samsung | 3b94442 | 2021-01-23 02:15:19 -0800 | [diff] [blame] | 2197 | i); |
| 2198 | } |
| 2199 | |
| 2200 | if (has_dynamic_scissor_with_count && has_dynamic_scissor) { |
| 2201 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133", |
| 2202 | "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] | 2203 | "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array", |
sfricke-samsung | 3b94442 | 2021-01-23 02:15:19 -0800 | [diff] [blame] | 2204 | i); |
| 2205 | } |
| 2206 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2207 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext); |
| 2208 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) { |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 2209 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2210 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 2211 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 2212 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2213 | i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2214 | } |
| 2215 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2216 | // 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] | 2217 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2218 | // Collect active stages and other information |
| 2219 | // Only want to loop through pStages once |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2220 | uint32_t active_shaders = 0; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2221 | bool has_eval = false; |
| 2222 | bool has_control = false; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2223 | if (create_info.pStages != nullptr) { |
| 2224 | for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) { |
| 2225 | active_shaders |= create_info.pStages[stage_index].stage; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2226 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2227 | 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] | 2228 | has_control = true; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2229 | } 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] | 2230 | has_eval = true; |
| 2231 | } |
| 2232 | |
| 2233 | skip |= validate_string( |
| 2234 | "vkCreateGraphicsPipelines", |
| 2235 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}), |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 2236 | kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName); |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 2237 | |
| 2238 | std::stringstream msg; |
| 2239 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 2240 | ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2241 | &create_info.pStages[stage_index]); |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2242 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2243 | } |
| 2244 | |
| 2245 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2246 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) { |
| 2247 | skip |= |
| 2248 | validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 2249 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 2250 | create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 2251 | false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2252 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2253 | const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2254 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 2255 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2256 | skip |= validate_struct_pnext( |
| 2257 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2258 | "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2259 | ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info), |
| 2260 | allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion, |
| 2261 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 2262 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2263 | |
| 2264 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2265 | create_info.pTessellationState->flags, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2266 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 2267 | } |
| 2268 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2269 | 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] | 2270 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 2271 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2272 | create_info.pInputAssemblyState, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2273 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2274 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 2275 | |
| 2276 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2277 | create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2278 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2279 | |
| 2280 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2281 | create_info.pInputAssemblyState->flags, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2282 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 2283 | |
| 2284 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 2285 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2286 | create_info.pInputAssemblyState->topology, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2287 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 2288 | |
| 2289 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2290 | create_info.pInputAssemblyState->primitiveRestartEnable); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2291 | } |
| 2292 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2293 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) { |
| 2294 | auto const &vertex_input_state = create_info.pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2295 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2296 | if (create_info.pVertexInputState->flags != 0) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2297 | skip |= |
| 2298 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 2299 | "vkCreateGraphicsPipelines: pararameter " |
| 2300 | "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.", |
| 2301 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2302 | } |
| 2303 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2304 | const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2305 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2306 | skip |= |
| 2307 | validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 2308 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1, |
| 2309 | allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion, |
| 2310 | "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
| 2311 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2312 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 2313 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 2314 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2315 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 2316 | skip |= |
| 2317 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 2318 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2319 | create_info.pVertexInputState->vertexBindingDescriptionCount, |
| 2320 | &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2321 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 2322 | |
| 2323 | skip |= validate_array( |
| 2324 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 2325 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 2326 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 2327 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 2328 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2329 | if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2330 | for (uint32_t vertex_binding_description_index = 0; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2331 | vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2332 | ++vertex_binding_description_index) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2333 | skip |= validate_ranged_enum( |
| 2334 | "vkCreateGraphicsPipelines", |
| 2335 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 2336 | AllVkVertexInputRateEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2337 | create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2338 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 2339 | } |
| 2340 | } |
| 2341 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2342 | if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2343 | for (uint32_t vertex_attribute_description_index = 0; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2344 | vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2345 | ++vertex_attribute_description_index) { |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2346 | const VkFormat format = |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2347 | create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format; |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2348 | skip |= validate_ranged_enum( |
| 2349 | "vkCreateGraphicsPipelines", |
| 2350 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 2351 | AllVkFormatEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2352 | create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2353 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2354 | if (FormatIsDepthOrStencil(format)) { |
| 2355 | // Should never hopefully get here, but there are known driver advertising the wrong feature flags |
| 2356 | // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849 |
| 2357 | skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat, |
| 2358 | "vkCreateGraphicsPipelines: " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2359 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2360 | "].format is a " |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2361 | "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for " |
| 2362 | "alignment, replace with a color format.", |
| 2363 | i, vertex_attribute_description_index, string_VkFormat(format)); |
| 2364 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2365 | } |
| 2366 | } |
| 2367 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2368 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2369 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 2370 | "vkCreateGraphicsPipelines: pararameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2371 | "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32 |
| 2372 | ") is " |
| 2373 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2374 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2375 | } |
| 2376 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2377 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2378 | skip |= |
| 2379 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 2380 | "vkCreateGraphicsPipelines: pararameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2381 | "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32 |
| 2382 | ") is " |
| 2383 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2384 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2385 | } |
| 2386 | |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 2387 | layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2388 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 2389 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2390 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 2391 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2392 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 2393 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2394 | "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32 |
| 2395 | "].binding " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2396 | "(%" PRIu32 ") is not distinct.", |
| 2397 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2398 | } |
| 2399 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 2400 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2401 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2402 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 2403 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2404 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32 |
| 2405 | "].binding (%" PRIu32 |
| 2406 | ") is " |
| 2407 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2408 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2409 | } |
| 2410 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2411 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2412 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 2413 | "vkCreateGraphicsPipelines: parameter " |
| 2414 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32 |
| 2415 | "].stride (%" PRIu32 |
| 2416 | ") is greater " |
| 2417 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").", |
| 2418 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2419 | } |
| 2420 | } |
| 2421 | |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 2422 | layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2423 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 2424 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2425 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 2426 | if (location_it != attribute_locations.cend()) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2427 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
| 2428 | "vkCreateGraphicsPipelines: parameter " |
| 2429 | "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32 |
| 2430 | "].location (%" PRIu32 ") is not distinct.", |
| 2431 | i, d, vertex_attrib_desc.location); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2432 | } |
| 2433 | attribute_locations.insert(vertex_attrib_desc.location); |
| 2434 | |
| 2435 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 2436 | if (binding_it == vertex_bindings.cend()) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2437 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
| 2438 | "vkCreateGraphicsPipelines: parameter " |
| 2439 | " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32 |
| 2440 | "].binding (%" PRIu32 |
| 2441 | ") does not exist " |
| 2442 | "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.", |
| 2443 | i, d, vertex_attrib_desc.binding, i); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2444 | } |
| 2445 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2446 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2447 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 2448 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2449 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2450 | "].location (%" PRIu32 |
| 2451 | ") is " |
| 2452 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2453 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2454 | } |
| 2455 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2456 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2457 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 2458 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2459 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2460 | "].binding (%" PRIu32 |
| 2461 | ") is " |
| 2462 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2463 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2464 | } |
| 2465 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2466 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2467 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 2468 | "vkCreateGraphicsPipelines: parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2469 | "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32 |
| 2470 | "].offset (%" PRIu32 |
| 2471 | ") is " |
| 2472 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2473 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2474 | } |
| 2475 | } |
| 2476 | } |
| 2477 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2478 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 2479 | if (has_control && has_eval) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2480 | if (create_info.pTessellationState == nullptr) { |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2481 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2482 | "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32 |
| 2483 | "].pStages includes a tessellation control " |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2484 | "shader stage and a tessellation evaluation shader stage, " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2485 | "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.", |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2486 | i, i); |
| 2487 | } else { |
| 2488 | const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
| 2489 | skip |= validate_struct_pnext( |
| 2490 | "vkCreateGraphicsPipelines", |
| 2491 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2492 | "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1, |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2493 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 2494 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2495 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2496 | skip |= validate_reserved_flags( |
| 2497 | "vkCreateGraphicsPipelines", |
| 2498 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2499 | create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2500 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2501 | if (create_info.pTessellationState->patchControlPoints == 0 || |
| 2502 | create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
| 2503 | skip |= |
| 2504 | LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 2505 | "vkCreateGraphicsPipelines: invalid parameter " |
| 2506 | "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32 |
| 2507 | ". patchControlPoints " |
| 2508 | "should be >0 and <=%" PRIu32 ".", |
| 2509 | i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2510 | } |
| 2511 | } |
| 2512 | } |
| 2513 | |
| 2514 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2515 | if ((create_info.pRasterizationState != nullptr) && |
| 2516 | (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 2517 | if (create_info.pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2518 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 2519 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 2520 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 2521 | "].pViewportState (=NULL) is not a valid pointer.", |
| 2522 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2523 | } else { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2524 | const auto &viewport_state = *create_info.pViewportState; |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2525 | |
| 2526 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2527 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 2528 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2529 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 2530 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2531 | } |
| 2532 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2533 | const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2534 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2535 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 2536 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2537 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 2538 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2539 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2540 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2541 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2542 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2543 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2544 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 2545 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2546 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2547 | 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] | 2548 | allowed_structs_vk_pipeline_viewport_state_create_info, 200, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2549 | "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2550 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2551 | |
| 2552 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2553 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2554 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2555 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2556 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2557 | auto exclusive_scissor_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2558 | LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2559 | auto shading_rate_image_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2560 | LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2561 | auto coarse_sample_order_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2562 | LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext); |
| 2563 | const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2564 | const auto vp_w_scaling_struct = |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2565 | LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext); |
| 2566 | const auto depth_clip_control_struct = |
| 2567 | LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2568 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2569 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2570 | if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2571 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 2572 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2573 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 2574 | ") is not 1.", |
| 2575 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2576 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2577 | |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2578 | if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2579 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 2580 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2581 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2582 | ") is not 1.", |
| 2583 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2584 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2585 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2586 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 2587 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2588 | skip |= LogError( |
| 2589 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 2590 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2591 | "disabled, but pCreateInfos[%" PRIu32 |
| 2592 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 2593 | ") is not 1.", |
| 2594 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2595 | } |
| 2596 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2597 | if (shading_rate_image_struct && |
| 2598 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2599 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 2600 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2601 | "disabled, but pCreateInfos[%" PRIu32 |
| 2602 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 2603 | ") is neither 0 nor 1.", |
| 2604 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2605 | } |
| 2606 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2607 | } else { // multiViewport enabled |
| 2608 | if (viewport_state.viewportCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2609 | if (!has_dynamic_viewport_with_count) { |
| 2610 | skip |= LogError( |
| 2611 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
| 2612 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
| 2613 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2614 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2615 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 2616 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2617 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2618 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2619 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2620 | } else if (has_dynamic_viewport_with_count) { |
| 2621 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379", |
| 2622 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2623 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2624 | ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.", |
| 2625 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2626 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2627 | |
| 2628 | if (viewport_state.scissorCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2629 | if (!has_dynamic_scissor_with_count) { |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2630 | const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) |
| 2631 | ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136" |
| 2632 | : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength"; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2633 | skip |= LogError( |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2634 | device, vuid, |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2635 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
| 2636 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2637 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2638 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 2639 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2640 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2641 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2642 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2643 | } else if (has_dynamic_scissor_with_count) { |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2644 | const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) |
| 2645 | ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136" |
| 2646 | : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380"; |
| 2647 | skip |= LogError(device, vuid, |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2648 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2649 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2650 | ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.", |
| 2651 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2652 | } |
| 2653 | } |
| 2654 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2655 | if (!has_dynamic_scissor && viewport_state.pScissors) { |
| 2656 | for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) { |
| 2657 | const auto &scissor = viewport_state.pScissors[scissor_i]; |
ziga-lunarg | a77dc80 | 2021-07-15 13:19:06 +0200 | [diff] [blame] | 2658 | |
| 2659 | if (scissor.offset.x < 0) { |
| 2660 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821", |
| 2661 | "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32 |
| 2662 | "].pViewportState->pScissors[%" PRIu32 "] is negative.", |
| 2663 | scissor.offset.x, i, scissor_i); |
| 2664 | } |
| 2665 | |
| 2666 | if (scissor.offset.y < 0) { |
| 2667 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821", |
| 2668 | "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32 |
| 2669 | "].pViewportState->pScissors[%" PRIu32 "] is negative.", |
| 2670 | scissor.offset.y, i, scissor_i); |
| 2671 | } |
| 2672 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2673 | const int64_t x_sum = |
| 2674 | static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 2675 | if (x_sum > std::numeric_limits<int32_t>::max()) { |
| 2676 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822", |
| 2677 | "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 |
| 2678 | " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32 |
| 2679 | "] will overflow int32_t.", |
| 2680 | scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i); |
| 2681 | } |
ziga-lunarg | a77dc80 | 2021-07-15 13:19:06 +0200 | [diff] [blame] | 2682 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2683 | const int64_t y_sum = |
| 2684 | static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 2685 | if (y_sum > std::numeric_limits<int32_t>::max()) { |
| 2686 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823", |
| 2687 | "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 |
| 2688 | " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32 |
| 2689 | "] will overflow int32_t.", |
| 2690 | scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i); |
| 2691 | } |
| 2692 | } |
| 2693 | } |
| 2694 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2695 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2696 | skip |= |
| 2697 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 2698 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2699 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2700 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2701 | } |
| 2702 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2703 | 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] | 2704 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 2705 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2706 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2707 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2708 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2709 | } |
| 2710 | |
ziga-lunarg | 0f0d658 | 2022-03-13 16:17:40 +0100 | [diff] [blame] | 2711 | if (viewport_state.scissorCount != viewport_state.viewportCount) { |
| 2712 | if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) || |
| 2713 | (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) { |
| 2714 | const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) |
| 2715 | ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134" |
| 2716 | : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220"; |
| 2717 | skip |= LogError( |
| 2718 | device, vuid, |
| 2719 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2720 | ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2721 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
| 2722 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2723 | } |
| 2724 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2725 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2726 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2727 | skip |= |
| 2728 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 2729 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2730 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 2731 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2732 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2733 | } |
| 2734 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2735 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2736 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2737 | skip |= LogError( |
| 2738 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2739 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 2740 | "] " |
| 2741 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2742 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2743 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2744 | } |
| 2745 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2746 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2747 | skip |= LogError( |
| 2748 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2749 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 2750 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2751 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 2752 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2753 | } |
| 2754 | |
| 2755 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2756 | skip |= LogError( |
| 2757 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2758 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 2759 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2760 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 2761 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2762 | } |
| 2763 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2764 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2765 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 2766 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 2767 | skip |= |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2768 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2769 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 2770 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 2771 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 2772 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2773 | } |
| 2774 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2775 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2776 | shading_rate_image_struct->viewportCount > 0 && |
| 2777 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2778 | skip |= LogError( |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2779 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2780 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2781 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 2782 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2783 | i, i); |
| 2784 | } |
| 2785 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2786 | if (vp_swizzle_struct) { |
| 2787 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2788 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 2789 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 2790 | " does " |
| 2791 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 2792 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2793 | } |
| 2794 | } |
| 2795 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2796 | // validate the VkViewports |
| 2797 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 2798 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 2799 | 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] | 2800 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 2801 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 2802 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 2803 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2804 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2805 | } |
| 2806 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2807 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2808 | 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] | 2809 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2810 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2811 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 2812 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 2813 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2814 | } |
| 2815 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2816 | 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] | 2817 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2818 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2819 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 2820 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 2821 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2822 | } |
| 2823 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2824 | 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] | 2825 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2826 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2827 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 2828 | "VK_EXT_sample_locations extension is not enabled.", |
| 2829 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2830 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2831 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2832 | 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] | 2833 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2834 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2835 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 2836 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 2837 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2838 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2839 | |
| 2840 | if (coarse_sample_order_struct && |
| 2841 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 2842 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2843 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 2844 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2845 | "] " |
| 2846 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 2847 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 2848 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2849 | } |
| 2850 | |
| 2851 | if (coarse_sample_order_struct) { |
| 2852 | 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] | 2853 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2854 | } |
| 2855 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2856 | |
| 2857 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 2858 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2859 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 2860 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2861 | "] " |
| 2862 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 2863 | ") " |
| 2864 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 2865 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2866 | } |
| 2867 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2868 | skip |= LogError( |
| 2869 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2870 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2871 | "] " |
| 2872 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 2873 | i); |
| 2874 | } |
| 2875 | } |
sfricke-samsung | e6669ec | 2021-11-29 23:33:03 -0600 | [diff] [blame] | 2876 | |
| 2877 | if (depth_clip_control_struct) { |
| 2878 | const auto *depth_clip_control_features = |
| 2879 | LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext); |
| 2880 | const bool enabled_depth_clip_control = |
| 2881 | depth_clip_control_features && depth_clip_control_features->depthClipControl; |
| 2882 | if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) { |
| 2883 | skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470", |
| 2884 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2885 | "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the " |
| 2886 | "depthClipControl feature is not enabled. ", |
| 2887 | i); |
| 2888 | } |
| 2889 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2890 | } |
| 2891 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2892 | const bool is_frag_out_graphics_lib = |
| 2893 | graphics_lib_info && |
| 2894 | ((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] | 2895 | if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2896 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2897 | "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32 |
| 2898 | "].pRasterizationState->rasterizerDiscardEnable " |
| 2899 | "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2900 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2901 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2902 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 2903 | LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType, |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2904 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 2905 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 2906 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2907 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2908 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2909 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2910 | // 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] | 2911 | if (create_info.pMultisampleState) { |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2912 | skip |= validate_struct_pnext( |
| 2913 | "vkCreateGraphicsPipelines", |
| 2914 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2915 | valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes, |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2916 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 2917 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2918 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2919 | skip |= validate_reserved_flags( |
| 2920 | "vkCreateGraphicsPipelines", |
| 2921 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2922 | create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2923 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2924 | skip |= validate_bool32( |
| 2925 | "vkCreateGraphicsPipelines", |
| 2926 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2927 | create_info.pMultisampleState->sampleShadingEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2928 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2929 | skip |= validate_array( |
| 2930 | "vkCreateGraphicsPipelines", |
| 2931 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", |
| 2932 | ParameterName::IndexVector{i}), |
| 2933 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2934 | create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true, |
| 2935 | false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2936 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2937 | skip |= validate_flags("vkCreateGraphicsPipelines", |
| 2938 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", |
| 2939 | ParameterName::IndexVector{i}), |
| 2940 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2941 | create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit, |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2942 | "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2943 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2944 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
| 2945 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", |
| 2946 | ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2947 | create_info.pMultisampleState->alphaToCoverageEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2948 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2949 | skip |= validate_bool32( |
| 2950 | "vkCreateGraphicsPipelines", |
| 2951 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2952 | create_info.pMultisampleState->alphaToOneEnable); |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2953 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2954 | 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] | 2955 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType", |
| 2956 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32 |
| 2957 | "].pMultisampleState->sType must be " |
| 2958 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2959 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2960 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2961 | if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2962 | if (!physical_device_features.sampleRateShading) { |
| 2963 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 2964 | "vkCreateGraphicsPipelines(): parameter " |
| 2965 | "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.", |
| 2966 | i); |
| 2967 | } |
| 2968 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 2969 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2970 | if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2971 | skip |= LogError(device, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2972 | |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 2973 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
| 2974 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32 |
| 2975 | "].pMultisampleState->minSampleShading.", |
| 2976 | i); |
| 2977 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2978 | } |
| 2979 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2980 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2981 | const auto *line_state = |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2982 | LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2983 | |
| 2984 | if (line_state) { |
| 2985 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 2986 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2987 | if (create_info.pMultisampleState->alphaToCoverageEnable) { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2988 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2989 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2990 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2991 | "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2992 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2993 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 2994 | if (create_info.pMultisampleState->alphaToOneEnable) { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2995 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2996 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2997 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 2998 | "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2999 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3000 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3001 | if (create_info.pMultisampleState->sampleShadingEnable) { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3002 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3003 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 3004 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3005 | "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3006 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3007 | } |
| 3008 | } |
| 3009 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 3010 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 3011 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3012 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3013 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32 |
| 3014 | " must be in the " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3015 | "range [1,256].", |
| 3016 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3017 | } |
| 3018 | } |
| 3019 | const auto *line_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3020 | LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3021 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 3022 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3023 | skip |= |
| 3024 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3025 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3026 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3027 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 3028 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3029 | } |
| 3030 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 3031 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3032 | skip |= |
| 3033 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3034 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3035 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3036 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 3037 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3038 | } |
| 3039 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 3040 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3041 | skip |= |
| 3042 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3043 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3044 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3045 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 3046 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3047 | } |
| 3048 | if (line_state->stippledLineEnable) { |
| 3049 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 3050 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3051 | skip |= |
| 3052 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3053 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3054 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3055 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 3056 | "stippledRectangularLines feature.", |
| 3057 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3058 | } |
| 3059 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 3060 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3061 | skip |= |
| 3062 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3063 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3064 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3065 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 3066 | "stippledBresenhamLines feature.", |
| 3067 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3068 | } |
| 3069 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 3070 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3071 | skip |= |
| 3072 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3073 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3074 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3075 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 3076 | "stippledSmoothLines feature.", |
| 3077 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3078 | } |
| 3079 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
Malcolm Bechard | fc50900 | 2021-11-17 21:57:28 -0500 | [diff] [blame] | 3080 | (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3081 | skip |= |
| 3082 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3083 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3084 | "] lineRasterizationMode = " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3085 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 3086 | "stippledRectangularLines and strictLines features.", |
| 3087 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3088 | } |
| 3089 | } |
| 3090 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3091 | } |
| 3092 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3093 | bool uses_color_attachment = false; |
| 3094 | bool uses_depthstencil_attachment = false; |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3095 | VkSubpassDescriptionFlags subpass_flags = 0; |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3096 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 3097 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3098 | const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3099 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3100 | const auto &subpasses_uses = subpasses_uses_it->second; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3101 | if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3102 | uses_color_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3103 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3104 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3105 | uses_depthstencil_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3106 | } |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3107 | subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass]; |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3108 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 3109 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 3110 | } |
| 3111 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3112 | if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3113 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3114 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3115 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3116 | create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 3117 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3118 | |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3119 | skip |= |
| 3120 | validate_flags("vkCreateGraphicsPipelines", |
| 3121 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
| 3122 | "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3123 | create_info.pDepthStencilState->flags, kOptionalFlags, |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3124 | "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3125 | |
| 3126 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3127 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3128 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3129 | create_info.pDepthStencilState->depthTestEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3130 | |
| 3131 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3132 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3133 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3134 | create_info.pDepthStencilState->depthWriteEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3135 | |
| 3136 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3137 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3138 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3139 | "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3140 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3141 | |
| 3142 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3143 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3144 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3145 | create_info.pDepthStencilState->depthBoundsTestEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3146 | |
| 3147 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3148 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3149 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3150 | create_info.pDepthStencilState->stencilTestEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3151 | |
| 3152 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3153 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3154 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3155 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3156 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3157 | |
| 3158 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3159 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3160 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3161 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3162 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3163 | |
| 3164 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3165 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3166 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3167 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3168 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3169 | |
| 3170 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3171 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3172 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3173 | "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3174 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3175 | |
| 3176 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3177 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3178 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3179 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3180 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3181 | |
| 3182 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3183 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3184 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3185 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3186 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3187 | |
| 3188 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3189 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3190 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3191 | "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3192 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3193 | |
| 3194 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3195 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3196 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3197 | "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3198 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3199 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3200 | 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] | 3201 | skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3202 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32 |
| 3203 | "].pDepthStencilState->sType must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3204 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 3205 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3206 | } |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3207 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3208 | if ((create_info.pDepthStencilState->flags & |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3209 | VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) { |
| 3210 | const auto *rasterization_order_attachment_access_feature = |
| 3211 | LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext); |
| 3212 | const bool rasterization_order_depth_attachment_access_feature_enabled = |
| 3213 | rasterization_order_attachment_access_feature && |
| 3214 | rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE; |
| 3215 | if (!rasterization_order_depth_attachment_access_feature_enabled) { |
| 3216 | skip |= LogError( |
| 3217 | device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463", |
| 3218 | "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::" |
| 3219 | "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but " |
| 3220 | "VkPipelineDepthStencilStateCreateInfo::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3221 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3222 | } |
| 3223 | |
| 3224 | if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) { |
| 3225 | skip |= LogError( |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 3226 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485", |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3227 | "VkPipelineDepthStencilStateCreateInfo::flags == %s but " |
| 3228 | "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3229 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(), |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3230 | string_VkSubpassDescriptionFlags(subpass_flags).c_str()); |
| 3231 | } |
| 3232 | } |
| 3233 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3234 | if ((create_info.pDepthStencilState->flags & |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3235 | VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) { |
| 3236 | const auto *rasterization_order_attachment_access_feature = |
| 3237 | LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext); |
| 3238 | const bool rasterization_order_stencil_attachment_access_feature_enabled = |
| 3239 | rasterization_order_attachment_access_feature && |
| 3240 | rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE; |
| 3241 | if (!rasterization_order_stencil_attachment_access_feature_enabled) { |
| 3242 | skip |= LogError( |
| 3243 | device, |
| 3244 | "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464", |
| 3245 | "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::" |
| 3246 | "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but " |
| 3247 | "VkPipelineDepthStencilStateCreateInfo::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3248 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3249 | } |
| 3250 | |
| 3251 | if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) { |
| 3252 | skip |= LogError( |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 3253 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486", |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3254 | "VkPipelineDepthStencilStateCreateInfo::flags == %s but " |
| 3255 | "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3256 | string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(), |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3257 | string_VkSubpassDescriptionFlags(subpass_flags).c_str()); |
| 3258 | } |
| 3259 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3260 | } |
| 3261 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3262 | const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = { |
ziga-lunarg | 8de0916 | 2021-08-05 15:21:33 +0200 | [diff] [blame] | 3263 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT, |
| 3264 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT}; |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 3265 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3266 | if (create_info.pColorBlendState != nullptr && uses_color_attachment) { |
| 3267 | skip |= |
| 3268 | validate_struct_type("vkCreateGraphicsPipelines", |
| 3269 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 3270 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 3271 | create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, |
| 3272 | false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 3273 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3274 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3275 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 3276 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3277 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", |
| 3278 | 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] | 3279 | allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 3280 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 3281 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3282 | |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3283 | skip |= validate_flags("vkCreateGraphicsPipelines", |
| 3284 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
| 3285 | "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3286 | create_info.pColorBlendState->flags, kOptionalFlags, |
Mike Schuchardt | 00e8145 | 2021-11-29 11:11:20 -0800 | [diff] [blame] | 3287 | "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3288 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3289 | if ((create_info.pColorBlendState->flags & |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3290 | VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) { |
| 3291 | const auto *rasterization_order_attachment_access_feature = |
| 3292 | LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext); |
| 3293 | const bool rasterization_order_color_attachment_access_feature_enabled = |
| 3294 | rasterization_order_attachment_access_feature && |
| 3295 | rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE; |
| 3296 | |
| 3297 | if (!rasterization_order_color_attachment_access_feature_enabled) { |
| 3298 | skip |= LogError( |
| 3299 | device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465", |
| 3300 | "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::" |
| 3301 | "rasterizationColorAttachmentAccess == VK_FALSE, but " |
| 3302 | "VkPipelineColorBlendStateCreateInfo::flags == %s", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3303 | string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3304 | } |
| 3305 | |
| 3306 | 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] | 3307 | skip |= |
| 3308 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484", |
| 3309 | "VkPipelineColorBlendStateCreateInfo::flags == %s but " |
| 3310 | "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s", |
| 3311 | string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(), |
| 3312 | string_VkSubpassDescriptionFlags(subpass_flags).c_str()); |
Younggwan Kim | 26b9abd | 2021-12-07 21:22:03 +0000 | [diff] [blame] | 3313 | } |
| 3314 | } |
| 3315 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3316 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3317 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3318 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3319 | create_info.pColorBlendState->logicOpEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3320 | |
| 3321 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3322 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3323 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 3324 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3325 | create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true, |
| 3326 | kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3327 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3328 | if (create_info.pColorBlendState->pAttachments != NULL) { |
| 3329 | for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3330 | ++attachment_index) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3331 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3332 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3333 | ParameterName::IndexVector{i, attachment_index}), |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3334 | create_info.pColorBlendState->pAttachments[attachment_index].blendEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3335 | |
| 3336 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3337 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3338 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3339 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3340 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3341 | create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3342 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3343 | |
| 3344 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3345 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3346 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3347 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3348 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3349 | create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3350 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3351 | |
| 3352 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3353 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3354 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3355 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3356 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3357 | create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3358 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3359 | |
| 3360 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3361 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3362 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3363 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3364 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3365 | create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3366 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3367 | |
| 3368 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3369 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3370 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3371 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3372 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3373 | create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3374 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3375 | |
| 3376 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3377 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3378 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3379 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3380 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3381 | create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3382 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3383 | |
| 3384 | skip |= |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3385 | validate_flags("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3386 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3387 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3388 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3389 | create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 3390 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 3391 | |
| 3392 | if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) { |
| 3393 | bool invalid = false; |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3394 | switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) { |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 3395 | case VK_BLEND_OP_ZERO_EXT: |
| 3396 | case VK_BLEND_OP_SRC_EXT: |
| 3397 | case VK_BLEND_OP_DST_EXT: |
| 3398 | case VK_BLEND_OP_SRC_OVER_EXT: |
| 3399 | case VK_BLEND_OP_DST_OVER_EXT: |
| 3400 | case VK_BLEND_OP_SRC_IN_EXT: |
| 3401 | case VK_BLEND_OP_DST_IN_EXT: |
| 3402 | case VK_BLEND_OP_SRC_OUT_EXT: |
| 3403 | case VK_BLEND_OP_DST_OUT_EXT: |
| 3404 | case VK_BLEND_OP_SRC_ATOP_EXT: |
| 3405 | case VK_BLEND_OP_DST_ATOP_EXT: |
| 3406 | case VK_BLEND_OP_XOR_EXT: |
| 3407 | case VK_BLEND_OP_INVERT_EXT: |
| 3408 | case VK_BLEND_OP_INVERT_RGB_EXT: |
| 3409 | case VK_BLEND_OP_LINEARDODGE_EXT: |
| 3410 | case VK_BLEND_OP_LINEARBURN_EXT: |
| 3411 | case VK_BLEND_OP_VIVIDLIGHT_EXT: |
| 3412 | case VK_BLEND_OP_LINEARLIGHT_EXT: |
| 3413 | case VK_BLEND_OP_PINLIGHT_EXT: |
| 3414 | case VK_BLEND_OP_HARDMIX_EXT: |
| 3415 | case VK_BLEND_OP_PLUS_EXT: |
| 3416 | case VK_BLEND_OP_PLUS_CLAMPED_EXT: |
| 3417 | case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT: |
| 3418 | case VK_BLEND_OP_PLUS_DARKER_EXT: |
| 3419 | case VK_BLEND_OP_MINUS_EXT: |
| 3420 | case VK_BLEND_OP_MINUS_CLAMPED_EXT: |
| 3421 | case VK_BLEND_OP_CONTRAST_EXT: |
| 3422 | case VK_BLEND_OP_INVERT_OVG_EXT: |
| 3423 | case VK_BLEND_OP_RED_EXT: |
| 3424 | case VK_BLEND_OP_GREEN_EXT: |
| 3425 | case VK_BLEND_OP_BLUE_EXT: |
| 3426 | invalid = true; |
| 3427 | break; |
| 3428 | default: |
| 3429 | break; |
| 3430 | } |
| 3431 | if (invalid) { |
| 3432 | skip |= LogError( |
| 3433 | device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409", |
| 3434 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 3435 | "].pColorBlendState->pAttachments[%" PRIu32 |
| 3436 | "].colorBlendOp (%s) is not valid when " |
| 3437 | "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is " |
| 3438 | "VK_FALSE", |
| 3439 | i, attachment_index, |
| 3440 | string_VkBlendOp( |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3441 | create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp)); |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 3442 | } |
| 3443 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3444 | } |
| 3445 | } |
| 3446 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3447 | 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] | 3448 | skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3449 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32 |
| 3450 | "].pColorBlendState->sType must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3451 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 3452 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3453 | } |
| 3454 | |
| 3455 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3456 | if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3457 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3458 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3459 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3460 | AllVkLogicOpEnums, create_info.pColorBlendState->logicOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3461 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3462 | } |
| 3463 | } |
| 3464 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3465 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3466 | const VkPipelineCreateFlags flags = create_info.flags; |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3467 | if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3468 | if (create_info.basePipelineIndex != -1) { |
| 3469 | if (create_info.basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3470 | skip |= |
| 3471 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3472 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32 |
| 3473 | "]->basePipelineHandle, must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3474 | "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] | 3475 | "and pCreateInfos->basePipelineIndex is not -1.", |
| 3476 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3477 | } |
| 3478 | } |
| 3479 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3480 | if (create_info.basePipelineHandle != VK_NULL_HANDLE) { |
| 3481 | if (create_info.basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3482 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3483 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32 |
| 3484 | "]->basePipelineIndex, must be -1 if " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3485 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3486 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 3487 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3488 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 3489 | } else { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3490 | if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) { |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3491 | skip |= |
| 3492 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3493 | "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32 |
| 3494 | ") must be a valid" |
| 3495 | "index into the pCreateInfos array, of size %" PRIu32 ".", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3496 | i, create_info.basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 3497 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3498 | } |
| 3499 | } |
| 3500 | |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3501 | if (create_info.pRasterizationState) { |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3502 | if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3503 | if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3504 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3505 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 3506 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 3507 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 3508 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3509 | } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3510 | (physical_device_features.fillModeNonSolid == false)) { |
sfricke-samsung | a44586f | 2020-08-23 22:19:44 -0700 | [diff] [blame] | 3511 | skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3512 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3513 | "pCreateInfos[%" PRIu32 |
| 3514 | "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3515 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 3516 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3517 | } |
| 3518 | } else { |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3519 | if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 3520 | (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3521 | (physical_device_features.fillModeNonSolid == false)) { |
| 3522 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3523 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 3524 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3525 | "pCreateInfos[%" PRIu32 |
| 3526 | "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3527 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 3528 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3529 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3530 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3531 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3532 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3533 | (create_info.pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3534 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 3535 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 3536 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 3537 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 3538 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
Nathaniel Cesario | 66ca398 | 2022-03-01 15:51:11 -0700 | [diff] [blame] | 3539 | i, i, create_info.pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3540 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3541 | } |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3542 | |
| 3543 | // Validate no flags not allowed are used |
| 3544 | if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) { |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3545 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3546 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3547 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3548 | "VK_PIPELINE_CREATE_DISPATCH_BASE.", |
| 3549 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3550 | } |
Nathaniel Cesario | 81257cb | 2022-02-16 17:15:58 -0700 | [diff] [blame] | 3551 | if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) && |
| 3552 | (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) { |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3553 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3554 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3555 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3556 | "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.", |
| 3557 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3558 | } |
| 3559 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) { |
| 3560 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3561 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3562 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3563 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.", |
| 3564 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3565 | } |
| 3566 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) { |
| 3567 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3568 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3569 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3570 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.", |
| 3571 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3572 | } |
| 3573 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) { |
| 3574 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3575 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3576 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3577 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.", |
| 3578 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3579 | } |
| 3580 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) { |
| 3581 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3582 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3583 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3584 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.", |
| 3585 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3586 | } |
| 3587 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) { |
| 3588 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3589 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3590 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3591 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.", |
| 3592 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3593 | } |
| 3594 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) { |
| 3595 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3596 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3597 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3598 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.", |
| 3599 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3600 | } |
| 3601 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) { |
| 3602 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3603 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3604 | "]->flags (0x%x) must not include " |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3605 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.", |
| 3606 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3607 | } |
ziga-lunarg | 4bd42e4 | 2021-10-04 13:19:29 +0200 | [diff] [blame] | 3608 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) { |
| 3609 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947", |
| 3610 | "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 |
| 3611 | "]->flags (0x%x) must not include " |
| 3612 | "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.", |
| 3613 | i, flags); |
| 3614 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3615 | } |
| 3616 | } |
| 3617 | |
| 3618 | return skip; |
| 3619 | } |
| 3620 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3621 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 3622 | uint32_t createInfoCount, |
| 3623 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 3624 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3625 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3626 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3627 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3628 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3629 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 3630 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3631 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Nathaniel Cesario | 29e1240 | 2022-03-14 09:45:23 -0600 | [diff] [blame] | 3632 | if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
| 3633 | const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount; |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 3634 | if ((feedback_count != 0) && (feedback_count != 1)) { |
Nathaniel Cesario | 29e1240 | 2022-03-14 09:45:23 -0600 | [diff] [blame] | 3635 | skip |= LogError( |
| 3636 | device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566", |
| 3637 | "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32 |
| 3638 | ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].", |
| 3639 | feedback_count, i); |
| 3640 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 3641 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 3642 | |
| 3643 | // Make sure compute stage is selected |
| 3644 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3645 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3646 | "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32 |
| 3647 | "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3648 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 3649 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3650 | |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3651 | const VkPipelineCreateFlags flags = pCreateInfos[i].flags; |
| 3652 | // Validate no flags not allowed are used |
| 3653 | if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3654 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364", |
| 3655 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3656 | "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.", |
| 3657 | i, flags); |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3658 | } |
| 3659 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) { |
| 3660 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3661 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3662 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3663 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.", |
| 3664 | i, flags); |
| 3665 | } |
| 3666 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) { |
| 3667 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3668 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3669 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3670 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.", |
| 3671 | i, flags); |
| 3672 | } |
| 3673 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) { |
| 3674 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3675 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3676 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3677 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.", |
| 3678 | i, flags); |
| 3679 | } |
| 3680 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) { |
| 3681 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3682 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3683 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3684 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.", |
| 3685 | i, flags); |
| 3686 | } |
| 3687 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) { |
| 3688 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3689 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3690 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3691 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.", |
| 3692 | i, flags); |
| 3693 | } |
| 3694 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) { |
| 3695 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3696 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3697 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3698 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.", |
| 3699 | i, flags); |
| 3700 | } |
| 3701 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) { |
| 3702 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3703 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3704 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3705 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.", |
| 3706 | i, flags); |
| 3707 | } |
ziga-lunarg | f51e65f | 2021-07-18 23:51:57 +0200 | [diff] [blame] | 3708 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) { |
| 3709 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3710 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3711 | "]->flags (0x%x) must not include " |
ziga-lunarg | f51e65f | 2021-07-18 23:51:57 +0200 | [diff] [blame] | 3712 | "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.", |
| 3713 | i, flags); |
| 3714 | } |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3715 | if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) { |
| 3716 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 3717 | "vkCreateComputePipelines(): pCreateInfos[%" PRIu32 |
| 3718 | "]->flags (0x%x) must not include " |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3719 | "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.", |
| 3720 | i, flags); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3721 | } |
ziga-lunarg | 065f240 | 2021-07-22 11:56:05 +0200 | [diff] [blame] | 3722 | if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 3723 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 3724 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 3725 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699", |
| 3726 | "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32 |
| 3727 | "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the " |
| 3728 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.", |
| 3729 | i); |
| 3730 | } |
| 3731 | } |
| 3732 | |
| 3733 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 3734 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 3735 | skip |= LogError( |
| 3736 | device, "VUID-VkComputePipelineCreateInfo-flags-00700", |
| 3737 | "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32 |
| 3738 | "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT " |
| 3739 | "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 3740 | i); |
| 3741 | } |
| 3742 | } else { |
| 3743 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
| 3744 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698", |
| 3745 | "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32 |
| 3746 | ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".", |
| 3747 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 3748 | } |
| 3749 | } |
| 3750 | } |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 3751 | |
| 3752 | std::stringstream msg; |
| 3753 | msg << "pCreateInfos[%" << i << "].stage"; |
| 3754 | ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3755 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3756 | return skip; |
| 3757 | } |
| 3758 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3759 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3760 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3761 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3762 | |
| 3763 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3764 | const auto &features = physical_device_features; |
| 3765 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3766 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3767 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 3768 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3769 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 3770 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 3771 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 3772 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3773 | } |
| 3774 | |
| 3775 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 3776 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3777 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 3778 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 3779 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3780 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3781 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3782 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3783 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 3784 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3785 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 3786 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3787 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 3788 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3789 | } |
| 3790 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3791 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 3792 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3793 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 3794 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3795 | } |
| 3796 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3797 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 3798 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3799 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 3800 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3801 | } |
| 3802 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 3803 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 3804 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 3805 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3806 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 3807 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3808 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 3809 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 3810 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 3811 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3812 | } |
| 3813 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3814 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 3815 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 3816 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3817 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3818 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3819 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 3820 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 3821 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3822 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3823 | } |
| 3824 | |
| 3825 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 3826 | const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3827 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3828 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 3829 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 3830 | if (sampler_reduction != nullptr) { |
| 3831 | if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
sjfricke | 751b709 | 2022-04-12 21:49:37 +0900 | [diff] [blame] | 3832 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423", |
| 3833 | "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be " |
| 3834 | "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE."); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 3835 | } |
| 3836 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3837 | } |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 3838 | if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
sjfricke | 751b709 | 2022-04-12 21:49:37 +0900 | [diff] [blame] | 3839 | if (!IsExtEnabled(device_extensions.vk_ext_sampler_filter_minmax)) { |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 3840 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-pNext-06726", |
sjfricke | 751b709 | 2022-04-12 21:49:37 +0900 | [diff] [blame] | 3841 | "vkCreateSampler(): sampler reduction mode is %s, but extension %s is not enabled.", |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 3842 | string_VkSamplerReductionMode(sampler_reduction->reductionMode), |
| 3843 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 3844 | } |
ziga-lunarg | 01be97a | 2022-05-01 14:30:39 +0200 | [diff] [blame^] | 3845 | |
| 3846 | if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) { |
| 3847 | if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) { |
| 3848 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422", |
| 3849 | "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but " |
| 3850 | "extension %s is not enabled.", |
| 3851 | string_VkSamplerReductionMode(sampler_reduction->reductionMode), |
| 3852 | string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter), |
| 3853 | VK_EXT_FILTER_CUBIC_EXTENSION_NAME); |
| 3854 | } |
| 3855 | } |
ziga-lunarg | 9fc3e9b | 2022-04-11 12:04:56 +0200 | [diff] [blame] | 3856 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3857 | |
| 3858 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 3859 | // valid VkBorderColor value |
| 3860 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 3861 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 3862 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3863 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 3864 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3865 | } |
| 3866 | |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 3867 | // Checks for the IMG cubic filtering extension |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3868 | if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 3869 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 3870 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3871 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 3872 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 3873 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 3874 | } |
| 3875 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 3876 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 3877 | // Check for valid Lod range |
| 3878 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 3879 | skip |= |
| 3880 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 3881 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 3882 | } |
| 3883 | |
| 3884 | // Check mipLodBias to device limit |
| 3885 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 3886 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 3887 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 3888 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 3889 | } |
| 3890 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3891 | const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 3892 | if (sampler_conversion != nullptr) { |
| 3893 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 3894 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 3895 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 3896 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3897 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 3898 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 3899 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 3900 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 3901 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 3902 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 3903 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 3904 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 3905 | } |
| 3906 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 3907 | |
| 3908 | if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) { |
| 3909 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
| 3910 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574", |
| 3911 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3912 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 3913 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
| 3914 | } |
| 3915 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
| 3916 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575", |
| 3917 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3918 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 3919 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
| 3920 | } |
| 3921 | if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) { |
| 3922 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576", |
| 3923 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3924 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.", |
| 3925 | pCreateInfo->minLod, pCreateInfo->maxLod); |
| 3926 | } |
| 3927 | if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3928 | (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) || |
| 3929 | ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3930 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) { |
| 3931 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577", |
| 3932 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3933 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be " |
| 3934 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER", |
| 3935 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 3936 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
| 3937 | } |
| 3938 | if (pCreateInfo->anisotropyEnable) { |
| 3939 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578", |
| 3940 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3941 | "pCreateInfo->anisotropyEnable must be VK_FALSE"); |
| 3942 | } |
| 3943 | if (pCreateInfo->compareEnable) { |
| 3944 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579", |
| 3945 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3946 | "pCreateInfo->compareEnable must be VK_FALSE"); |
| 3947 | } |
| 3948 | if (pCreateInfo->unnormalizedCoordinates) { |
| 3949 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580", |
| 3950 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3951 | "pCreateInfo->unnormalizedCoordinates must be VK_FALSE"); |
| 3952 | } |
| 3953 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3954 | |
Piers Daniell | 833b949 | 2021-11-20 11:47:10 -0700 | [diff] [blame] | 3955 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 3956 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
| 3957 | if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) { |
| 3958 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 3959 | "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n", |
| 3960 | string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 3961 | } |
| 3962 | auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext); |
| 3963 | if (!custom_create_info) { |
| 3964 | skip |= LogError( |
| 3965 | device, "VUID-VkSamplerCreateInfo-borderColor-04011", |
| 3966 | "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT " |
| 3967 | "struct in pNext chain.\n", |
| 3968 | string_VkBorderColor(pCreateInfo->borderColor)); |
| 3969 | } else { |
| 3970 | if ((custom_create_info->format != VK_FORMAT_UNDEFINED) && |
| 3971 | ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && |
| 3972 | !FormatIsSampledInt(custom_create_info->format)) || |
| 3973 | (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT && |
| 3974 | !FormatIsSampledFloat(custom_create_info->format)))) { |
| 3975 | skip |= |
| 3976 | LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013", |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3977 | "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s " |
| 3978 | "whose type does not match\n", |
| 3979 | string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format)); |
Piers Daniell | 833b949 | 2021-11-20 11:47:10 -0700 | [diff] [blame] | 3980 | ; |
| 3981 | } |
| 3982 | } |
| 3983 | } |
| 3984 | |
| 3985 | const auto *border_color_component_mapping = |
| 3986 | LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext); |
| 3987 | if (border_color_component_mapping) { |
| 3988 | const auto *border_color_swizzle_features = |
| 3989 | LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext); |
| 3990 | bool border_color_swizzle_features_enabled = |
| 3991 | border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle; |
| 3992 | if (!border_color_swizzle_features_enabled) { |
| 3993 | skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437", |
| 3994 | "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use " |
| 3995 | "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT"); |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3996 | } |
| 3997 | } |
| 3998 | } |
| 3999 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4000 | return skip; |
| 4001 | } |
| 4002 | |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4003 | bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info, |
| 4004 | const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info, |
| 4005 | const char *func_name) const { |
| 4006 | bool skip = false; |
| 4007 | |
| 4008 | for (uint32_t i = 0; i < create_info.bindingCount; ++i) { |
| 4009 | uint32_t mutable_type_count = 0; |
| 4010 | if (mutable_create_info.mutableDescriptorTypeListCount > i) { |
| 4011 | mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount; |
| 4012 | } |
| 4013 | if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) { |
| 4014 | if (mutable_type_count == 0) { |
| 4015 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597", |
| 4016 | "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32 |
| 4017 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but " |
| 4018 | "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4019 | "].descriptorTypeCount is 0.", |
| 4020 | func_name, i, i); |
| 4021 | } |
| 4022 | } else { |
| 4023 | if (mutable_type_count > 0) { |
| 4024 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599", |
| 4025 | "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32 |
| 4026 | "].descriptorType is %s, but " |
| 4027 | "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4028 | "].descriptorTypeCount is not 0.", |
| 4029 | func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i); |
| 4030 | } |
| 4031 | } |
| 4032 | } |
| 4033 | |
| 4034 | for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) { |
| 4035 | for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) { |
| 4036 | switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) { |
| 4037 | case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE: |
| 4038 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600", |
| 4039 | "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4040 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", |
| 4041 | func_name, j, k); |
| 4042 | break; |
| 4043 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 4044 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601", |
| 4045 | "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4046 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.", |
| 4047 | func_name, j, k); |
| 4048 | break; |
| 4049 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 4050 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602", |
| 4051 | "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4052 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.", |
| 4053 | func_name, j, k); |
| 4054 | break; |
| 4055 | case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT: |
| 4056 | skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603", |
| 4057 | "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4058 | "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.", |
| 4059 | func_name, j, k); |
| 4060 | break; |
| 4061 | default: |
| 4062 | break; |
| 4063 | } |
| 4064 | for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) { |
| 4065 | if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] == |
| 4066 | mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) { |
| 4067 | skip |= |
| 4068 | LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598", |
| 4069 | "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4070 | "].pDescriptorTypes[%" PRIu32 |
| 4071 | "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32 |
| 4072 | "].pDescriptorTypes[%" PRIu32 "] are both %s.", |
| 4073 | func_name, j, k, j, l, |
| 4074 | string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k])); |
| 4075 | } |
| 4076 | } |
| 4077 | } |
| 4078 | } |
| 4079 | |
| 4080 | return skip; |
| 4081 | } |
| 4082 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4083 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 4084 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 4085 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4086 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4087 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4088 | |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4089 | const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext); |
| 4090 | const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext); |
| 4091 | bool mutable_descriptor_type_features_enabled = |
| 4092 | mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE; |
| 4093 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4094 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4095 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 4096 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 4097 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4098 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 4099 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 4100 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 4101 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 4102 | ++descriptor_index) { |
| 4103 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Spencer Fricke | b0e3082 | 2020-03-23 10:32:30 -0700 | [diff] [blame] | 4104 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4105 | "vkCreateDescriptorSetLayout: required parameter " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4106 | "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32 |
| 4107 | "] specified as VK_NULL_HANDLE", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4108 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4109 | } |
| 4110 | } |
| 4111 | } |
| 4112 | |
| 4113 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 4114 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 4115 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4116 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4117 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32 |
| 4118 | "].descriptorCount is not 0, " |
| 4119 | "pCreateInfo->pBindings[%" PRIu32 |
| 4120 | "].stageFlags must be a valid combination of VkShaderStageFlagBits " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4121 | "values.", |
| 4122 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4123 | } |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 4124 | |
| 4125 | if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) && |
| 4126 | (pCreateInfo->pBindings[i].stageFlags != 0) && |
| 4127 | (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4128 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510", |
| 4129 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32 |
| 4130 | "].descriptorCount is not 0 and " |
| 4131 | "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32 |
| 4132 | "].stageFlags " |
| 4133 | "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s", |
| 4134 | i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str()); |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 4135 | } |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4136 | |
| 4137 | if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) { |
| 4138 | if (!mutable_descriptor_type) { |
| 4139 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593", |
| 4140 | "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32 |
| 4141 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but " |
| 4142 | "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.", |
| 4143 | i); |
| 4144 | } |
| 4145 | if (pCreateInfo->pBindings[i].pImmutableSamplers) { |
| 4146 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594", |
| 4147 | "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32 |
| 4148 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but " |
| 4149 | "pImmutableSamplers is not NULL.", |
| 4150 | i); |
| 4151 | } |
| 4152 | if (!mutable_descriptor_type_features_enabled) { |
| 4153 | skip |= LogError( |
| 4154 | device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595", |
| 4155 | "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32 |
| 4156 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but " |
| 4157 | "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.", |
| 4158 | i); |
| 4159 | } |
| 4160 | } |
| 4161 | |
| 4162 | if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR && |
| 4163 | pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) { |
| 4164 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591", |
| 4165 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains " |
| 4166 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32 |
| 4167 | "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i); |
| 4168 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4169 | } |
| 4170 | } |
ziga-lunarg | 8a4d319 | 2021-10-13 19:54:19 +0200 | [diff] [blame] | 4171 | |
| 4172 | if (mutable_descriptor_type) { |
| 4173 | ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type, |
| 4174 | "vkDescriptorSetLayoutCreateInfo"); |
| 4175 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4176 | } |
ziga-lunarg | fc6896f | 2021-10-15 18:46:12 +0200 | [diff] [blame] | 4177 | if (pCreateInfo) { |
| 4178 | if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) && |
| 4179 | (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) { |
| 4180 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590", |
| 4181 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both " |
| 4182 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and " |
| 4183 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE."); |
| 4184 | } |
| 4185 | if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) && |
| 4186 | (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) { |
| 4187 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592", |
| 4188 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both " |
| 4189 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and " |
| 4190 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE."); |
| 4191 | } |
| 4192 | if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE && |
| 4193 | !mutable_descriptor_type_features_enabled) { |
| 4194 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596", |
| 4195 | "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains " |
| 4196 | "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but " |
| 4197 | "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled."); |
| 4198 | } |
| 4199 | } |
| 4200 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4201 | return skip; |
| 4202 | } |
| 4203 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4204 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 4205 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4206 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4207 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4208 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 4209 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4210 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 4211 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4212 | } |
| 4213 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4214 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 4215 | const VkWriteDescriptorSet *pDescriptorWrites, |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4216 | const bool isPushDescriptor) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4217 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4218 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4219 | if (pDescriptorWrites != NULL) { |
| 4220 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 4221 | // descriptorCount must be greater than 0 |
| 4222 | if (pDescriptorWrites[i].descriptorCount == 0) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4223 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 4224 | "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.", |
| 4225 | vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4226 | } |
| 4227 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4228 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4229 | if (!isPushDescriptor) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4230 | // dstSet must be a valid VkDescriptorSet handle |
| 4231 | skip |= validate_required_handle(vkCallingFunction, |
| 4232 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 4233 | pDescriptorWrites[i].dstSet); |
| 4234 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4235 | |
| 4236 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 4237 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 4238 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 4239 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 4240 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4241 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4242 | if (!isPushDescriptor) { |
| 4243 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 4244 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or |
| 4245 | // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid |
| 4246 | // VkDescriptorImageInfo structures. Valid imageView handles are checked in |
| 4247 | // ObjectLifetimes::ValidateDescriptorWrite. |
| 4248 | skip |= LogError( |
| 4249 | device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493", |
| 4250 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4251 | "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 4252 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 4253 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.", |
| 4254 | vkCallingFunction, i, i); |
| 4255 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 4256 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 4257 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 4258 | // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types |
| 4259 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and |
| 4260 | // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT |
| 4261 | skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494", |
| 4262 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4263 | "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE " |
| 4264 | "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 |
| 4265 | "].pImageInfo must not be NULL.", |
| 4266 | vkCallingFunction, i, i); |
| 4267 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4268 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 4269 | // 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] | 4270 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout |
| 4271 | // member of any given element of pImageInfo must be a valid VkImageLayout |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4272 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 4273 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4274 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4275 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 4276 | ParameterName::IndexVector{i, descriptor_index}), |
| 4277 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 4278 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4279 | } |
| 4280 | } |
| 4281 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 4282 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 4283 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 4284 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 4285 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 4286 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 4287 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4288 | // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4289 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4290 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4291 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4292 | "].descriptorType is " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4293 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 4294 | "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] | 4295 | "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4296 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4297 | } else { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4298 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4299 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4300 | if (robustness2_features && robustness2_features->nullDescriptor) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4301 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 4302 | ++descriptor_index) { |
| 4303 | if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE && |
| 4304 | (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 || |
| 4305 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4306 | skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4307 | "%s(): if pDescriptorWrites[%" PRIu32 |
| 4308 | "].buffer is VK_NULL_HANDLE, " |
baldurk | 751594b | 2020-09-09 09:41:02 +0100 | [diff] [blame] | 4309 | "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] | 4310 | vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset, |
| 4311 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4312 | } |
| 4313 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4314 | } |
| 4315 | } |
| 4316 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 4317 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4318 | // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4319 | } |
| 4320 | |
| 4321 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 4322 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4323 | VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4324 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 4325 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4326 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4327 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4328 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4329 | "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4330 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4331 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4332 | } |
| 4333 | } |
| 4334 | } |
| 4335 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 4336 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4337 | VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4338 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 4339 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4340 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4341 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4342 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4343 | "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4344 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4345 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4346 | } |
| 4347 | } |
| 4348 | } |
| 4349 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4350 | // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR |
| 4351 | // or VkWriteDescriptorSetInlineUniformBlockEX |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4352 | if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4353 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4354 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 4355 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382", |
| 4356 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext" |
| 4357 | "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4358 | "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".", |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4359 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 4360 | pDescriptorWrites[i].descriptorCount); |
| 4361 | } |
| 4362 | // further checks only if we have right structtype |
| 4363 | if (pnext_struct) { |
| 4364 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 4365 | skip |= LogError( |
| 4366 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4367 | "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32 |
| 4368 | " in the extended structure " |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4369 | ".", |
| 4370 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4371 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4372 | if (pnext_struct->accelerationStructureCount == 0) { |
| 4373 | skip |= LogError(device, |
| 4374 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4375 | "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4376 | } |
| 4377 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4378 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4379 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 4380 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 4381 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 4382 | skip |= LogError(device, |
| 4383 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580", |
| 4384 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4385 | "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4386 | } |
| 4387 | } |
| 4388 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4389 | } |
| 4390 | } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4391 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4392 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 4393 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817", |
| 4394 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext" |
| 4395 | "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4396 | "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".", |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4397 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 4398 | pDescriptorWrites[i].descriptorCount); |
| 4399 | } |
| 4400 | // further checks only if we have right structtype |
| 4401 | if (pnext_struct) { |
| 4402 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 4403 | skip |= LogError( |
| 4404 | device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4405 | "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32 |
| 4406 | " in the extended structure " |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4407 | ".", |
| 4408 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4409 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4410 | if (pnext_struct->accelerationStructureCount == 0) { |
| 4411 | skip |= LogError(device, |
| 4412 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4413 | "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4414 | } |
| 4415 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4416 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 4417 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 4418 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 4419 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 4420 | skip |= LogError(device, |
| 4421 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749", |
| 4422 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 4423 | "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4424 | } |
| 4425 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4426 | } |
| 4427 | } |
| 4428 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4429 | } |
| 4430 | } |
| 4431 | return skip; |
| 4432 | } |
| 4433 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4434 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 4435 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 4436 | uint32_t descriptorCopyCount, |
| 4437 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 4438 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false); |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4439 | } |
| 4440 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4441 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4442 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4443 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4444 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 4445 | } |
| 4446 | |
sfricke-samsung | 681ab7b | 2020-10-29 01:53:35 -0700 | [diff] [blame] | 4447 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
| 4448 | const VkAllocationCallbacks *pAllocator, |
| 4449 | VkRenderPass *pRenderPass) const { |
| 4450 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 4451 | } |
| 4452 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4453 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4454 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4455 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4456 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 4457 | } |
| 4458 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4459 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 4460 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4461 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4462 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4463 | |
| 4464 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4465 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 4466 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4467 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 4468 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4469 | return skip; |
| 4470 | } |
| 4471 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4472 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4473 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4474 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 4475 | |
| 4476 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 4477 | const char *cmd_name = "vkBeginCommandBuffer"; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4478 | bool cb_is_secondary; |
| 4479 | { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 4480 | auto lock = CBReadLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4481 | cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end()); |
| 4482 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4483 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4484 | if (cb_is_secondary) { |
| 4485 | // Implicit VUs |
| 4486 | // validate only sType here; pointer has to be validated in core_validation |
| 4487 | const bool k_not_required = false; |
| 4488 | const char *k_no_vuid = nullptr; |
| 4489 | const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo; |
| 4490 | 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] | 4491 | info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid, |
| 4492 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4493 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4494 | if (info) { |
| 4495 | const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = { |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 4496 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT, |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 4497 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR, |
| 4498 | VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD, |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 4499 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV}; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4500 | skip |= validate_struct_pnext( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4501 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", |
| 4502 | info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info), |
| 4503 | allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion, |
| 4504 | "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4505 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4506 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4507 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4508 | // Explicit VUs |
| 4509 | if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4510 | skip |= LogError( |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4511 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
| 4512 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 4513 | cmd_name); |
| 4514 | } |
| 4515 | |
| 4516 | if (physical_device_features.inheritedQueries) { |
| 4517 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4518 | AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags, |
| 4519 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
| 4520 | } else { // !inheritedQueries |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4521 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4522 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4523 | } |
| 4524 | |
| 4525 | if (physical_device_features.pipelineStatisticsQuery) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4526 | skip |= |
| 4527 | validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
| 4528 | AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags, |
| 4529 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
| 4530 | } else { // !pipelineStatisticsQuery |
| 4531 | skip |= |
| 4532 | validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics, |
| 4533 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4534 | } |
| 4535 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4536 | const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4537 | if (conditional_rendering) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4538 | const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4539 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 4540 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
| 4541 | skip |= LogError( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4542 | commandBuffer, |
| 4543 | "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4544 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 4545 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 4546 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 4547 | } |
ziga-lunarg | 9d01913 | 2021-07-19 01:05:31 +0200 | [diff] [blame] | 4548 | |
| 4549 | auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext); |
| 4550 | if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport && |
| 4551 | p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE && |
| 4552 | p_inherited_viewport_scissor_info->viewportDepthCount != 1) { |
| 4553 | skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783", |
| 4554 | "vkBeginCommandBuffer: multiViewport feature is disabled, but " |
| 4555 | "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in " |
| 4556 | "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1."); |
| 4557 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 4558 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4559 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4560 | return skip; |
| 4561 | } |
| 4562 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4563 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4564 | uint32_t viewportCount, const VkViewport *pViewports) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4565 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4566 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4567 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 4568 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4569 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 4570 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 4571 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 4572 | } |
| 4573 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4574 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 4575 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 4576 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 4577 | } |
| 4578 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 4579 | 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] | 4580 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4581 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 4582 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4583 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4584 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4585 | } |
| 4586 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 4587 | |
| 4588 | if (pViewports) { |
| 4589 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 4590 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 4591 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4592 | skip |= manual_PreCallValidateViewport( |
| 4593 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 4594 | } |
| 4595 | } |
| 4596 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4597 | return skip; |
| 4598 | } |
| 4599 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4600 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4601 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4602 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4603 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4604 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4605 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4606 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 4607 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 4608 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4609 | } |
| 4610 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4611 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 4612 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 4613 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4614 | } |
| 4615 | } else { // multiViewport enabled |
| 4616 | 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] | 4617 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4618 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 4619 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4620 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4621 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4622 | } |
| 4623 | } |
| 4624 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4625 | if (pScissors) { |
| 4626 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 4627 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4628 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4629 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4630 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 4631 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 4632 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4633 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4634 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4635 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4636 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 4637 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 4638 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4639 | } |
| 4640 | |
| 4641 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 4642 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4643 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 4644 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4645 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4646 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4647 | } |
| 4648 | |
| 4649 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 4650 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4651 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 4652 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4653 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4654 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4655 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4656 | } |
| 4657 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4658 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4659 | return skip; |
| 4660 | } |
| 4661 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4662 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4663 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4664 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4665 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4666 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 4667 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4668 | } |
| 4669 | |
| 4670 | return skip; |
| 4671 | } |
| 4672 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4673 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4674 | uint32_t drawCount, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4675 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4676 | |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4677 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 41ce65b | 2020-10-30 12:17:06 -0600 | [diff] [blame] | 4678 | skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4679 | "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "", |
| 4680 | drawCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4681 | } |
| 4682 | if (drawCount > device_limits.maxDrawIndirectCount) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4683 | skip |= |
| 4684 | LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719", |
| 4685 | "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").", |
| 4686 | drawCount, device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4687 | } |
| 4688 | return skip; |
| 4689 | } |
| 4690 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4691 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4692 | VkDeviceSize offset, uint32_t drawCount, |
| 4693 | uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4694 | bool skip = false; |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4695 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4696 | skip |= |
| 4697 | LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718", |
| 4698 | "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "", |
| 4699 | drawCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4700 | } |
| 4701 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 4702 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4703 | "CmdDrawIndexedIndirect(): drawCount (%" PRIu32 |
| 4704 | ") is not less than or equal to the maximum allowed (%" PRIu32 ").", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4705 | drawCount, device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4706 | } |
| 4707 | return skip; |
| 4708 | } |
| 4709 | |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4710 | bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 4711 | VkDeviceSize countBufferOffset, bool khr) const { |
| 4712 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4713 | const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4714 | if (offset & 3) { |
| 4715 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4716 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4717 | } |
| 4718 | |
| 4719 | if (countBufferOffset & 3) { |
| 4720 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4721 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4722 | countBufferOffset); |
| 4723 | } |
| 4724 | return skip; |
| 4725 | } |
| 4726 | |
| 4727 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4728 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4729 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 4730 | uint32_t stride) const { |
| 4731 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 4732 | } |
| 4733 | |
| 4734 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4735 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4736 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 4737 | uint32_t stride) const { |
| 4738 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 4739 | } |
| 4740 | |
| 4741 | bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 4742 | VkDeviceSize countBufferOffset, bool khr) const { |
| 4743 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4744 | const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4745 | if (offset & 3) { |
| 4746 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4747 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4748 | } |
| 4749 | |
| 4750 | if (countBufferOffset & 3) { |
| 4751 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4752 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4753 | countBufferOffset); |
| 4754 | } |
| 4755 | return skip; |
| 4756 | } |
| 4757 | |
| 4758 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4759 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4760 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 4761 | uint32_t stride) const { |
| 4762 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 4763 | } |
| 4764 | |
| 4765 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4766 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4767 | VkDeviceSize countBufferOffset, |
| 4768 | uint32_t maxDrawCount, uint32_t stride) const { |
| 4769 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 4770 | } |
| 4771 | |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 4772 | bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 4773 | const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount, |
| 4774 | uint32_t firstInstance, uint32_t stride) const { |
| 4775 | bool skip = false; |
| 4776 | if (stride & 3) { |
| 4777 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936", |
| 4778 | "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride); |
| 4779 | } |
| 4780 | if (drawCount && nullptr == pVertexInfo) { |
| 4781 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935", |
| 4782 | "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing " |
| 4783 | "one or more valid instances of VkMultiDrawInfoEXT structures"); |
| 4784 | } |
| 4785 | return skip; |
| 4786 | } |
| 4787 | |
| 4788 | bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 4789 | const VkMultiDrawIndexedInfoEXT *pIndexInfo, |
| 4790 | uint32_t instanceCount, uint32_t firstInstance, |
| 4791 | uint32_t stride, const int32_t *pVertexOffset) const { |
| 4792 | bool skip = false; |
| 4793 | if (stride & 3) { |
| 4794 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941", |
| 4795 | "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride); |
| 4796 | } |
| 4797 | if (drawCount && nullptr == pIndexInfo) { |
| 4798 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940", |
| 4799 | "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to " |
| 4800 | "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures"); |
| 4801 | } |
| 4802 | return skip; |
| 4803 | } |
| 4804 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4805 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 4806 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4807 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4808 | bool skip = false; |
| 4809 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 4810 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4811 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4812 | "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4813 | } |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 4814 | if (pRects[rect].rect.extent.width == 0) { |
| 4815 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4816 | "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect); |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 4817 | } |
| 4818 | if (pRects[rect].rect.extent.height == 0) { |
| 4819 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4820 | "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect); |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 4821 | } |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4822 | } |
| 4823 | return skip; |
| 4824 | } |
| 4825 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4826 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 4827 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 4828 | VkImageFormatProperties2 *pImageFormatProperties, |
| 4829 | const char *apiName) const { |
| 4830 | bool skip = false; |
| 4831 | |
| 4832 | if (pImageFormatInfo != nullptr) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4833 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4834 | if (image_stencil_struct != nullptr) { |
| 4835 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 4836 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 4837 | // No flags other than the legal attachment bits may be set |
| 4838 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 4839 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4840 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 4841 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 4842 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 4843 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 4844 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4845 | } |
| 4846 | } |
| 4847 | } |
ziga-lunarg | d3da253 | 2021-08-11 11:50:12 +0200 | [diff] [blame] | 4848 | const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext); |
| 4849 | if (image_drm_format) { |
| 4850 | if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 4851 | skip |= LogError( |
| 4852 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", |
| 4853 | "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, " |
| 4854 | "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", |
| 4855 | apiName, string_VkImageTiling(pImageFormatInfo->tiling)); |
| 4856 | } |
ziga-lunarg | 27e256d | 2021-10-07 23:38:12 +0200 | [diff] [blame] | 4857 | if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) { |
| 4858 | skip |= LogError( |
| 4859 | physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315", |
| 4860 | "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, " |
| 4861 | "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".", |
| 4862 | apiName, image_drm_format->queueFamilyIndexCount); |
| 4863 | } |
ziga-lunarg | d3da253 | 2021-08-11 11:50:12 +0200 | [diff] [blame] | 4864 | } else { |
| 4865 | if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 4866 | skip |= LogError( |
| 4867 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", |
| 4868 | "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include " |
| 4869 | "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", |
| 4870 | apiName); |
| 4871 | } |
| 4872 | } |
| 4873 | if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT && |
| 4874 | (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) { |
| 4875 | const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext); |
| 4876 | if (!format_list || format_list->viewFormatCount == 0) { |
| 4877 | skip |= LogError( |
| 4878 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313", |
| 4879 | "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT " |
| 4880 | "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.", |
| 4881 | apiName); |
| 4882 | } |
| 4883 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4884 | } |
| 4885 | |
| 4886 | return skip; |
| 4887 | } |
| 4888 | |
| 4889 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 4890 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 4891 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 4892 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 4893 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 4894 | } |
| 4895 | |
| 4896 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 4897 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 4898 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 4899 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 4900 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 4901 | } |
| 4902 | |
Lionel Landwerlin | 5fe5275 | 2020-07-22 08:18:14 +0300 | [diff] [blame] | 4903 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties( |
| 4904 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, |
| 4905 | VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const { |
| 4906 | bool skip = false; |
| 4907 | |
| 4908 | if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 4909 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248", |
| 4910 | "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT."); |
| 4911 | } |
| 4912 | |
| 4913 | return skip; |
| 4914 | } |
| 4915 | |
ziga-lunarg | 73b5ef2 | 2021-07-29 20:25:06 +0200 | [diff] [blame] | 4916 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR( |
| 4917 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo, |
| 4918 | uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const { |
| 4919 | bool skip = false; |
| 4920 | |
| 4921 | if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR | |
| 4922 | VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) { |
| 4923 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844", |
| 4924 | "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of " |
| 4925 | "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, " |
| 4926 | "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR."); |
| 4927 | } |
| 4928 | |
ziga-lunarg | 42f884b | 2021-08-25 16:13:20 +0200 | [diff] [blame] | 4929 | return skip; |
ziga-lunarg | 73b5ef2 | 2021-07-29 20:25:06 +0200 | [diff] [blame] | 4930 | } |
| 4931 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 4932 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 4933 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 4934 | bool skip = false; |
| 4935 | |
| 4936 | if (pRegions != nullptr) { |
| 4937 | for (uint32_t i = 0; i < regionCount; i++) { |
| 4938 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4939 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4940 | "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 4941 | } |
| 4942 | } |
| 4943 | } |
| 4944 | return skip; |
| 4945 | } |
| 4946 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 4947 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, |
| 4948 | const VkCopyBufferInfo2KHR *pCopyBufferInfo) const { |
| 4949 | bool skip = false; |
| 4950 | |
| 4951 | if (pCopyBufferInfo->pRegions != nullptr) { |
| 4952 | for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) { |
| 4953 | if (pCopyBufferInfo->pRegions[i].size == 0) { |
Tony-LunarG | ef03547 | 2021-11-02 10:23:33 -0600 | [diff] [blame] | 4954 | skip |= LogError(device, "VUID-VkBufferCopy2-size-01988", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 4955 | "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 4956 | } |
| 4957 | } |
| 4958 | } |
| 4959 | return skip; |
| 4960 | } |
| 4961 | |
Tony-LunarG | ef03547 | 2021-11-02 10:23:33 -0600 | [diff] [blame] | 4962 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer, |
| 4963 | const VkCopyBufferInfo2 *pCopyBufferInfo) const { |
| 4964 | bool skip = false; |
| 4965 | |
| 4966 | if (pCopyBufferInfo->pRegions != nullptr) { |
| 4967 | for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) { |
| 4968 | if (pCopyBufferInfo->pRegions[i].size == 0) { |
| 4969 | skip |= LogError(device, "VUID-VkBufferCopy2-size-01988", |
| 4970 | "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i); |
| 4971 | } |
| 4972 | } |
| 4973 | } |
| 4974 | return skip; |
| 4975 | } |
| 4976 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4977 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4978 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 4979 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4980 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4981 | |
| 4982 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4983 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 4984 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 4985 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4986 | } |
| 4987 | |
| 4988 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4989 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 4990 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 4991 | "), must be greater than zero and less than or equal to 65536.", |
| 4992 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4993 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4994 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 4995 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 4996 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4997 | } |
| 4998 | return skip; |
| 4999 | } |
| 5000 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5001 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5002 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5003 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5004 | |
| 5005 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5006 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 5007 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 5008 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5009 | } |
| 5010 | |
| 5011 | if (size != VK_WHOLE_SIZE) { |
| 5012 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5013 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5014 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 5015 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5016 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5017 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 5018 | "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] | 5019 | } |
| 5020 | } |
| 5021 | return skip; |
| 5022 | } |
| 5023 | |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5024 | bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5025 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5026 | |
| 5027 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5028 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 5029 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 5030 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 5031 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5032 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5033 | "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 5034 | "pCreateInfo->queueFamilyIndexCount must be greater than 1.", |
| 5035 | func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5036 | } |
| 5037 | |
| 5038 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 5039 | // queueFamilyIndexCount uint32_t values |
| 5040 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5041 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5042 | "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5043 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5044 | "pCreateInfo->queueFamilyIndexCount uint32_t values.", |
| 5045 | func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5046 | } |
| 5047 | } |
| 5048 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 5049 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5050 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5051 | |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5052 | // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo |
| 5053 | const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext); |
| 5054 | if (format_list_info) { |
| 5055 | const uint32_t viewFormatCount = format_list_info->viewFormatCount; |
| 5056 | if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) { |
| 5057 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100", |
| 5058 | "%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] | 5059 | "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 |
| 5060 | ") must be 0 or 1 if it is in the pNext chain.", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5061 | func_name, viewFormatCount); |
| 5062 | } |
| 5063 | |
| 5064 | // Using the first format, compare the rest of the formats against it that they are compatible |
| 5065 | for (uint32_t i = 1; i < viewFormatCount; i++) { |
| 5066 | if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) != |
| 5067 | FormatCompatibilityClass(format_list_info->pViewFormats[i])) { |
| 5068 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099", |
| 5069 | "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5070 | "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32 |
| 5071 | "] (%s) are not compatible in the pNext chain.", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 5072 | func_name, string_VkFormat(format_list_info->pViewFormats[0]), i, |
| 5073 | string_VkFormat(format_list_info->pViewFormats[i])); |
| 5074 | } |
| 5075 | } |
| 5076 | } |
| 5077 | |
| 5078 | // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR |
| 5079 | if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) { |
| 5080 | if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) { |
| 5081 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 5082 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the " |
| 5083 | "VK_KHR_swapchain_mutable_format extension, which has not been enabled.", |
| 5084 | func_name); |
| 5085 | } else { |
| 5086 | if (format_list_info == nullptr) { |
| 5087 | skip |= LogError( |
| 5088 | device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 5089 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of " |
| 5090 | "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.", |
| 5091 | func_name); |
| 5092 | } else if (format_list_info->viewFormatCount == 0) { |
| 5093 | skip |= LogError( |
| 5094 | device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 5095 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount " |
| 5096 | "member of VkImageFormatListCreateInfo in the pNext chain is zero.", |
| 5097 | func_name); |
| 5098 | } else { |
| 5099 | bool found_base_format = false; |
| 5100 | for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) { |
| 5101 | if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) { |
| 5102 | found_base_format = true; |
| 5103 | break; |
| 5104 | } |
| 5105 | } |
| 5106 | if (!found_base_format) { |
| 5107 | skip |= |
| 5108 | LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 5109 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the " |
| 5110 | "elements of the pViewFormats member of VkImageFormatListCreateInfo match " |
| 5111 | "pCreateInfo->imageFormat.", |
| 5112 | func_name); |
| 5113 | } |
| 5114 | } |
| 5115 | } |
| 5116 | } |
| 5117 | } |
| 5118 | return skip; |
| 5119 | } |
| 5120 | |
| 5121 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 5122 | const VkAllocationCallbacks *pAllocator, |
| 5123 | VkSwapchainKHR *pSwapchain) const { |
| 5124 | bool skip = false; |
| 5125 | skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo); |
| 5126 | return skip; |
| 5127 | } |
| 5128 | |
| 5129 | bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, |
| 5130 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 5131 | const VkAllocationCallbacks *pAllocator, |
| 5132 | VkSwapchainKHR *pSwapchains) const { |
| 5133 | bool skip = false; |
| 5134 | if (pCreateInfos) { |
| 5135 | for (uint32_t i = 0; i < swapchainCount; i++) { |
| 5136 | std::stringstream func_name; |
| 5137 | func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()"; |
| 5138 | skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]); |
| 5139 | } |
| 5140 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5141 | return skip; |
| 5142 | } |
| 5143 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5144 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5145 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5146 | |
| 5147 | if (pPresentInfo && pPresentInfo->pNext) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5148 | const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5149 | if (present_regions) { |
| 5150 | // 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] | 5151 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5152 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 5153 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
sfricke-samsung | a4cc4ff | 2020-08-23 22:05:49 -0700 | [diff] [blame] | 5154 | skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5155 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 5156 | "extension swapchainCount is %i. These values must be equal.", |
| 5157 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5158 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5159 | 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] | 5160 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 5161 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5162 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 5163 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 5164 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 5165 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5166 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5167 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 5168 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5169 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5170 | } |
| 5171 | } |
| 5172 | |
| 5173 | return skip; |
| 5174 | } |
| 5175 | |
sfricke-samsung | 5c1b739 | 2020-12-13 22:17:15 -0800 | [diff] [blame] | 5176 | bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 5177 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 5178 | const VkAllocationCallbacks *pAllocator, |
| 5179 | VkDisplayModeKHR *pMode) const { |
| 5180 | bool skip = false; |
| 5181 | |
| 5182 | const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters; |
| 5183 | if (display_mode_parameters.visibleRegion.width == 0) { |
| 5184 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990", |
| 5185 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0."); |
| 5186 | } |
| 5187 | if (display_mode_parameters.visibleRegion.height == 0) { |
| 5188 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991", |
| 5189 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0."); |
| 5190 | } |
| 5191 | if (display_mode_parameters.refreshRate == 0) { |
| 5192 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992", |
| 5193 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0."); |
| 5194 | } |
| 5195 | |
| 5196 | return skip; |
| 5197 | } |
| 5198 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5199 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5200 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 5201 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 5202 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5203 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5204 | bool skip = false; |
| 5205 | |
| 5206 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5207 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 5208 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5209 | } |
| 5210 | |
| 5211 | return skip; |
| 5212 | } |
| 5213 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 5214 | |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5215 | static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) { |
| 5216 | bool partial_overlap = false; |
| 5217 | |
| 5218 | static const std::vector<VkDescriptorType> all_descriptor_types = { |
| 5219 | VK_DESCRIPTOR_TYPE_SAMPLER, |
| 5220 | VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 5221 | VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, |
| 5222 | VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, |
| 5223 | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, |
| 5224 | VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, |
| 5225 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 5226 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 5227 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, |
| 5228 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, |
| 5229 | VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, |
| 5230 | VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT, |
| 5231 | VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, |
| 5232 | VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, |
| 5233 | }; |
| 5234 | |
| 5235 | const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext); |
| 5236 | if (mutable_descriptor_type) { |
| 5237 | std::vector<VkDescriptorType> first_types, second_types; |
| 5238 | if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) { |
| 5239 | for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) { |
| 5240 | first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]); |
| 5241 | } |
| 5242 | } else { |
| 5243 | first_types = all_descriptor_types; |
| 5244 | } |
| 5245 | if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) { |
| 5246 | for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) { |
| 5247 | second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]); |
| 5248 | } |
| 5249 | } else { |
| 5250 | second_types = all_descriptor_types; |
| 5251 | } |
| 5252 | |
| 5253 | bool complete_overlap = first_types.size() == second_types.size(); |
| 5254 | bool disjoint = true; |
| 5255 | for (const auto first_type : first_types) { |
| 5256 | bool found = false; |
| 5257 | for (const auto second_type : second_types) { |
| 5258 | if (first_type == second_type) { |
| 5259 | found = true; |
| 5260 | break; |
| 5261 | } |
| 5262 | } |
| 5263 | if (found) { |
| 5264 | disjoint = false; |
| 5265 | } else { |
| 5266 | complete_overlap = false; |
| 5267 | } |
| 5268 | if (!disjoint && !complete_overlap) { |
| 5269 | partial_overlap = true; |
| 5270 | break; |
| 5271 | } |
| 5272 | } |
| 5273 | } |
| 5274 | |
| 5275 | return partial_overlap; |
| 5276 | } |
| 5277 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5278 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5279 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5280 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5281 | bool skip = false; |
| 5282 | |
| 5283 | if (pCreateInfo) { |
| 5284 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5285 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 5286 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5287 | } |
| 5288 | |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5289 | const auto *mutable_descriptor_type_features = |
| 5290 | LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext); |
| 5291 | bool mutable_descriptor_type_enabled = |
| 5292 | mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE; |
| 5293 | |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5294 | if (pCreateInfo->pPoolSizes) { |
| 5295 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 5296 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5297 | skip |= LogError( |
| 5298 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5299 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5300 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 5301 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 5302 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5303 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 5304 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 5305 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 5306 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 5307 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 5308 | } |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5309 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) { |
| 5310 | skip |= |
| 5311 | LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608", |
| 5312 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 5313 | "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE " |
| 5314 | ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.", |
| 5315 | i); |
| 5316 | } |
| 5317 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) { |
| 5318 | for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) { |
| 5319 | if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) { |
| 5320 | if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) { |
| 5321 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787", |
| 5322 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 5323 | "].type and pCreateInfo->pPoolSizes[%" PRIu32 |
| 5324 | "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE " |
| 5325 | " and have sets which partially overlap.", |
| 5326 | i, j); |
| 5327 | } |
| 5328 | } |
| 5329 | } |
| 5330 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5331 | } |
| 5332 | } |
ziga-lunarg | 0cf8521 | 2021-07-19 01:26:17 +0200 | [diff] [blame] | 5333 | |
ziga-lunarg | 0bc679d | 2021-10-15 15:55:19 +0200 | [diff] [blame] | 5334 | if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) { |
| 5335 | skip |= |
| 5336 | LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609", |
| 5337 | "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, " |
| 5338 | "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled."); |
| 5339 | } |
ziga-lunarg | 0cf8521 | 2021-07-19 01:26:17 +0200 | [diff] [blame] | 5340 | if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) && |
| 5341 | (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) { |
| 5342 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607", |
| 5343 | "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both " |
| 5344 | "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT"); |
| 5345 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 5346 | } |
| 5347 | |
| 5348 | return skip; |
| 5349 | } |
| 5350 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5351 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5352 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5353 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5354 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5355 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5356 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5357 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 5358 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 5359 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5360 | } |
| 5361 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5362 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5363 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5364 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 5365 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 5366 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5367 | } |
| 5368 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5369 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 5370 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5371 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 5372 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 5373 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5374 | } |
| 5375 | |
| 5376 | return skip; |
| 5377 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5378 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5379 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5380 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 5381 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 5382 | |
| 5383 | if ((offset % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5384 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
| 5385 | "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 5386 | } |
| 5387 | return skip; |
| 5388 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5389 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5390 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 5391 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5392 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5393 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5394 | |
| 5395 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5396 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5397 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5398 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 5399 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 5400 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 5401 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5402 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5403 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 5404 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 5405 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 5406 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5407 | } |
| 5408 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5409 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5410 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5411 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 5412 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 5413 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 5414 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5415 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5416 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 5417 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 5418 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 5419 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5420 | } |
| 5421 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5422 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5423 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5424 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 5425 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 5426 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 5427 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5428 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5429 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 5430 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 5431 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 5432 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 5433 | } |
| 5434 | |
| 5435 | return skip; |
| 5436 | } |
| 5437 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 5438 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 5439 | VkPipelineBindPoint pipelineBindPoint, |
| 5440 | VkPipelineLayout layout, uint32_t set, |
| 5441 | uint32_t descriptorWriteCount, |
| 5442 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
Mike Schuchardt | 979898a | 2022-01-11 10:46:59 -0800 | [diff] [blame] | 5443 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true); |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 5444 | } |
| 5445 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5446 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 5447 | uint32_t firstExclusiveScissor, |
| 5448 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5449 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5450 | bool skip = false; |
| 5451 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5452 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5453 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5454 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5455 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 5456 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 5457 | ") is not 0.", |
| 5458 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5459 | } |
| 5460 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5461 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5462 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 5463 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 5464 | ") is not 1.", |
| 5465 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5466 | } |
| 5467 | } else { // multiViewport enabled |
| 5468 | 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] | 5469 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5470 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 5471 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 5472 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5473 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5474 | } |
| 5475 | } |
| 5476 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5477 | if (pExclusiveScissors) { |
| 5478 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 5479 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 5480 | |
| 5481 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5482 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 5483 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 5484 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5485 | } |
| 5486 | |
| 5487 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5488 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 5489 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 5490 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5491 | } |
| 5492 | |
| 5493 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 5494 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5495 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 5496 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5497 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5498 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5499 | } |
| 5500 | |
| 5501 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 5502 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5503 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 5504 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5505 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5506 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 5507 | } |
| 5508 | } |
| 5509 | } |
| 5510 | |
| 5511 | return skip; |
| 5512 | } |
| 5513 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 5514 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 5515 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5516 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 5517 | bool skip = false; |
Shannon McPherson | 169d0c7 | 2020-11-13 18:48:19 -0700 | [diff] [blame] | 5518 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 5519 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
| 5520 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 5521 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 5522 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 5523 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 5524 | } |
| 5525 | |
| 5526 | return skip; |
| 5527 | } |
| 5528 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5529 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 5530 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5531 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5532 | bool skip = false; |
| 5533 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5534 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5535 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5536 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5537 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 5538 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 5539 | ") is not 0.", |
| 5540 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5541 | } |
| 5542 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5543 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5544 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 5545 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 5546 | ") is not 1.", |
| 5547 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5548 | } |
| 5549 | } |
| 5550 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5551 | 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] | 5552 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5553 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 5554 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 5555 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5556 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5557 | } |
| 5558 | |
| 5559 | return skip; |
| 5560 | } |
| 5561 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5562 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 5563 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 5564 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5565 | bool skip = false; |
| 5566 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5567 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5568 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 5569 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 5570 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5571 | } |
| 5572 | |
| 5573 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5574 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 5575 | } |
| 5576 | |
| 5577 | return skip; |
| 5578 | } |
| 5579 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5580 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5581 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5582 | bool skip = false; |
| 5583 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5584 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5585 | skip |= LogError( |
| 5586 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5587 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 5588 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5589 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5590 | } |
| 5591 | |
| 5592 | return skip; |
| 5593 | } |
| 5594 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5595 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5596 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5597 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5598 | bool skip = false; |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 5599 | static const int condition_multiples = 0b0011; |
| 5600 | if (offset & condition_multiples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5601 | skip |= LogError( |
| 5602 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 5603 | "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] | 5604 | } |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 5605 | if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5606 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 5607 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 5608 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 5609 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 5610 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5611 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5612 | skip |= LogError( |
| 5613 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5614 | "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "", |
| 5615 | drawCount); |
Jeff Bolz | b574c34 | 2018-11-08 15:36:57 -0600 | [diff] [blame] | 5616 | } |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 5617 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 5618 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5619 | "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32 |
| 5620 | ") is not less than or equal to the maximum allowed (%" PRIu32 ").", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5621 | drawCount, device_limits.maxDrawIndirectCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 5622 | } |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5623 | return skip; |
| 5624 | } |
| 5625 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5626 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 5627 | VkDeviceSize offset, VkBuffer countBuffer, |
| 5628 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5629 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5630 | bool skip = false; |
| 5631 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5632 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5633 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 5634 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 5635 | "), is not a multiple of 4.", |
| 5636 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5637 | } |
| 5638 | |
| 5639 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5640 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 5641 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 5642 | "), is not a multiple of 4.", |
| 5643 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5644 | } |
| 5645 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 5646 | return skip; |
| 5647 | } |
| 5648 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5649 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5650 | const VkAllocationCallbacks *pAllocator, |
| 5651 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5652 | bool skip = false; |
| 5653 | |
| 5654 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 5655 | if (pCreateInfo != nullptr) { |
| 5656 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 5657 | // VkQueryPipelineStatisticFlagBits values |
| 5658 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 5659 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5660 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 5661 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 5662 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 5663 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5664 | } |
sfricke-samsung | 7d69d0d | 2020-04-25 10:27:27 -0700 | [diff] [blame] | 5665 | if (pCreateInfo->queryCount == 0) { |
| 5666 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763", |
| 5667 | "vkCreateQueryPool(): queryCount must be greater than zero."); |
| 5668 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 5669 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5670 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5671 | } |
| 5672 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5673 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 5674 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5675 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5676 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 5677 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5678 | } |
| 5679 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5680 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 5681 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 5682 | VkResult result) { |
| 5683 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5684 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5685 | } |
| 5686 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5687 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 5688 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 5689 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5690 | // 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] | 5691 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5692 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5693 | } |
| 5694 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 5695 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 5696 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5697 | // 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] | 5698 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 5699 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5700 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5701 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5702 | void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5703 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5704 | if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 5705 | auto lock = CBWriteLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5706 | for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) { |
Jeremy Gebben | fc6f815 | 2021-03-18 16:58:55 -0600 | [diff] [blame] | 5707 | secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5708 | } |
| 5709 | } |
| 5710 | } |
| 5711 | |
| 5712 | void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5713 | const VkCommandBuffer *pCommandBuffers) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 5714 | auto lock = CBWriteLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5715 | for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) { |
| 5716 | secondary_cb_map.erase(pCommandBuffers[cb_index]); |
| 5717 | } |
| 5718 | } |
| 5719 | |
| 5720 | void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5721 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 5722 | auto lock = CBWriteLock(); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5723 | for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) { |
| 5724 | if (item->second == commandPool) { |
| 5725 | item = secondary_cb_map.erase(item); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5726 | } else { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 5727 | ++item; |
| 5728 | } |
| 5729 | } |
| 5730 | } |
| 5731 | |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5732 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5733 | const VkAllocationCallbacks *pAllocator, |
| 5734 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5735 | bool skip = false; |
| 5736 | |
| 5737 | if (pAllocateInfo) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5738 | auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5739 | 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] | 5740 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 5741 | "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] | 5742 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5743 | |
| 5744 | VkMemoryAllocateFlags flags = 0; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5745 | auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5746 | if (flags_info) { |
| 5747 | flags = flags_info->flags; |
| 5748 | } |
| 5749 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5750 | auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5751 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5752 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5753 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 5754 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5755 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5756 | } |
| 5757 | |
| 5758 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5759 | auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5760 | #endif |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5761 | auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 5762 | auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5763 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5764 | auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5765 | #endif |
| 5766 | |
| 5767 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5768 | skip |= LogError( |
| 5769 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5770 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 5771 | } |
| 5772 | if ( |
| 5773 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 5774 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 5775 | #endif |
| 5776 | (import_memory_fd && import_memory_fd->handleType) || |
| 5777 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 5778 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 5779 | #endif |
| 5780 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5781 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 5782 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5783 | } |
| 5784 | } |
| 5785 | |
ziga-lunarg | 1d5e11d | 2021-07-18 13:13:40 +0200 | [diff] [blame] | 5786 | auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext); |
| 5787 | if (export_memory) { |
| 5788 | auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext); |
| 5789 | if (export_memory_nv) { |
| 5790 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640", |
| 5791 | "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and " |
| 5792 | "VkExportMemoryAllocateInfoNV"); |
| 5793 | } |
| 5794 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 5795 | auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext); |
| 5796 | if (export_memory_win32_nv) { |
| 5797 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640", |
| 5798 | "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and " |
| 5799 | "VkExportMemoryWin32HandleInfoNV"); |
| 5800 | } |
| 5801 | #endif |
| 5802 | } |
| 5803 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5804 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 5805 | VkBool32 capture_replay = false; |
| 5806 | VkBool32 buffer_device_address = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5807 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 5808 | if (vulkan_12_features) { |
| 5809 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 5810 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 5811 | } else { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5812 | const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 5813 | if (bda_features) { |
| 5814 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 5815 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 5816 | } |
| 5817 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5818 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5819 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5820 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5821 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5822 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5823 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5824 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5825 | "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] | 5826 | } |
| 5827 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5828 | } |
| 5829 | return skip; |
| 5830 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5831 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5832 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5833 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5834 | bool skip = false; |
| 5835 | |
| 5836 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 5837 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 5838 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5839 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5840 | } else { |
| 5841 | uint32_t vertex_component_size = 0; |
| 5842 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 5843 | vertex_component_size = 4; |
| 5844 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 5845 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 5846 | vertex_component_size = 2; |
| 5847 | } |
| 5848 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5849 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5850 | } |
| 5851 | } |
| 5852 | |
| 5853 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 5854 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5855 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5856 | } else { |
| 5857 | uint32_t index_element_size = 0; |
| 5858 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 5859 | index_element_size = 4; |
| 5860 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 5861 | index_element_size = 2; |
| 5862 | } |
| 5863 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5864 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5865 | } |
| 5866 | } |
| 5867 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 5868 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5869 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5870 | } |
| 5871 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5872 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5873 | } |
| 5874 | } |
| 5875 | |
| 5876 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5877 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5878 | } |
| 5879 | |
| 5880 | return skip; |
| 5881 | } |
| 5882 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5883 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 5884 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5885 | bool skip = false; |
| 5886 | |
| 5887 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5888 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5889 | } |
| 5890 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5891 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5892 | } |
| 5893 | |
| 5894 | return skip; |
| 5895 | } |
| 5896 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5897 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 5898 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5899 | bool skip = false; |
| 5900 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5901 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5902 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5903 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5904 | } |
| 5905 | return skip; |
| 5906 | } |
| 5907 | |
| 5908 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5909 | VkAccelerationStructureNV object_handle, const char *func_name, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5910 | bool is_cmd) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5911 | bool skip = false; |
| 5912 | 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] | 5913 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 5914 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 5915 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5916 | } |
| 5917 | 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] | 5918 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 5919 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 5920 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5921 | } |
ziga-lunarg | 10309ee | 2021-08-02 13:11:21 +0200 | [diff] [blame] | 5922 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 5923 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623", |
| 5924 | "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR."); |
| 5925 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5926 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 5927 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5928 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 5929 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 5930 | "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] | 5931 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5932 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5933 | skip |= LogError(object_handle, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5934 | is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241" |
| 5935 | : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5936 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 5937 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5938 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5939 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5940 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 5941 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 5942 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5943 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 5944 | 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] | 5945 | uint64_t total_triangle_count = 0; |
| 5946 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 5947 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5948 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5949 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5950 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5951 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 5952 | continue; |
| 5953 | } |
| 5954 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 5955 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5956 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5957 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 5958 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 5959 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5960 | } |
| 5961 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 5962 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 5963 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 5964 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 5965 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 5966 | if (geometry.geometryType != first_geometry_type) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5967 | skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 5968 | "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32 |
| 5969 | "].geometryType does not match " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5970 | "info.pGeometries[0].geometryType.", |
| 5971 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 5972 | } |
| 5973 | } |
| 5974 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5975 | for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) { |
| 5976 | if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV || |
| 5977 | info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) { |
| 5978 | skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503", |
| 5979 | "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV" |
| 5980 | "or VK_GEOMETRY_TYPE_AABBS_NV."); |
| 5981 | } |
| 5982 | } |
| 5983 | skip |= |
| 5984 | validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV, |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 5985 | info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5986 | return skip; |
| 5987 | } |
| 5988 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5989 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 5990 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5991 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5992 | bool skip = false; |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5993 | if (pCreateInfo) { |
| 5994 | if ((pCreateInfo->compactedSize != 0) && |
| 5995 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5996 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 5997 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 5998 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 5999 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6000 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6001 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6002 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6003 | "vkCreateAccelerationStructureNV()", false); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6004 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 6005 | return skip; |
| 6006 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6007 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6008 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 6009 | const VkAccelerationStructureInfoNV *pInfo, |
| 6010 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 6011 | VkBool32 update, VkAccelerationStructureNV dst, |
| 6012 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 6013 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6014 | bool skip = false; |
| 6015 | |
| 6016 | if (pInfo != nullptr) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6017 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6018 | } |
| 6019 | |
| 6020 | return skip; |
| 6021 | } |
| 6022 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6023 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR( |
| 6024 | VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 6025 | VkAccelerationStructureKHR *pAccelerationStructure) const { |
| 6026 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6027 | const auto *acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6028 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6029 | if (!acceleration_structure_features || |
| 6030 | (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) { |
| 6031 | skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611", |
| 6032 | "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled"); |
| 6033 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6034 | if (pCreateInfo) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6035 | if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR && |
| 6036 | (!acceleration_structure_features || |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6037 | (acceleration_structure_features && |
| 6038 | acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6039 | skip |= |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6040 | LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613", |
| 6041 | "vkCreateAccelerationStructureKHR(): If createFlags includes " |
| 6042 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, " |
| 6043 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6044 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6045 | if (pCreateInfo->deviceAddress && |
| 6046 | !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
| 6047 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612", |
| 6048 | "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include " |
| 6049 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR"); |
| 6050 | } |
ziga-lunarg | 8ddbe46 | 2021-09-06 16:14:17 +0200 | [diff] [blame] | 6051 | if (pCreateInfo->deviceAddress && (!acceleration_structure_features || |
| 6052 | (acceleration_structure_features && |
| 6053 | acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
| 6054 | skip |= LogError( |
| 6055 | device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488", |
| 6056 | "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but " |
| 6057 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled."); |
| 6058 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6059 | if (SafeModulo(pCreateInfo->offset, 256) != 0) { |
| 6060 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734", |
ziga-lunarg | 8ddbe46 | 2021-09-06 16:14:17 +0200 | [diff] [blame] | 6061 | "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", |
| 6062 | pCreateInfo->offset); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6063 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6064 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6065 | return skip; |
| 6066 | } |
| 6067 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6068 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 6069 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6070 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6071 | bool skip = false; |
| 6072 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6073 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 6074 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 6075 | } |
| 6076 | return skip; |
| 6077 | } |
| 6078 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6079 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV( |
| 6080 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures, |
| 6081 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 6082 | bool skip = false; |
Mark Lobodzinski | c0df6b6 | 2021-01-08 12:34:11 -0700 | [diff] [blame] | 6083 | if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 6084 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6085 | "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be " |
Mark Lobodzinski | c0df6b6 | 2021-01-08 12:34:11 -0700 | [diff] [blame] | 6086 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6087 | } |
| 6088 | return skip; |
| 6089 | } |
| 6090 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6091 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 6092 | uint32_t createInfoCount, |
| 6093 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 6094 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6095 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6096 | bool skip = false; |
| 6097 | |
| 6098 | for (uint32_t i = 0; i < createInfoCount; i++) { |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 6099 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 6100 | std::stringstream msg; |
| 6101 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 6102 | ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]); |
| 6103 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6104 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6105 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 6106 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6107 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 6108 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 6109 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 6110 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6111 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6112 | |
| 6113 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6114 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6115 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 6116 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 6117 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 6118 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905", |
| 6119 | "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled," |
| 6120 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 6121 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 6122 | } |
| 6123 | } |
| 6124 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6125 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 6126 | skip |= |
| 6127 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904", |
| 6128 | "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 6129 | } |
| 6130 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) && |
| 6131 | (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) { |
| 6132 | skip |= |
| 6133 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957", |
| 6134 | "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and" |
| 6135 | "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time."); |
| 6136 | } |
| 6137 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 6138 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6139 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 6140 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423", |
| 6141 | "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be " |
| 6142 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 6143 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 6144 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6145 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6146 | skip |= |
| 6147 | LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415", |
| 6148 | "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the" |
| 6149 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element" |
| 6150 | "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to " |
| 6151 | "that element."); |
| 6152 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6153 | } |
| 6154 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 6155 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6156 | skip |= |
| 6157 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422", |
| 6158 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 6159 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling" |
| 6160 | "commands pCreateInfos parameter."); |
| 6161 | } |
| 6162 | } else { |
| 6163 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6164 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424", |
| 6165 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 6166 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 6167 | } |
| 6168 | } |
| 6169 | } |
| 6170 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 6171 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456", |
| 6172 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR."); |
| 6173 | } |
| 6174 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) { |
| 6175 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458", |
| 6176 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6177 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR."); |
| 6178 | } |
| 6179 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) { |
| 6180 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459", |
| 6181 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6182 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR."); |
| 6183 | } |
| 6184 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) { |
| 6185 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460", |
| 6186 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6187 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR."); |
| 6188 | } |
| 6189 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) { |
| 6190 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461", |
| 6191 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6192 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR."); |
| 6193 | } |
| 6194 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 6195 | skip |= LogError( |
| 6196 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462", |
| 6197 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 6198 | } |
| 6199 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 6200 | skip |= LogError( |
| 6201 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463", |
| 6202 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 6203 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6204 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) { |
| 6205 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588", |
| 6206 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 6207 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 6208 | } |
| 6209 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 6210 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816", |
| 6211 | "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
| 6212 | } |
ziga-lunarg | dfffee4 | 2021-10-10 11:49:59 +0200 | [diff] [blame] | 6213 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) { |
| 6214 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948", |
| 6215 | "vkCreateRayTracingPipelinesNV: flags must not contain the " |
| 6216 | "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag."); |
| 6217 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 6218 | } |
| 6219 | |
| 6220 | return skip; |
| 6221 | } |
| 6222 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6223 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR( |
| 6224 | VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 6225 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6226 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6227 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6228 | if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) { |
| 6229 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586", |
| 6230 | "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6231 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6232 | for (uint32_t i = 0; i < createInfoCount; i++) { |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 6233 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 6234 | std::stringstream msg; |
| 6235 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 6236 | ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(), |
aitor-lunarg | dbd9e65 | 2022-02-23 19:12:53 +0100 | [diff] [blame] | 6237 | &pCreateInfos[i].pStages[stage_index]); |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 6238 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6239 | if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) { |
| 6240 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 6241 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596", |
| 6242 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 6243 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 6244 | } |
| 6245 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 6246 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597", |
| 6247 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 6248 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR."); |
| 6249 | } |
| 6250 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6251 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6252 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Nathaniel Cesario | 6a0ce2f | 2022-04-02 21:47:54 -0600 | [diff] [blame] | 6253 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6254 | "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32 |
| 6255 | "], When chained to VkRayTracingPipelineCreateInfoKHR, " |
| 6256 | "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6257 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").", |
| 6258 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
| 6259 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6260 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6261 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6262 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 6263 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 6264 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 6265 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6266 | "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled," |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6267 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 6268 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 6269 | } |
| 6270 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6271 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6272 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904", |
| 6273 | "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6274 | } |
| 6275 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6276 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6277 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6278 | "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, " |
| 6279 | "pLibraryInterface must not be NULL."); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6280 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6281 | } |
| 6282 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 6283 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816", |
| 6284 | "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6285 | } |
| 6286 | for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) { |
| 6287 | if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) || |
| 6288 | (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) { |
| 6289 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) && |
| 6290 | (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) { |
| 6291 | skip |= LogError( |
| 6292 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6293 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 6294 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6295 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 6296 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element " |
| 6297 | "must not be VK_SHADER_UNUSED_KHR"); |
| 6298 | } |
| 6299 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) && |
| 6300 | (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) { |
| 6301 | skip |= LogError( |
| 6302 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6303 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 6304 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6305 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 6306 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that " |
| 6307 | "element must not be VK_SHADER_UNUSED_KHR"); |
| 6308 | } |
| 6309 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6310 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE && |
| 6311 | pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) { |
| 6312 | if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) { |
| 6313 | skip |= LogError( |
| 6314 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599", |
| 6315 | "vkCreateRayTracingPipelinesKHR: If " |
| 6316 | "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is " |
| 6317 | "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must " |
| 6318 | "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 6319 | } |
| 6320 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6321 | } |
| 6322 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 6323 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6324 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 6325 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6326 | "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be " |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6327 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 6328 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 6329 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6330 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 6331 | skip |= |
| 6332 | LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415", |
| 6333 | "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the" |
| 6334 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is" |
| 6335 | "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that " |
| 6336 | "element."); |
| 6337 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6338 | } |
| 6339 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 6340 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6341 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6342 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6343 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32 |
| 6344 | ") must be a valid into the calling" |
| 6345 | "commands pCreateInfos parameter %" PRIu32 ".", |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6346 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 6347 | } |
| 6348 | } else { |
| 6349 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 6350 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6351 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 6352 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 6353 | } |
| 6354 | } |
| 6355 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6356 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR && |
| 6357 | (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) { |
| 6358 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598", |
| 6359 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 6360 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, " |
| 6361 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled."); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6362 | } |
| 6363 | bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library); |
| 6364 | if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) { |
| 6365 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595", |
| 6366 | "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, " |
| 6367 | "pLibraryInfo and pLibraryInterface must be NULL."); |
| 6368 | } |
| 6369 | if (pCreateInfos[i].pLibraryInfo) { |
| 6370 | if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) { |
| 6371 | if (pCreateInfos[i].stageCount == 0) { |
| 6372 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600", |
| 6373 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 6374 | "stageCount must not be 0."); |
| 6375 | } |
| 6376 | if (pCreateInfos[i].groupCount == 0) { |
| 6377 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601", |
| 6378 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 6379 | "groupCount must not be 0."); |
| 6380 | } |
| 6381 | } else { |
| 6382 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
| 6383 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590", |
| 6384 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member " |
| 6385 | "is greater than 0, its " |
| 6386 | "pLibraryInterface member must not be NULL."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6387 | } |
| 6388 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6389 | } |
| 6390 | if (pCreateInfos[i].pLibraryInterface) { |
| 6391 | if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize > |
| 6392 | phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) { |
| 6393 | skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605", |
| 6394 | "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to " |
| 6395 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize."); |
| 6396 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6397 | } |
| 6398 | if (deferredOperation != VK_NULL_HANDLE) { |
| 6399 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) { |
| 6400 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587", |
| 6401 | "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of " |
| 6402 | "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] | 6403 | } |
| 6404 | } |
ziga-lunarg | dea7658 | 2021-09-17 14:38:08 +0200 | [diff] [blame] | 6405 | if (pCreateInfos[i].pDynamicState) { |
| 6406 | for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) { |
| 6407 | if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) { |
| 6408 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602", |
| 6409 | "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32 |
| 6410 | "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.", |
| 6411 | i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j])); |
| 6412 | } |
| 6413 | } |
| 6414 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 6415 | } |
| 6416 | |
| 6417 | return skip; |
| 6418 | } |
| 6419 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6420 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 6421 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 6422 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6423 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6424 | bool skip = false; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6425 | if (!IsExtEnabled(device_extensions.vk_khr_swapchain)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6426 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6427 | if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6428 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6429 | if (!IsExtEnabled(device_extensions.vk_khr_surface)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6430 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6431 | if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6432 | skip |= |
| 6433 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 6434 | if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6435 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 6436 | skip |= validate_struct_type( |
| 6437 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 6438 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 6439 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 6440 | if (pSurfaceInfo != NULL) { |
| 6441 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 6442 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 6443 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 6444 | |
| 6445 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 6446 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 6447 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 6448 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 6449 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 6450 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6451 | |
Mike Schuchardt | 05b028d | 2022-01-05 14:15:00 -0800 | [diff] [blame] | 6452 | if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 6453 | skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521", |
| 6454 | "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 6455 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 6456 | } |
| 6457 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 6458 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 6459 | } |
| 6460 | return skip; |
| 6461 | } |
| 6462 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 6463 | |
| 6464 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 6465 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6466 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 6467 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 6468 | bool skip = false; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 6469 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 6470 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 6471 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 6472 | } |
| 6473 | return skip; |
| 6474 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 6475 | |
| 6476 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6477 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 6478 | bool skip = false; |
| 6479 | |
| 6480 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6481 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6482 | "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 6483 | } |
| 6484 | |
| 6485 | return skip; |
| 6486 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 6487 | |
| 6488 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6489 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 6490 | bool skip = false; |
| 6491 | |
| 6492 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6493 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 6494 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 6495 | } |
| 6496 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6497 | const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext); |
Mark Lobodzinski | 804fde8 | 2020-05-08 07:49:25 -0600 | [diff] [blame] | 6498 | 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] | 6499 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 6500 | "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] | 6501 | } |
| 6502 | |
| 6503 | return skip; |
| 6504 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6505 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6506 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 6507 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 6508 | const VkDeviceSize *pOffsets) const { |
| 6509 | bool skip = false; |
| 6510 | if (firstBinding > device_limits.maxVertexInputBindings) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6511 | skip |= |
| 6512 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 6513 | "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", |
| 6514 | firstBinding, device_limits.maxVertexInputBindings); |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6515 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 6516 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6517 | "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32 |
| 6518 | ") must be less than " |
| 6519 | "maxVertexInputBindings (%" PRIu32 ")", |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6520 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 6521 | } |
| 6522 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6523 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 6524 | if (pBuffers[i] == VK_NULL_HANDLE) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6525 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6526 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6527 | skip |= |
| 6528 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001", |
| 6529 | "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6530 | } else { |
| 6531 | if (pOffsets[i] != 0) { |
| 6532 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6533 | "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 |
| 6534 | "] is not 0", |
| 6535 | i, i); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 6536 | } |
| 6537 | } |
| 6538 | } |
| 6539 | } |
| 6540 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 6541 | return skip; |
| 6542 | } |
| 6543 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6544 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6545 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6546 | bool skip = false; |
| 6547 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6548 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 6549 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6550 | } |
| 6551 | return skip; |
| 6552 | } |
| 6553 | |
| 6554 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 6555 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6556 | bool skip = false; |
| 6557 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6558 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 6559 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 6560 | } |
| 6561 | return skip; |
| 6562 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 6563 | |
| 6564 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 6565 | VkSemaphore semaphore, VkFence fence, |
| 6566 | uint32_t *pImageIndex) const { |
| 6567 | bool skip = false; |
| 6568 | |
| 6569 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6570 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 6571 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 6572 | } |
| 6573 | |
| 6574 | return skip; |
| 6575 | } |
| 6576 | |
| 6577 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 6578 | uint32_t *pImageIndex) const { |
| 6579 | bool skip = false; |
| 6580 | |
| 6581 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6582 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 6583 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 6584 | } |
| 6585 | |
| 6586 | return skip; |
| 6587 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6588 | |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 6589 | bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, |
| 6590 | uint32_t firstBinding, uint32_t bindingCount, |
| 6591 | const VkBuffer *pBuffers, |
| 6592 | const VkDeviceSize *pOffsets, |
| 6593 | const VkDeviceSize *pSizes) const { |
| 6594 | bool skip = false; |
| 6595 | |
| 6596 | char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT"; |
| 6597 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 6598 | if (pOffsets[i] & 3) { |
| 6599 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359", |
| 6600 | "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]); |
| 6601 | } |
| 6602 | } |
| 6603 | |
| 6604 | if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6605 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356", |
| 6606 | "%s: The firstBinding(%" PRIu32 |
| 6607 | ") index is greater than or equal to " |
| 6608 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6609 | cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6610 | } |
| 6611 | |
| 6612 | if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6613 | skip |= |
| 6614 | LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357", |
| 6615 | "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32 |
| 6616 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6617 | cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6618 | } |
| 6619 | |
| 6620 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 6621 | // pSizes is optional and may be nullptr. |
| 6622 | if (pSizes != nullptr) { |
| 6623 | if (pSizes[i] != VK_WHOLE_SIZE && |
| 6624 | pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) { |
| 6625 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361", |
| 6626 | "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64 |
| 6627 | ") is not VK_WHOLE_SIZE and is greater than " |
| 6628 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.", |
| 6629 | cmd_name, i, pSizes[i]); |
| 6630 | } |
| 6631 | } |
| 6632 | } |
| 6633 | |
| 6634 | return skip; |
| 6635 | } |
| 6636 | |
| 6637 | bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 6638 | uint32_t firstCounterBuffer, |
| 6639 | uint32_t counterBufferCount, |
| 6640 | const VkBuffer *pCounterBuffers, |
| 6641 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 6642 | bool skip = false; |
| 6643 | |
| 6644 | char const *const cmd_name = "CmdBeginTransformFeedbackEXT"; |
| 6645 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6646 | skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368", |
| 6647 | "%s: The firstCounterBuffer(%" PRIu32 |
| 6648 | ") index is greater than or equal to " |
| 6649 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6650 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6651 | } |
| 6652 | |
| 6653 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6654 | skip |= |
| 6655 | LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369", |
| 6656 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 6657 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6658 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 6659 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6660 | } |
| 6661 | |
| 6662 | return skip; |
| 6663 | } |
| 6664 | |
| 6665 | bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 6666 | uint32_t firstCounterBuffer, uint32_t counterBufferCount, |
| 6667 | const VkBuffer *pCounterBuffers, |
| 6668 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 6669 | bool skip = false; |
| 6670 | |
| 6671 | char const *const cmd_name = "CmdEndTransformFeedbackEXT"; |
| 6672 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6673 | skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376", |
| 6674 | "%s: The firstCounterBuffer(%" PRIu32 |
| 6675 | ") index is greater than or equal to " |
| 6676 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6677 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6678 | } |
| 6679 | |
| 6680 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 6681 | skip |= |
| 6682 | LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377", |
| 6683 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 6684 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 6685 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 6686 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 6687 | } |
| 6688 | |
| 6689 | return skip; |
| 6690 | } |
| 6691 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6692 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 6693 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 6694 | VkDeviceSize counterBufferOffset, |
| 6695 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 6696 | bool skip = false; |
| 6697 | |
| 6698 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 6699 | skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
| 6700 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32 |
| 6701 | ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").", |
| 6702 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6703 | } |
| 6704 | |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 6705 | if ((counterOffset % 4) != 0) { |
sfricke-samsung | 6886c4b | 2021-01-16 08:37:35 -0800 | [diff] [blame] | 6706 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 6707 | "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset); |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 6708 | } |
| 6709 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 6710 | return skip; |
| 6711 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6712 | |
| 6713 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 6714 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 6715 | const VkAllocationCallbacks *pAllocator, |
| 6716 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 6717 | const char *apiName) const { |
| 6718 | bool skip = false; |
| 6719 | |
| 6720 | // Check samplerYcbcrConversion feature is set |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6721 | const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6722 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6723 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 6724 | if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) { |
| 6725 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6726 | "%s: samplerYcbcrConversion must be enabled.", apiName); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 6727 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6728 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6729 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6730 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6731 | const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6732 | 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] | 6733 | #else |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6734 | const bool is_external_format = false; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6735 | #endif |
| 6736 | |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6737 | const VkFormat format = pCreateInfo->format; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6738 | |
| 6739 | // 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] | 6740 | if (!is_external_format) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6741 | const VkComponentMapping components = pCreateInfo->components; |
| 6742 | // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec |
| 6743 | if (FormatIsXChromaSubsampled(format) == true) { |
| 6744 | if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) { |
| 6745 | skip |= |
| 6746 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6747 | "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G " |
| 6748 | "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6749 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6750 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6751 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6752 | if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 6753 | (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) { |
| 6754 | skip |= LogError( |
| 6755 | device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582", |
| 6756 | "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or " |
| 6757 | "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.", |
| 6758 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a)); |
| 6759 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6760 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6761 | if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 6762 | (components.r != VK_COMPONENT_SWIZZLE_B)) { |
| 6763 | skip |= |
| 6764 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6765 | "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R " |
| 6766 | "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] | 6767 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6768 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6769 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6770 | if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 6771 | (components.b != VK_COMPONENT_SWIZZLE_R)) { |
| 6772 | skip |= |
| 6773 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6774 | "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B " |
| 6775 | "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] | 6776 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6777 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6778 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6779 | // If one is identity, both need to be |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6780 | const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 6781 | const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 6782 | if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6783 | skip |= |
| 6784 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6785 | "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) " |
| 6786 | "are an identity swizzle, then both need to be an identity swizzle.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6787 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r), |
| 6788 | string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6789 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6790 | } |
| 6791 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6792 | if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) { |
| 6793 | // Checks same VU multiple ways in order to give a more useful error message |
| 6794 | const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655"; |
| 6795 | if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) || |
| 6796 | (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) || |
| 6797 | (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) { |
| 6798 | skip |= LogError( |
| 6799 | device, vuid, |
| 6800 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6801 | "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.", |
| 6802 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6803 | string_VkComponentSwizzle(components.b)); |
| 6804 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6805 | |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6806 | // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA" |
| 6807 | // 4 component format = no issue |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6808 | // 3 = no [a] |
| 6809 | // 2 = no [b,a] |
| 6810 | // 1 = no [g,b,a] |
| 6811 | // 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] | 6812 | const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6813 | |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6814 | if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) || |
| 6815 | (components.b == VK_COMPONENT_SWIZZLE_A))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6816 | skip |= LogError(device, vuid, |
| 6817 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6818 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.", |
| 6819 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6820 | string_VkComponentSwizzle(components.b)); |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6821 | } else if ((component_count < 3) && |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6822 | ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) || |
| 6823 | (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) { |
| 6824 | skip |= LogError(device, vuid, |
| 6825 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6826 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B " |
| 6827 | "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 6828 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6829 | string_VkComponentSwizzle(components.b)); |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6830 | } else if ((component_count < 2) && |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6831 | ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) || |
| 6832 | (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) { |
| 6833 | skip |= LogError(device, vuid, |
| 6834 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6835 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G " |
| 6836 | "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 6837 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6838 | string_VkComponentSwizzle(components.b)); |
| 6839 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6840 | } |
| 6841 | } |
| 6842 | |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6843 | return skip; |
| 6844 | } |
| 6845 | |
| 6846 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 6847 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 6848 | const VkAllocationCallbacks *pAllocator, |
| 6849 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 6850 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 6851 | "vkCreateSamplerYcbcrConversion"); |
| 6852 | } |
| 6853 | |
| 6854 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 6855 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 6856 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 6857 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 6858 | "vkCreateSamplerYcbcrConversionKHR"); |
| 6859 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 6860 | |
| 6861 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR( |
| 6862 | VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const { |
| 6863 | bool skip = false; |
| 6864 | VkExternalSemaphoreHandleTypeFlags supported_handle_types = |
| 6865 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 6866 | |
| 6867 | if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6868 | skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", |
| 6869 | "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).", |
| 6870 | report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(), |
| 6871 | string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType), |
| 6872 | string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 6873 | } |
| 6874 | return skip; |
| 6875 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6876 | |
| 6877 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6878 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6879 | bool skip = false; |
| 6880 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 6881 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 6882 | "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 6883 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6884 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6885 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 6886 | skip |= LogError( |
| 6887 | device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584", |
| 6888 | "vkCopyAccelerationStructureToMemoryKHR: The " |
| 6889 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 6890 | } |
| 6891 | skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress, |
| 6892 | "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732"); |
| 6893 | if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) { |
| 6894 | skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751", |
| 6895 | "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes."); |
| 6896 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6897 | return skip; |
| 6898 | } |
| 6899 | |
| 6900 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR( |
| 6901 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 6902 | bool skip = false; |
| 6903 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 6904 | skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update |
| 6905 | LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 6906 | "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 6907 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6908 | if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) { |
| 6909 | skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 6910 | "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6911 | pInfo->dst.deviceAddress); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6912 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6913 | return skip; |
| 6914 | } |
| 6915 | |
| 6916 | bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 6917 | const char *api_name) const { |
| 6918 | bool skip = false; |
| 6919 | if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR || |
| 6920 | pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) { |
| 6921 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410", |
| 6922 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR" |
| 6923 | "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.", |
| 6924 | api_name); |
| 6925 | } |
| 6926 | return skip; |
| 6927 | } |
| 6928 | |
| 6929 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6930 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6931 | bool skip = false; |
| 6932 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()"); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6933 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6934 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6935 | skip |= LogError( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6936 | device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582", |
| 6937 | "vkCopyAccelerationStructureKHR: The " |
| 6938 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6939 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6940 | return skip; |
| 6941 | } |
| 6942 | |
| 6943 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR( |
| 6944 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 6945 | bool skip = false; |
| 6946 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()"); |
| 6947 | return skip; |
| 6948 | } |
| 6949 | |
| 6950 | bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 6951 | const char *api_name, bool is_cmd) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6952 | bool skip = false; |
| 6953 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6954 | skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413", |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6955 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name); |
| 6956 | } |
| 6957 | return skip; |
| 6958 | } |
| 6959 | |
| 6960 | bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6961 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6962 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6963 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6964 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6965 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 6966 | skip |= LogError( |
| 6967 | device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583", |
| 6968 | "vkCopyMemoryToAccelerationStructureKHR: The " |
| 6969 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6970 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6971 | skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress, |
| 6972 | "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6973 | return skip; |
| 6974 | } |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 6975 | |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6976 | bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR( |
| 6977 | VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 6978 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6979 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6980 | if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) { |
| 6981 | skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 6982 | "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6983 | pInfo->src.deviceAddress); |
| 6984 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6985 | return skip; |
| 6986 | } |
| 6987 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR( |
| 6988 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 6989 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 6990 | bool skip = false; |
| 6991 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 6992 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 6993 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 6994 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 6995 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 6996 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 6997 | } |
| 6998 | return skip; |
| 6999 | } |
| 7000 | bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR( |
| 7001 | VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 7002 | VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const { |
| 7003 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7004 | const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7005 | if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 7006 | skip |= LogError( |
| 7007 | device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585", |
| 7008 | "vkCmdWriteAccelerationStructuresPropertiesKHR: The " |
| 7009 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 7010 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7011 | if (dataSize < accelerationStructureCount * stride) { |
| 7012 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452", |
| 7013 | "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to " |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 7014 | "accelerationStructureCount (%" PRIu32 ") *stride(%zu).", |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7015 | dataSize, accelerationStructureCount, stride); |
| 7016 | } |
| 7017 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 7018 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 7019 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 7020 | "vkWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 7021 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 7022 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 7023 | } |
| 7024 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) { |
| 7025 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 7026 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448", |
| 7027 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 7028 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR," |
| 7029 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 7030 | stride); |
| 7031 | } |
| 7032 | } |
| 7033 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) { |
| 7034 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 7035 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450", |
| 7036 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 7037 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR," |
| 7038 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 7039 | stride); |
| 7040 | } |
| 7041 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7042 | return skip; |
| 7043 | } |
| 7044 | bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR( |
| 7045 | VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const { |
| 7046 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7047 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7048 | if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) { |
| 7049 | skip |= LogError( |
| 7050 | device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606", |
| 7051 | "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::" |
| 7052 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7053 | } |
| 7054 | return skip; |
| 7055 | } |
| 7056 | |
| 7057 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7058 | const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 7059 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, |
| 7060 | const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 7061 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7062 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 7063 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7064 | // RayGen |
| 7065 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 7066 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023", |
| 7067 | "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] | 7068 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7069 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7070 | 0) { |
| 7071 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682", |
| 7072 | "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 7073 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7074 | } |
| 7075 | // Callable |
| 7076 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7077 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694", |
| 7078 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 7079 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7080 | } |
| 7081 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7082 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041", |
| 7083 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7084 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7085 | } |
| 7086 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7087 | 0) { |
| 7088 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693", |
| 7089 | "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 7090 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7091 | } |
| 7092 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7093 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7094 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690", |
| 7095 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 7096 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7097 | } |
| 7098 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7099 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7100 | "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to " |
| 7101 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7102 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7103 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7104 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689", |
| 7105 | "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 7106 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7107 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7108 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7109 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7110 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686", |
| 7111 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of " |
| 7112 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7113 | } |
| 7114 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7115 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029", |
| 7116 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7117 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7118 | } |
| 7119 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7120 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685", |
| 7121 | "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 7122 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7123 | } |
| 7124 | if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) { |
| 7125 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629", |
| 7126 | "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to " |
| 7127 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount"); |
| 7128 | } |
| 7129 | if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) { |
| 7130 | skip |= |
| 7131 | LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626", |
| 7132 | "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] " |
| 7133 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7134 | } |
| 7135 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7136 | if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) { |
| 7137 | skip |= |
| 7138 | LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627", |
| 7139 | "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] " |
| 7140 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]"); |
| 7141 | } |
| 7142 | |
| 7143 | if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) { |
| 7144 | skip |= |
| 7145 | LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628", |
| 7146 | "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] " |
| 7147 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7148 | } |
| 7149 | return skip; |
| 7150 | } |
| 7151 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7152 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR( |
| 7153 | VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 7154 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 7155 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7156 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7157 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7158 | if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) { |
| 7159 | skip |= LogError( |
| 7160 | device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637", |
| 7161 | "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect " |
| 7162 | "feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7163 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7164 | // RayGen |
| 7165 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 7166 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023", |
| 7167 | "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] | 7168 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7169 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7170 | 0) { |
| 7171 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682", |
| 7172 | "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 7173 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7174 | } |
| 7175 | // Callabe |
| 7176 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7177 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694", |
| 7178 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 7179 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7180 | } |
| 7181 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7182 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7183 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal " |
| 7184 | "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7185 | } |
| 7186 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 7187 | 0) { |
| 7188 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693", |
| 7189 | "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 7190 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7191 | } |
| 7192 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7193 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7194 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690", |
| 7195 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 7196 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7197 | } |
| 7198 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7199 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7200 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to " |
| 7201 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7202 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7203 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7204 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689", |
| 7205 | "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 7206 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 7207 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7208 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7209 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 7210 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686", |
| 7211 | "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of " |
| 7212 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7213 | } |
| 7214 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 7215 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7216 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to " |
| 7217 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 7218 | } |
| 7219 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 7220 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685", |
| 7221 | "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 7222 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7223 | } |
| 7224 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7225 | if (SafeModulo(indirectDeviceAddress, 4) != 0) { |
| 7226 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634", |
| 7227 | "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7228 | } |
| 7229 | return skip; |
| 7230 | } |
| 7231 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV( |
| 7232 | VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, |
| 7233 | VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 7234 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, |
| 7235 | VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 7236 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 7237 | bool skip = false; |
| 7238 | if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7239 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462", |
| 7240 | "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of " |
| 7241 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7242 | } |
| 7243 | if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 7244 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465", |
| 7245 | "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of " |
| 7246 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 7247 | } |
| 7248 | if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 7249 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468", |
| 7250 | "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to " |
| 7251 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. "); |
| 7252 | } |
| 7253 | |
| 7254 | // hitShader |
| 7255 | if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7256 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460", |
| 7257 | "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of " |
| 7258 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7259 | } |
| 7260 | if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 7261 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464", |
| 7262 | "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of " |
| 7263 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 7264 | } |
| 7265 | if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 7266 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467", |
| 7267 | "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to " |
| 7268 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 7269 | } |
| 7270 | |
| 7271 | // missShader |
| 7272 | if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7273 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458", |
| 7274 | "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of " |
| 7275 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7276 | } |
| 7277 | if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 7278 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463", |
| 7279 | "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of " |
| 7280 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 7281 | } |
| 7282 | if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 7283 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466", |
| 7284 | "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to " |
| 7285 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 7286 | } |
| 7287 | |
| 7288 | // raygenShader |
| 7289 | if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 7290 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456", |
| 7291 | "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of " |
sourav parmar | d152180 | 2020-06-07 21:49:02 -0700 | [diff] [blame] | 7292 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 7293 | } |
| 7294 | if (width > device_limits.maxComputeWorkGroupCount[0]) { |
| 7295 | skip |= |
| 7296 | LogError(device, "VUID-vkCmdTraceRaysNV-width-02469", |
| 7297 | "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o]."); |
| 7298 | } |
| 7299 | if (height > device_limits.maxComputeWorkGroupCount[1]) { |
| 7300 | skip |= |
| 7301 | LogError(device, "VUID-vkCmdTraceRaysNV-height-02470", |
| 7302 | "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1]."); |
| 7303 | } |
| 7304 | if (depth > device_limits.maxComputeWorkGroupCount[2]) { |
| 7305 | skip |= |
| 7306 | LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471", |
| 7307 | "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2]."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7308 | } |
| 7309 | return skip; |
| 7310 | } |
| 7311 | |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7312 | bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7313 | VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo, |
| 7314 | VkAccelerationStructureCompatibilityKHR *pCompatibility) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7315 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7316 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
| 7317 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 7318 | if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) || |
| 7319 | (raytracing_features && !raytracing_features->rayTracingPipeline))) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7320 | skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661", |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 7321 | "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled."); |
| 7322 | } |
| 7323 | return skip; |
| 7324 | } |
| 7325 | |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7326 | bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 7327 | const VkViewport *pViewports, bool is_ext) const { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7328 | bool skip = false; |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7329 | const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount"; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7330 | |
| 7331 | if (!physical_device_features.multiViewport) { |
| 7332 | if (viewportCount != 1) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7333 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395", |
| 7334 | "%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] | 7335 | viewportCount); |
| 7336 | } |
| 7337 | } else { // multiViewport enabled |
| 7338 | if (viewportCount < 1 || viewportCount > device_limits.maxViewports) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7339 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394", |
| 7340 | "%s: viewportCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7341 | ") must " |
| 7342 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7343 | api_call, viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7344 | } |
| 7345 | } |
| 7346 | |
| 7347 | if (pViewports) { |
| 7348 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 7349 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7350 | skip |= manual_PreCallValidateViewport( |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7351 | viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7352 | } |
| 7353 | } |
| 7354 | |
| 7355 | return skip; |
| 7356 | } |
| 7357 | |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7358 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 7359 | const VkViewport *pViewports) const { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7360 | bool skip = false; |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7361 | skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true); |
| 7362 | return skip; |
| 7363 | } |
| 7364 | |
| 7365 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 7366 | const VkViewport *pViewports) const { |
| 7367 | bool skip = false; |
| 7368 | skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false); |
| 7369 | return skip; |
| 7370 | } |
| 7371 | |
| 7372 | bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 7373 | const VkRect2D *pScissors, bool is_ext) const { |
| 7374 | bool skip = false; |
| 7375 | const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount"; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7376 | |
| 7377 | if (!physical_device_features.multiViewport) { |
| 7378 | if (scissorCount != 1) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7379 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398", |
| 7380 | "%s: scissorCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7381 | ") must " |
| 7382 | "be 1 when the multiViewport feature is disabled.", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7383 | api_call, scissorCount); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7384 | } |
| 7385 | } else { // multiViewport enabled |
| 7386 | if (scissorCount == 0) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7387 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397", |
| 7388 | "%s: scissorCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7389 | ") must " |
| 7390 | "be great than zero.", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7391 | api_call, scissorCount); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7392 | } else if (scissorCount > device_limits.maxViewports) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7393 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397", |
| 7394 | "%s: scissorCount (=%" PRIu32 |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7395 | ") must " |
| 7396 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7397 | api_call, scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7398 | } |
| 7399 | } |
| 7400 | |
| 7401 | if (pScissors) { |
| 7402 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 7403 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
| 7404 | |
| 7405 | if (scissor.offset.x < 0) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7406 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call, |
| 7407 | scissor_i, scissor.offset.x); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7408 | } |
| 7409 | |
| 7410 | if (scissor.offset.y < 0) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7411 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call, |
| 7412 | scissor_i, scissor.offset.y); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7413 | } |
| 7414 | |
| 7415 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 7416 | if (x_sum > INT32_MAX) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7417 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400", |
| 7418 | "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32 |
| 7419 | "] will overflow int32_t.", |
| 7420 | api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7421 | } |
| 7422 | |
| 7423 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 7424 | if (y_sum > INT32_MAX) { |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7425 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401", |
| 7426 | "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32 |
| 7427 | "] will overflow int32_t.", |
| 7428 | api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
| 7429 | } |
| 7430 | } |
| 7431 | } |
| 7432 | |
| 7433 | return skip; |
| 7434 | } |
| 7435 | |
| 7436 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 7437 | const VkRect2D *pScissors) const { |
| 7438 | bool skip = false; |
| 7439 | skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true); |
| 7440 | return skip; |
| 7441 | } |
| 7442 | |
| 7443 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 7444 | const VkRect2D *pScissors) const { |
| 7445 | bool skip = false; |
| 7446 | skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false); |
| 7447 | return skip; |
| 7448 | } |
| 7449 | |
| 7450 | bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, |
| 7451 | const VkBuffer *pBuffers, const VkDeviceSize *pOffsets, |
| 7452 | const VkDeviceSize *pSizes, const VkDeviceSize *pStrides, |
| 7453 | bool is_2ext) const { |
| 7454 | bool skip = false; |
| 7455 | const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()"; |
| 7456 | if (firstBinding >= device_limits.maxVertexInputBindings) { |
| 7457 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355", |
| 7458 | "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call, |
| 7459 | firstBinding, device_limits.maxVertexInputBindings); |
| 7460 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 7461 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356", |
| 7462 | "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32 |
| 7463 | ") must be less than " |
| 7464 | "maxVertexInputBindings (%" PRIu32 ")", |
| 7465 | api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 7466 | } |
| 7467 | |
| 7468 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 7469 | if (pBuffers[i] == VK_NULL_HANDLE) { |
| 7470 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 7471 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 7472 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111", |
| 7473 | "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i); |
| 7474 | } else { |
| 7475 | if (pOffsets[i] != 0) { |
| 7476 | skip |= |
| 7477 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112", |
| 7478 | "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i); |
| 7479 | } |
| 7480 | } |
| 7481 | } |
| 7482 | if (pStrides) { |
| 7483 | if (pStrides[i] > device_limits.maxVertexInputBindingStride) { |
| 7484 | skip |= |
| 7485 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362", |
| 7486 | "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")", |
| 7487 | api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7488 | } |
| 7489 | } |
| 7490 | } |
| 7491 | |
| 7492 | return skip; |
| 7493 | } |
| 7494 | |
| 7495 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 7496 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 7497 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 7498 | const VkDeviceSize *pStrides) const { |
| 7499 | bool skip = false; |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7500 | skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true); |
| 7501 | return skip; |
| 7502 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7503 | |
Tony-LunarG | 3f953ba | 2021-10-15 15:35:39 -0600 | [diff] [blame] | 7504 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 7505 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 7506 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 7507 | const VkDeviceSize *pStrides) const { |
| 7508 | bool skip = false; |
| 7509 | skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 7510 | return skip; |
| 7511 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7512 | |
| 7513 | bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR( |
| 7514 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const { |
| 7515 | bool skip = false; |
| 7516 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 7517 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 7518 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654", |
| 7519 | "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name); |
| 7520 | } |
| 7521 | if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR && |
| 7522 | pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) { |
| 7523 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796", |
| 7524 | "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set," |
| 7525 | "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.", |
| 7526 | api_name); |
| 7527 | } |
| 7528 | if (pInfos[i].pGeometries && pInfos[i].ppGeometries) { |
| 7529 | skip |= |
| 7530 | LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788", |
| 7531 | "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name); |
| 7532 | } |
| 7533 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) { |
| 7534 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790", |
| 7535 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name); |
| 7536 | } |
| 7537 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && |
| 7538 | pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) { |
| 7539 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793", |
| 7540 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be" |
| 7541 | " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount", |
| 7542 | api_name); |
| 7543 | } |
| 7544 | if (pInfos[i].pGeometries) { |
| 7545 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 7546 | skip |= validate_ranged_enum( |
| 7547 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}), |
| 7548 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType, |
| 7549 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 7550 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7551 | skip |= validate_struct_type( |
| 7552 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}), |
| 7553 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 7554 | &(pInfos[i].pGeometries[j].geometry.triangles), |
| 7555 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 7556 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 7557 | skip |= validate_struct_pnext( |
| 7558 | api_name, |
| 7559 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 7560 | NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 7561 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 7562 | skip |= |
| 7563 | validate_ranged_enum(api_name, |
| 7564 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat", |
| 7565 | ParameterName::IndexVector{i, j}), |
| 7566 | "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat, |
| 7567 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 7568 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 7569 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 7570 | &pInfos[i].pGeometries[j].geometry.triangles, |
| 7571 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 7572 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 7573 | skip |= validate_ranged_enum( |
| 7574 | api_name, |
| 7575 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}), |
| 7576 | "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType, |
| 7577 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 7578 | |
| 7579 | if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) { |
| 7580 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 7581 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 7582 | } |
| 7583 | if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 7584 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 7585 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 7586 | skip |= |
| 7587 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 7588 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 7589 | api_name); |
| 7590 | } |
| 7591 | } |
| 7592 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7593 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 7594 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 7595 | &pInfos[i].pGeometries[j].geometry.instances, |
| 7596 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 7597 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 7598 | skip |= validate_struct_type( |
| 7599 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}), |
| 7600 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 7601 | &(pInfos[i].pGeometries[j].geometry.instances), |
| 7602 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 7603 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 7604 | skip |= validate_struct_pnext( |
| 7605 | api_name, |
| 7606 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 7607 | NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 7608 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 7609 | |
| 7610 | skip |= validate_bool32(api_name, |
| 7611 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers", |
| 7612 | ParameterName::IndexVector{i, j}), |
| 7613 | pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers); |
| 7614 | } |
| 7615 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 7616 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 7617 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 7618 | &pInfos[i].pGeometries[j].geometry.aabbs, |
| 7619 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 7620 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 7621 | skip |= validate_struct_type( |
| 7622 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 7623 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 7624 | &(pInfos[i].pGeometries[j].geometry.aabbs), |
| 7625 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 7626 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 7627 | skip |= validate_struct_pnext( |
| 7628 | api_name, |
| 7629 | ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 7630 | pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 7631 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 7632 | if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) { |
| 7633 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 7634 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 7635 | } |
| 7636 | } |
| 7637 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 7638 | pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7639 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 7640 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 7641 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 7642 | api_name); |
| 7643 | } |
| 7644 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 7645 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7646 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 7647 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 7648 | "of elements of" |
| 7649 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 7650 | api_name); |
| 7651 | } |
| 7652 | if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) { |
| 7653 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 7654 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 7655 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 7656 | api_name); |
| 7657 | } |
| 7658 | } |
| 7659 | } |
| 7660 | } |
| 7661 | if (pInfos[i].ppGeometries != NULL) { |
| 7662 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 7663 | skip |= validate_ranged_enum( |
| 7664 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}), |
| 7665 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType, |
| 7666 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 7667 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7668 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 7669 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 7670 | &pInfos[i].ppGeometries[j]->geometry.triangles, |
| 7671 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 7672 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 7673 | skip |= validate_struct_type( |
| 7674 | api_name, |
| 7675 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}), |
| 7676 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 7677 | &(pInfos[i].ppGeometries[j]->geometry.triangles), |
| 7678 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 7679 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 7680 | skip |= validate_struct_pnext( |
| 7681 | api_name, |
| 7682 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 7683 | NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 7684 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 7685 | skip |= validate_ranged_enum(api_name, |
| 7686 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat", |
| 7687 | ParameterName::IndexVector{i, j}), |
| 7688 | "VkFormat", AllVkFormatEnums, |
| 7689 | pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat, |
| 7690 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 7691 | skip |= validate_ranged_enum(api_name, |
| 7692 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType", |
| 7693 | ParameterName::IndexVector{i, j}), |
| 7694 | "VkIndexType", AllVkIndexTypeEnums, |
| 7695 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType, |
| 7696 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 7697 | if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) { |
| 7698 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 7699 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 7700 | } |
| 7701 | if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 7702 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 7703 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 7704 | skip |= |
| 7705 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 7706 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 7707 | api_name); |
| 7708 | } |
| 7709 | } |
| 7710 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7711 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 7712 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 7713 | &pInfos[i].ppGeometries[j]->geometry.instances, |
| 7714 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 7715 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 7716 | skip |= validate_struct_type( |
| 7717 | api_name, |
| 7718 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}), |
| 7719 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 7720 | &(pInfos[i].ppGeometries[j]->geometry.instances), |
| 7721 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 7722 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 7723 | skip |= validate_struct_pnext( |
| 7724 | api_name, |
| 7725 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 7726 | NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 7727 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 7728 | skip |= validate_bool32(api_name, |
| 7729 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers", |
| 7730 | ParameterName::IndexVector{i, j}), |
| 7731 | pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers); |
| 7732 | } |
| 7733 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 7734 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 7735 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 7736 | &pInfos[i].ppGeometries[j]->geometry.aabbs, |
| 7737 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 7738 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 7739 | skip |= validate_struct_type( |
| 7740 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 7741 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 7742 | &(pInfos[i].ppGeometries[j]->geometry.aabbs), |
| 7743 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 7744 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 7745 | skip |= validate_struct_pnext( |
| 7746 | api_name, |
| 7747 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 7748 | pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 7749 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 7750 | if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) { |
| 7751 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 7752 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 7753 | } |
| 7754 | } |
| 7755 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 7756 | pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7757 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 7758 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 7759 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 7760 | api_name); |
| 7761 | } |
| 7762 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 7763 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7764 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 7765 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 7766 | "of elements of" |
| 7767 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 7768 | api_name); |
| 7769 | } |
| 7770 | if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) { |
| 7771 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 7772 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 7773 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 7774 | api_name); |
| 7775 | } |
| 7776 | } |
| 7777 | } |
| 7778 | } |
| 7779 | } |
| 7780 | return skip; |
| 7781 | } |
| 7782 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR( |
| 7783 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 7784 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 7785 | bool skip = false; |
| 7786 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR"); |
| 7787 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 7788 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 7789 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 7790 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710", |
| 7791 | "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its " |
| 7792 | "scratchData.deviceAddress member must be a multiple of " |
| 7793 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 7794 | } |
| 7795 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 7796 | if (i == k) continue; |
| 7797 | bool found = false; |
| 7798 | if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 7799 | skip |= |
| 7800 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 7801 | "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32 |
| 7802 | ") of pInfos must " |
| 7803 | "not be " |
| 7804 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 7805 | ") of pInfos.", |
| 7806 | i, k); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7807 | found = true; |
| 7808 | } |
| 7809 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 7810 | skip |= |
| 7811 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403", |
| 7812 | "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32 |
| 7813 | ") of pInfos must " |
| 7814 | "not be " |
| 7815 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 7816 | ") of pInfos.", |
| 7817 | i, k); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7818 | found = true; |
| 7819 | } |
| 7820 | if (found) break; |
| 7821 | } |
| 7822 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 7823 | if (pInfos[i].pGeometries) { |
| 7824 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7825 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7826 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7827 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 7828 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7829 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7830 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7831 | } |
| 7832 | } else { |
| 7833 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 7834 | skip |= |
| 7835 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 7836 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7837 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7838 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7839 | } |
| 7840 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7841 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7842 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7843 | skip |= LogError( |
| 7844 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 7845 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7846 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7847 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7848 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7849 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7850 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 7851 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 7852 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 7853 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 7854 | } |
| 7855 | } |
| 7856 | } else if (pInfos[i].ppGeometries) { |
| 7857 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7858 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7859 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7860 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 7861 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7862 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7863 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7864 | } |
| 7865 | } else { |
| 7866 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 7867 | skip |= |
| 7868 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 7869 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7870 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7871 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7872 | } |
| 7873 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7874 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7875 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7876 | skip |= LogError( |
| 7877 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 7878 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7879 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7880 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7881 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7882 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7883 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 7884 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 7885 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 7886 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 7887 | } |
| 7888 | } |
| 7889 | } |
| 7890 | } |
| 7891 | } |
| 7892 | return skip; |
| 7893 | } |
| 7894 | |
| 7895 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR( |
| 7896 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 7897 | const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides, |
| 7898 | const uint32_t *const *ppMaxPrimitiveCounts) const { |
| 7899 | bool skip = false; |
| 7900 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR"); |
| 7901 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7902 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7903 | if (!ray_tracing_acceleration_structure_features || |
| 7904 | ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) { |
| 7905 | skip |= LogError( |
| 7906 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650", |
| 7907 | "vkCmdBuildAccelerationStructuresIndirectKHR: The " |
| 7908 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled."); |
| 7909 | } |
| 7910 | for (uint32_t i = 0; i < infoCount; ++i) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7911 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 7912 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 7913 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710", |
| 7914 | "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its " |
| 7915 | "scratchData.deviceAddress member must be a multiple of " |
| 7916 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 7917 | } |
| 7918 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 7919 | if (i == k) continue; |
| 7920 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 7921 | skip |= LogError( |
| 7922 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403", |
| 7923 | "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32 |
| 7924 | ") " |
| 7925 | "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of " |
| 7926 | "any other element [%" PRIu32 ") of pInfos.", |
| 7927 | i, k); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7928 | break; |
| 7929 | } |
| 7930 | } |
| 7931 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 7932 | if (pInfos[i].pGeometries) { |
| 7933 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7934 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7935 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7936 | skip |= LogError( |
| 7937 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 7938 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7939 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7940 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7941 | } |
| 7942 | } else { |
| 7943 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 7944 | skip |= LogError( |
| 7945 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 7946 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7947 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7948 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7949 | } |
| 7950 | } |
| 7951 | } |
| 7952 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 7953 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7954 | skip |= LogError( |
| 7955 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 7956 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7957 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7958 | } |
| 7959 | } |
| 7960 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7961 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 7962 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 7963 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 7964 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 7965 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 7966 | } |
| 7967 | } |
| 7968 | } else if (pInfos[i].ppGeometries) { |
| 7969 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7970 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7971 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7972 | skip |= LogError( |
| 7973 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 7974 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7975 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7976 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7977 | } |
| 7978 | } else { |
| 7979 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 7980 | skip |= LogError( |
| 7981 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 7982 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7983 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7984 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7985 | } |
| 7986 | } |
| 7987 | } |
| 7988 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 7989 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7990 | skip |= LogError( |
| 7991 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 7992 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7993 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7994 | } |
| 7995 | } |
| 7996 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7997 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 7998 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 7999 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 8000 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 8001 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 8002 | } |
| 8003 | } |
| 8004 | } |
| 8005 | } |
| 8006 | } |
| 8007 | return skip; |
| 8008 | } |
| 8009 | |
| 8010 | bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR( |
| 8011 | VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, |
| 8012 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 8013 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 8014 | bool skip = false; |
| 8015 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR"); |
| 8016 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 8017 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8018 | if (!ray_tracing_acceleration_structure_features || |
| 8019 | ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 8020 | skip |= |
| 8021 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581", |
| 8022 | "vkBuildAccelerationStructuresKHR: The " |
| 8023 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled"); |
| 8024 | } |
| 8025 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 8026 | for (uint32_t j = 0; j < infoCount; ++j) { |
| 8027 | if (i == j) continue; |
| 8028 | bool found = false; |
| 8029 | if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8030 | skip |= |
| 8031 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 8032 | "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32 |
| 8033 | ") of pInfos must " |
| 8034 | "not be " |
| 8035 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 8036 | ") of pInfos.", |
| 8037 | i, j); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8038 | found = true; |
| 8039 | } |
| 8040 | if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8041 | skip |= |
| 8042 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403", |
| 8043 | "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32 |
| 8044 | ") of pInfos must " |
| 8045 | "not be " |
| 8046 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32 |
| 8047 | ") of pInfos.", |
| 8048 | i, j); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8049 | found = true; |
| 8050 | } |
| 8051 | if (found) break; |
| 8052 | } |
| 8053 | } |
| 8054 | return skip; |
| 8055 | } |
| 8056 | |
| 8057 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR( |
| 8058 | VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo, |
| 8059 | const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const { |
| 8060 | bool skip = false; |
| 8061 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR"); |
| 8062 | const auto *ray_tracing_pipeline_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 8063 | LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 8064 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
ziga-lunarg | bcfba98 | 2022-03-19 17:49:55 +0100 | [diff] [blame] | 8065 | if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) || |
| 8066 | (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8067 | skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617", |
Lars-Ivar Hesselberg Simonsen | dcd1e40 | 2021-11-23 17:14:03 +0100 | [diff] [blame] | 8068 | "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled"); |
| 8069 | } |
| 8070 | if (pBuildInfo != nullptr) { |
| 8071 | if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) { |
| 8072 | skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619", |
| 8073 | "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts " |
| 8074 | "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values"); |
| 8075 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 8076 | } |
| 8077 | return skip; |
| 8078 | } |
sfricke-samsung | ecafb19 | 2021-01-17 08:21:14 -0800 | [diff] [blame] | 8079 | |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8080 | bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT( |
| 8081 | VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount, |
| 8082 | const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount, |
| 8083 | const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const { |
| 8084 | bool skip = false; |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8085 | const auto *vertex_attribute_divisor_features = |
| 8086 | LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext); |
| 8087 | |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8088 | // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791 |
| 8089 | if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
| 8090 | skip |= |
| 8091 | LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791", |
| 8092 | "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit"); |
| 8093 | } |
| 8094 | |
| 8095 | // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792 |
| 8096 | if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
| 8097 | skip |= LogError( |
| 8098 | device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792", |
| 8099 | "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit"); |
| 8100 | } |
| 8101 | |
| 8102 | // VUID-vkCmdSetVertexInputEXT-binding-04793 |
| 8103 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) { |
| 8104 | bool binding_found = false; |
| 8105 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) { |
| 8106 | if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) { |
| 8107 | binding_found = true; |
| 8108 | break; |
| 8109 | } |
| 8110 | } |
| 8111 | if (!binding_found) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8112 | skip |= LogError( |
| 8113 | device, "VUID-vkCmdSetVertexInputEXT-binding-04793", |
| 8114 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8115 | } |
| 8116 | } |
| 8117 | |
| 8118 | // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794 |
| 8119 | if (vertexBindingDescriptionCount > 1) { |
| 8120 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) { |
| 8121 | uint32_t binding_value = pVertexBindingDescriptions[binding].binding; |
| 8122 | for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) { |
| 8123 | if (binding_value == pVertexBindingDescriptions[next_binding].binding) { |
| 8124 | skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8125 | "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified", |
| 8126 | binding_value); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8127 | } |
| 8128 | } |
| 8129 | } |
| 8130 | } |
| 8131 | |
| 8132 | // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795 |
| 8133 | if (vertexAttributeDescriptionCount > 1) { |
| 8134 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) { |
| 8135 | uint32_t location = pVertexAttributeDescriptions[attribute].location; |
| 8136 | for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) { |
| 8137 | if (location == pVertexAttributeDescriptions[next_attribute].location) { |
| 8138 | skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8139 | "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified", |
| 8140 | location); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8141 | } |
| 8142 | } |
| 8143 | } |
| 8144 | } |
| 8145 | |
| 8146 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) { |
| 8147 | // VUID-VkVertexInputBindingDescription2EXT-binding-04796 |
| 8148 | if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8149 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796", |
| 8150 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8151 | "].binding is greater than maxVertexInputBindings", |
| 8152 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8153 | } |
| 8154 | |
| 8155 | // VUID-VkVertexInputBindingDescription2EXT-stride-04797 |
| 8156 | if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8157 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797", |
| 8158 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8159 | "].stride is greater than maxVertexInputBindingStride", |
| 8160 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8161 | } |
| 8162 | |
| 8163 | // VUID-VkVertexInputBindingDescription2EXT-divisor-04798 |
| 8164 | if (pVertexBindingDescriptions[binding].divisor == 0 && |
| 8165 | (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) { |
| 8166 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8167 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8168 | "].divisor is zero but " |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8169 | "vertexAttributeInstanceRateZeroDivisor is not enabled", |
| 8170 | binding); |
| 8171 | } |
| 8172 | |
| 8173 | if (pVertexBindingDescriptions[binding].divisor > 1) { |
| 8174 | // VUID-VkVertexInputBindingDescription2EXT-divisor-04799 |
| 8175 | if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) { |
| 8176 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8177 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8178 | "].divisor is greater than one but " |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8179 | "vertexAttributeInstanceRateDivisor is not enabled", |
| 8180 | binding); |
| 8181 | } else { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8182 | // VUID-VkVertexInputBindingDescription2EXT-divisor-06226 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8183 | if (pVertexBindingDescriptions[binding].divisor > |
| 8184 | phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8185 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226", |
| 8186 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8187 | "].divisor is greater than maxVertexAttribDivisor", |
| 8188 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8189 | } |
| 8190 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8191 | // VUID-VkVertexInputBindingDescription2EXT-divisor-06227 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8192 | if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8193 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227", |
| 8194 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32 |
| 8195 | "].divisor is greater than 1 but inputRate " |
| 8196 | "is not VK_VERTEX_INPUT_RATE_INSTANCE", |
| 8197 | binding); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8198 | } |
| 8199 | } |
| 8200 | } |
| 8201 | } |
| 8202 | |
| 8203 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8204 | // VUID-VkVertexInputAttributeDescription2EXT-location-06228 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8205 | if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8206 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228", |
| 8207 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8208 | "].location is greater than maxVertexInputAttributes", |
| 8209 | attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8210 | } |
| 8211 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8212 | // VUID-VkVertexInputAttributeDescription2EXT-binding-06229 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8213 | if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8214 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229", |
| 8215 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8216 | "].binding is greater than maxVertexInputBindings", |
| 8217 | attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8218 | } |
| 8219 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 8220 | // VUID-VkVertexInputAttributeDescription2EXT-offset-06230 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8221 | if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8222 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230", |
| 8223 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8224 | "].offset is greater than maxVertexInputAttributeOffset", |
| 8225 | attribute); |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8226 | } |
| 8227 | |
| 8228 | // VUID-VkVertexInputAttributeDescription2EXT-format-04805 |
| 8229 | VkFormatProperties properties; |
| 8230 | DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties); |
| 8231 | if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) { |
| 8232 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8233 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 |
| 8234 | "].format is not a " |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 8235 | "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format", |
| 8236 | attribute); |
| 8237 | } |
| 8238 | } |
| 8239 | |
| 8240 | return skip; |
| 8241 | } |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8242 | |
| 8243 | bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, |
| 8244 | VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, |
| 8245 | const void *pValues) const { |
| 8246 | bool skip = false; |
| 8247 | const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize; |
| 8248 | // Check that offset + size don't exceed the max. |
| 8249 | // Prevent arithetic overflow here by avoiding addition and testing in this order. |
| 8250 | if (offset >= max_push_constants_size) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8251 | skip |= |
| 8252 | LogError(device, "VUID-vkCmdPushConstants-offset-00370", |
| 8253 | "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".", |
| 8254 | offset, max_push_constants_size); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8255 | } |
| 8256 | if (size > max_push_constants_size - offset) { |
| 8257 | skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8258 | "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32 |
| 8259 | ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".", |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8260 | offset, size, max_push_constants_size); |
| 8261 | } |
| 8262 | |
| 8263 | // size needs to be non-zero and a multiple of 4. |
| 8264 | if (size & 0x3) { |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8265 | skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", |
| 8266 | "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8267 | } |
| 8268 | |
| 8269 | // offset needs to be a multiple of 4. |
| 8270 | if ((offset & 0x3) != 0) { |
| 8271 | skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368", |
sfricke-samsung | a3d4fc1 | 2021-09-28 22:25:46 -0700 | [diff] [blame] | 8272 | "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 8273 | } |
| 8274 | return skip; |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 8275 | } |
ziga-lunarg | b1dd8a2 | 2021-07-15 17:47:19 +0200 | [diff] [blame] | 8276 | |
| 8277 | bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, |
| 8278 | uint32_t srcCacheCount, |
| 8279 | const VkPipelineCache *pSrcCaches) const { |
| 8280 | bool skip = false; |
| 8281 | if (pSrcCaches) { |
| 8282 | for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) { |
| 8283 | if (pSrcCaches[index0] == dstCache) { |
| 8284 | skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770", |
| 8285 | "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.", |
| 8286 | report_data->FormatHandle(dstCache).c_str()); |
| 8287 | break; |
| 8288 | } |
| 8289 | } |
| 8290 | } |
| 8291 | return skip; |
| 8292 | } |
Nathaniel Cesario | 298d3cb | 2021-08-03 13:49:02 -0600 | [diff] [blame] | 8293 | |
| 8294 | bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, |
| 8295 | VkImageLayout imageLayout, const VkClearColorValue *pColor, |
| 8296 | uint32_t rangeCount, |
| 8297 | const VkImageSubresourceRange *pRanges) const { |
| 8298 | bool skip = false; |
| 8299 | if (!pColor) { |
| 8300 | skip |= |
| 8301 | LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null"); |
| 8302 | } |
| 8303 | return skip; |
| 8304 | } |
| 8305 | |
| 8306 | bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name, |
| 8307 | const VkRenderPassBeginInfo *const rp_begin) const { |
| 8308 | bool skip = false; |
| 8309 | if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) { |
| 8310 | skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962", |
| 8311 | "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32 |
ziga-lunarg | 47109fb | 2021-09-03 18:41:12 +0200 | [diff] [blame] | 8312 | "), but VkRenderPassBeginInfo::pClearValues is null.", |
Nathaniel Cesario | 298d3cb | 2021-08-03 13:49:02 -0600 | [diff] [blame] | 8313 | func_name, rp_begin->clearValueCount); |
| 8314 | } |
| 8315 | return skip; |
| 8316 | } |
| 8317 | |
| 8318 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 8319 | VkSubpassContents) const { |
| 8320 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin); |
| 8321 | return skip; |
| 8322 | } |
| 8323 | |
| 8324 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer, |
| 8325 | const VkRenderPassBeginInfo *pRenderPassBegin, |
| 8326 | const VkSubpassBeginInfo *) const { |
| 8327 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin); |
| 8328 | return skip; |
| 8329 | } |
| 8330 | |
| 8331 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 8332 | const VkSubpassBeginInfo *) const { |
| 8333 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin); |
| 8334 | return skip; |
| 8335 | } |
ziga-lunarg | c7bb56a | 2021-08-10 09:28:52 +0200 | [diff] [blame] | 8336 | |
| 8337 | bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer, |
| 8338 | uint32_t firstDiscardRectangle, |
| 8339 | uint32_t discardRectangleCount, |
| 8340 | const VkRect2D *pDiscardRectangles) const { |
| 8341 | bool skip = false; |
| 8342 | |
| 8343 | if (pDiscardRectangles) { |
| 8344 | for (uint32_t i = 0; i < discardRectangleCount; ++i) { |
| 8345 | const int64_t x_sum = |
| 8346 | static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width); |
| 8347 | if (x_sum > std::numeric_limits<int32_t>::max()) { |
| 8348 | skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588", |
| 8349 | "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 8350 | ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.", |
| 8351 | pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i); |
| 8352 | } |
| 8353 | |
| 8354 | const int64_t y_sum = |
| 8355 | static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height); |
| 8356 | if (y_sum > std::numeric_limits<int32_t>::max()) { |
| 8357 | skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589", |
| 8358 | "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 8359 | ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.", |
| 8360 | pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i); |
| 8361 | } |
| 8362 | } |
| 8363 | } |
| 8364 | |
| 8365 | return skip; |
| 8366 | } |
ziga-lunarg | 3c37dfb | 2021-08-24 12:51:07 +0200 | [diff] [blame] | 8367 | |
| 8368 | bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, |
| 8369 | uint32_t queryCount, size_t dataSize, void *pData, |
| 8370 | VkDeviceSize stride, VkQueryResultFlags flags) const { |
| 8371 | bool skip = false; |
| 8372 | |
| 8373 | if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) { |
| 8374 | skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811", |
| 8375 | "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit."); |
| 8376 | } |
| 8377 | |
| 8378 | return skip; |
| 8379 | } |
ziga-lunarg | cf340c4 | 2021-08-19 00:13:38 +0200 | [diff] [blame] | 8380 | |
| 8381 | bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT( |
| 8382 | VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const { |
| 8383 | bool skip = false; |
| 8384 | |
| 8385 | if ((pConditionalRenderingBegin->offset & 3) != 0) { |
| 8386 | skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984", |
| 8387 | "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64 |
| 8388 | ") is not a multiple of 4.", |
| 8389 | pConditionalRenderingBegin->offset); |
| 8390 | } |
| 8391 | |
| 8392 | return skip; |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame] | 8393 | } |
Mike Schuchardt | 05b028d | 2022-01-05 14:15:00 -0800 | [diff] [blame] | 8394 | |
| 8395 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, |
| 8396 | VkSurfaceKHR surface, |
| 8397 | uint32_t *pSurfaceFormatCount, |
| 8398 | VkSurfaceFormatKHR *pSurfaceFormats) const { |
| 8399 | bool skip = false; |
| 8400 | if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8401 | skip |= LogError( |
| 8402 | physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524", |
| 8403 | "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled."); |
| 8404 | } |
| 8405 | return skip; |
| 8406 | } |
| 8407 | |
| 8408 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, |
| 8409 | VkSurfaceKHR surface, |
| 8410 | uint32_t *pPresentModeCount, |
| 8411 | VkPresentModeKHR *pPresentModes) const { |
| 8412 | bool skip = false; |
| 8413 | if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8414 | skip |= LogError( |
| 8415 | physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524", |
| 8416 | "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled."); |
| 8417 | } |
| 8418 | return skip; |
| 8419 | } |
| 8420 | |
| 8421 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR( |
| 8422 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 8423 | VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const { |
| 8424 | bool skip = false; |
| 8425 | if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8426 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520", |
| 8427 | "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 8428 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 8429 | } |
| 8430 | return skip; |
| 8431 | } |
| 8432 | |
| 8433 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR( |
| 8434 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount, |
| 8435 | VkSurfaceFormat2KHR *pSurfaceFormats) const { |
| 8436 | bool skip = false; |
| 8437 | if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8438 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521", |
| 8439 | "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 8440 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 8441 | } |
| 8442 | return skip; |
| 8443 | } |
| 8444 | |
| 8445 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 8446 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT( |
| 8447 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount, |
| 8448 | VkPresentModeKHR *pPresentModes) const { |
| 8449 | bool skip = false; |
| 8450 | if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) { |
| 8451 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521", |
| 8452 | "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and " |
| 8453 | "VK_GOOGLE_surfaceless_query is not enabled."); |
| 8454 | } |
| 8455 | return skip; |
| 8456 | } |
ziga-lunarg | 50f8e6b | 2021-12-18 20:24:35 +0100 | [diff] [blame] | 8457 | |
Mike Schuchardt | 05b028d | 2022-01-05 14:15:00 -0800 | [diff] [blame] | 8458 | #endif // VK_USE_PLATFORM_WIN32_KHR |
ziga-lunarg | 50f8e6b | 2021-12-18 20:24:35 +0100 | [diff] [blame] | 8459 | |
| 8460 | bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo, |
| 8461 | const char *func_name) const { |
| 8462 | bool skip = false; |
| 8463 | |
| 8464 | if (pInfo && pInfo->pCreateInfo) { |
| 8465 | const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo); |
| 8466 | if (image_swapchain_create_info) { |
| 8467 | skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416", |
| 8468 | "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name); |
| 8469 | } |
| 8470 | } |
| 8471 | |
| 8472 | return skip; |
| 8473 | } |
| 8474 | |
| 8475 | bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR( |
| 8476 | VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const { |
| 8477 | bool skip = false; |
| 8478 | |
| 8479 | skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR"); |
| 8480 | |
| 8481 | return skip; |
| 8482 | } |
| 8483 | |
| 8484 | bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR( |
| 8485 | VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount, |
| 8486 | VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const { |
| 8487 | bool skip = false; |
| 8488 | |
| 8489 | skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR"); |
| 8490 | |
| 8491 | return skip; |
| 8492 | } |