Mark Lobodzinski | c0df6b6 | 2021-01-08 12:34:11 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2021 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2021 Valve Corporation |
| 3 | * Copyright (c) 2015-2021 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2021 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 | |
Mark Lobodzinski | 21b91fe | 2020-12-03 15:44:24 -0700 | [diff] [blame] | 37 | read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); } |
| 38 | write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); } |
| 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; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 42 | static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); } |
| 43 | static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(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)) { |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 314 | // Get the needed vertex attribute divisor limits |
| 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 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 321 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 322 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 323 | // Save app-enabled features in this device's validation object |
| 324 | // 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] | 325 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 326 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 327 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 328 | if (features2) { |
| 329 | tmp_features2_state.features = features2->features; |
| 330 | } else if (pCreateInfo->pEnabledFeatures) { |
| 331 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 332 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 333 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 334 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 335 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 336 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 337 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 340 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 341 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 342 | bool skip = false; |
| 343 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 344 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 345 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 346 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 347 | } |
| 348 | |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 349 | // If this device supports VK_KHR_portability_subset, it must be enabled |
| 350 | const std::string portability_extension_name("VK_KHR_portability_subset"); |
| 351 | const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice); |
| 352 | const bool portability_supported = dev_extensions.count(portability_extension_name) != 0; |
| 353 | bool portability_requested = false; |
| 354 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 355 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 356 | skip |= |
| 357 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 358 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 359 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 360 | pCreateInfo->ppEnabledExtensionNames[i]); |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 361 | if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) { |
| 362 | portability_requested = true; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | if (portability_supported && !portability_requested) { |
| 367 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451", |
| 368 | "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it", |
| 369 | report_data->FormatHandle(physicalDevice).c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 370 | } |
| 371 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 372 | { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 373 | bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME)); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 374 | bool negative_viewport = |
| 375 | IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME)); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 376 | if (maint1 && negative_viewport) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 377 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 378 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
| 379 | "VK_AMD_negative_viewport_height."); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 380 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 381 | } |
| 382 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 383 | { |
ziga-lunarg | 9271a7c | 2021-07-19 16:37:06 +0200 | [diff] [blame] | 384 | bool khr_bda = |
| 385 | IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 386 | bool ext_bda = |
| 387 | 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] | 388 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 389 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 390 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 391 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 395 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 396 | // Check for get_physical_device_properties2 struct |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 397 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 398 | if (features2) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 399 | // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 400 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 401 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 402 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 403 | } |
| 404 | } |
| 405 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 406 | auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 407 | const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 408 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 409 | if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { |
| 410 | skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", |
| 411 | "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); |
| 412 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 413 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 414 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed && |
| 415 | !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) { |
| 416 | skip |= LogError( |
| 417 | device, |
| 418 | "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575", |
| 419 | "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay " |
| 420 | "must also be VK_TRUE."); |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 421 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 422 | auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 423 | 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] | 424 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 425 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 426 | "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] | 427 | } |
| 428 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 429 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 430 | if (vulkan_11_features) { |
| 431 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 432 | while (current) { |
| 433 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 434 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 435 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 436 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 437 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 438 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 439 | skip |= LogError( |
| 440 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 441 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 442 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 443 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 444 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 445 | break; |
| 446 | } |
| 447 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 448 | } |
sfricke-samsung | ebda679 | 2021-01-16 08:57:52 -0800 | [diff] [blame] | 449 | |
| 450 | // Check features are enabled if matching extension is passed in as well |
| 451 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 452 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 453 | if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 454 | (vulkan_11_features->shaderDrawParameters == VK_FALSE)) { |
| 455 | skip |= LogError( |
| 456 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476", |
| 457 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.", |
| 458 | VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME); |
| 459 | } |
| 460 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 461 | } |
| 462 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 463 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 464 | if (vulkan_12_features) { |
| 465 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 466 | while (current) { |
| 467 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 468 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 469 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 470 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 471 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 472 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 473 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 474 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 475 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 476 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 477 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 478 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 479 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 480 | skip |= LogError( |
| 481 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 482 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 483 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 484 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 485 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 486 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 487 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 488 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 489 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 490 | break; |
| 491 | } |
| 492 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 493 | } |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 494 | // Check features are enabled if matching extension is passed in as well |
| 495 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 496 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 497 | if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 498 | (vulkan_12_features->drawIndirectCount == VK_FALSE)) { |
| 499 | skip |= LogError( |
| 500 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831", |
| 501 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", |
| 502 | VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 503 | } |
| 504 | if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 505 | (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { |
| 506 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832", |
| 507 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " |
| 508 | "is not VK_TRUE.", |
| 509 | VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); |
| 510 | } |
| 511 | if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 512 | (vulkan_12_features->descriptorIndexing == VK_FALSE)) { |
| 513 | skip |= LogError( |
| 514 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833", |
| 515 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", |
| 516 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 517 | } |
| 518 | if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 519 | (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { |
| 520 | skip |= LogError( |
| 521 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834", |
| 522 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", |
| 523 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 524 | } |
| 525 | if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 526 | ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || |
| 527 | (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { |
| 528 | skip |= |
| 529 | LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835", |
| 530 | "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " |
| 531 | "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", |
| 532 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); |
| 533 | } |
| 534 | } |
ziga-lunarg | 27f88fd | 2021-08-01 15:47:30 +0200 | [diff] [blame] | 535 | if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) { |
| 536 | if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) { |
| 537 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748", |
| 538 | "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress " |
| 539 | "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address"); |
| 540 | } |
| 541 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 542 | } |
| 543 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 544 | // Validate pCreateInfo->pQueueCreateInfos |
| 545 | if (pCreateInfo->pQueueCreateInfos) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 546 | |
| 547 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 548 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
| 549 | const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 550 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 551 | skip |= |
| 552 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 553 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 554 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 555 | "index value.", |
| 556 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 557 | } |
| 558 | |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 559 | if (queue_create_info.pQueuePriorities != nullptr) { |
| 560 | for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { |
| 561 | const float queue_priority = queue_create_info.pQueuePriorities[j]; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 562 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 563 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 564 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 565 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 566 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 567 | } |
| 568 | } |
| 569 | } |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 570 | |
| 571 | // 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] | 572 | VkBool32 protected_memory = VK_FALSE; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 573 | const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 574 | LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 575 | if (protected_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 576 | protected_memory = protected_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 577 | } else if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 578 | protected_memory = vulkan_11_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 579 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 580 | if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 581 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", |
| 582 | "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " |
| 583 | "protectedMemory feature being set as well."); |
| 584 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 585 | } |
| 586 | } |
| 587 | |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 588 | // feature dependencies for VK_KHR_variable_pointers |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 589 | const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 590 | VkBool32 variable_pointers = VK_FALSE; |
| 591 | VkBool32 variable_pointers_storage_buffer = VK_FALSE; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 592 | if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 593 | variable_pointers = vulkan_11_features->variablePointers; |
| 594 | variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 595 | } else if (variable_pointers_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 596 | variable_pointers = variable_pointers_features->variablePointers; |
| 597 | variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 598 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 599 | if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) { |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 600 | skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431", |
| 601 | "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE"); |
| 602 | } |
| 603 | |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 604 | // feature dependencies for VK_KHR_multiview |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 605 | const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 606 | VkBool32 multiview = VK_FALSE; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 607 | VkBool32 multiview_geometry_shader = VK_FALSE; |
| 608 | VkBool32 multiview_tessellation_shader = VK_FALSE; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 609 | if (vulkan_11_features) { |
| 610 | multiview = vulkan_11_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 611 | multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader; |
| 612 | multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 613 | } else if (multiview_features) { |
| 614 | multiview = multiview_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 615 | multiview_geometry_shader = multiview_features->multiviewGeometryShader; |
| 616 | multiview_tessellation_shader = multiview_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 617 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 618 | if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 619 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580", |
| 620 | "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 621 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 622 | if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 623 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581", |
| 624 | "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 625 | } |
| 626 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 627 | return skip; |
| 628 | } |
| 629 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 630 | 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] | 631 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 632 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 633 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 634 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 635 | } |
| 636 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 637 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 638 | } |
| 639 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 640 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 641 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 642 | bool skip = false; |
| 643 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 644 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 645 | skip |= |
| 646 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 647 | |
| 648 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 649 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 650 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 651 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 652 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 653 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 654 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 658 | // queueFamilyIndexCount uint32_t values |
| 659 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 660 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 661 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 662 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 663 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 664 | } |
| 665 | } |
| 666 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 667 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
| 668 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915", |
| 669 | "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the " |
| 670 | "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set."); |
| 671 | } |
| 672 | |
| 673 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) { |
| 674 | skip |= |
| 675 | LogError(device, "VUID-VkBufferCreateInfo-flags-00916", |
| 676 | "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with " |
| 677 | "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set."); |
| 678 | } |
| 679 | |
| 680 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 681 | skip |= |
| 682 | LogError(device, "VUID-VkBufferCreateInfo-flags-00917", |
| 683 | "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with " |
| 684 | "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set."); |
| 685 | } |
| 686 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 687 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 688 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 689 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 690 | ((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] | 691 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 692 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 693 | "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] | 694 | } |
| 695 | } |
| 696 | |
| 697 | return skip; |
| 698 | } |
| 699 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 700 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 701 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 702 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 703 | |
| 704 | if (pCreateInfo != nullptr) { |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 705 | const VkFormat image_format = pCreateInfo->format; |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 706 | const VkImageCreateFlags image_flags = pCreateInfo->flags; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 707 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 708 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 709 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 710 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 711 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942", |
| 712 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 713 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 717 | // queueFamilyIndexCount uint32_t values |
| 718 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 719 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941", |
| 720 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 721 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 722 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 723 | } |
| 724 | } |
| 725 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 726 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 727 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 728 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 729 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 730 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 731 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 732 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 733 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 734 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 735 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 736 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 737 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 738 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 739 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 740 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 741 | skip |= LogError( |
| 742 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 743 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 744 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 745 | } |
| 746 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 747 | // 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] | 748 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 749 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 750 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 751 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 752 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 756 | if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 757 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 758 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 759 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 760 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 761 | ") are not equal.", |
| 762 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 763 | } |
| 764 | |
| 765 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 766 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 767 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 768 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 769 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 770 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 774 | skip |= LogError( |
| 775 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 776 | "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] | 777 | } |
| 778 | } |
| 779 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 780 | // 3D image may have only 1 layer |
| 781 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 782 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 783 | "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] | 784 | } |
| 785 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 786 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 787 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 788 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 789 | // At least one of the legal attachment bits must be set |
| 790 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 791 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 792 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 793 | } |
| 794 | // No flags other than the legal attachment bits may be set |
| 795 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 796 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 797 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 798 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 799 | } |
| 800 | } |
| 801 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 802 | // 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] | 803 | 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] | 804 | // Max mip levels is different for corner-sampled images vs normal images. |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 805 | 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] | 806 | ? static_cast<uint32_t>(ceil(log2(max_dim))) |
| 807 | : static_cast<uint32_t>(floor(log2(max_dim)) + 1); |
| 808 | if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 809 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 810 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 811 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 812 | "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] | 813 | } |
| 814 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 815 | 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] | 816 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 817 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 818 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 819 | } |
| 820 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 821 | 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] | 822 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 823 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 824 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 825 | } |
| 826 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 827 | 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] | 828 | skip |= LogError( |
| 829 | device, "VUID-VkImageCreateInfo-flags-01924", |
| 830 | "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the " |
| 831 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set."); |
| 832 | } |
| 833 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 834 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 835 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 836 | if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 837 | ((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] | 838 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 839 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 840 | "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] | 841 | } |
| 842 | |
| 843 | // 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] | 844 | if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 845 | // Linear tiling is unsupported |
| 846 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
sfricke-samsung | 9801d75 | 2020-08-23 22:00:16 -0700 | [diff] [blame] | 847 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 848 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 849 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | // Sparse 1D image isn't valid |
| 853 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 854 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 855 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 859 | 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] | 860 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 861 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 862 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 866 | 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] | 867 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 868 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 869 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | // Multi-sample 2D image when device doesn't support it |
| 873 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 874 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 875 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 876 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 877 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 878 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 879 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 880 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 881 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 882 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 883 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 884 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 885 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 886 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 887 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 888 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 889 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 890 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 891 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 892 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 893 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 894 | } |
| 895 | } |
| 896 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 897 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 898 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 899 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 900 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 901 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 902 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 903 | } |
| 904 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 905 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 906 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 907 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 908 | } |
| 909 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 910 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 911 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 912 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 913 | } |
| 914 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 915 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 916 | if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 917 | 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] | 918 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 919 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 920 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 921 | } |
| 922 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 923 | if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 924 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 925 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 926 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a " |
| 927 | "depth/stencil format.", |
| 928 | string_VkFormat(image_format)); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 929 | } |
| 930 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 931 | 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] | 932 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 933 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 934 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 935 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 936 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 937 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 938 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 939 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 940 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 941 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 942 | } |
| 943 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 944 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 945 | 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] | 946 | (FormatHasDepth(image_format) == false)) { |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 947 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533", |
| 948 | "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] | 949 | "format (%s) must be a depth or depth/stencil format.", |
| 950 | string_VkFormat(image_format)); |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 951 | } |
| 952 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 953 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 954 | if (image_stencil_struct != nullptr) { |
| 955 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 956 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 957 | // No flags other than the legal attachment bits may be set |
| 958 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 959 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 960 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 961 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 962 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 963 | "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] | 964 | } |
| 965 | } |
| 966 | |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 967 | if (FormatIsDepthOrStencil(image_format)) { |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 968 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 969 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
sfricke-samsung | f3a9b5b | 2021-01-13 13:05:52 -0800 | [diff] [blame] | 970 | skip |= LogError( |
| 971 | device, "VUID-VkImageCreateInfo-Format-02536", |
| 972 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 973 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device " |
| 974 | "maxFramebufferWidth (%u)", |
| 975 | pCreateInfo->extent.width, device_limits.maxFramebufferWidth); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
sfricke-samsung | f3a9b5b | 2021-01-13 13:05:52 -0800 | [diff] [blame] | 979 | skip |= LogError( |
| 980 | device, "VUID-VkImageCreateInfo-format-02537", |
| 981 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 982 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device " |
| 983 | "maxFramebufferHeight (%u)", |
| 984 | pCreateInfo->extent.height, device_limits.maxFramebufferHeight); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 985 | } |
| 986 | } |
| 987 | |
| 988 | if (!physical_device_features.shaderStorageImageMultisample && |
| 989 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 990 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 991 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 992 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 993 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 994 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 995 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 999 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1000 | skip |= LogError( |
| 1001 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1002 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 1003 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1004 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 1005 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 1006 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1007 | skip |= LogError( |
| 1008 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1009 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 1010 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 1011 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1012 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 1013 | } |
| 1014 | |
| 1015 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 1016 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1017 | skip |= LogError( |
| 1018 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1019 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 1020 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1021 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 1022 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 1023 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1024 | skip |= LogError( |
| 1025 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 1026 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 1027 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 1028 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 1029 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 1030 | } |
| 1031 | } |
| 1032 | } |
Spencer Fricke | ca52b5c | 2020-03-16 17:34:00 -0700 | [diff] [blame] | 1033 | |
| 1034 | if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 1035 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 1036 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968", |
| 1037 | "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images " |
| 1038 | "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
| 1039 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1040 | |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1041 | std::vector<uint64_t> image_create_drm_format_modifiers; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1042 | if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1043 | const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext); |
| 1044 | const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext); |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1045 | if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1046 | if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) || |
| 1047 | ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) { |
| 1048 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261", |
| 1049 | "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have " |
| 1050 | "either VkImageDrmFormatModifierListCreateInfoEXT or " |
| 1051 | "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain"); |
Martin Freebody | 0ec2c7a | 2021-03-03 16:48:00 +0000 | [diff] [blame] | 1052 | } else if (drm_format_mod_explict != nullptr) { |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1053 | image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier); |
| 1054 | } else if (drm_format_mod_list != nullptr) { |
| 1055 | for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) { |
| 1056 | image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers); |
| 1057 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1058 | } |
| 1059 | } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) { |
| 1060 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262", |
| 1061 | "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a " |
| 1062 | "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT " |
| 1063 | "in the pNext chain"); |
| 1064 | } |
| 1065 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1066 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1067 | static const uint64_t drm_format_mod_linear = 0; |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1068 | bool image_create_maybe_linear = false; |
| 1069 | if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) { |
| 1070 | image_create_maybe_linear = true; |
| 1071 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) { |
| 1072 | image_create_maybe_linear = false; |
| 1073 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1074 | image_create_maybe_linear = |
| 1075 | (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] | 1076 | drm_format_mod_linear) != image_create_drm_format_modifiers.end()); |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1077 | } |
| 1078 | |
| 1079 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 1080 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1081 | ((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] | 1082 | (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) { |
| 1083 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 1084 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
| 1085 | } |
| 1086 | |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1087 | if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) && |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1088 | ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || |
| 1089 | image_create_maybe_linear)) { |
| 1090 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259", |
| 1091 | "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips."); |
| 1092 | } |
| 1093 | |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1094 | if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) { |
| 1095 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1096 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557", |
| 1097 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1098 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1099 | } |
| 1100 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1101 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558", |
| 1102 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1103 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
| 1104 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1105 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1106 | if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) { |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1107 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1108 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565", |
| 1109 | "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1110 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 1111 | } |
| 1112 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1113 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566", |
| 1114 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1115 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1116 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1117 | if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1118 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567", |
| 1119 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1120 | "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT."); |
| 1121 | } |
| 1122 | if (pCreateInfo->mipLevels != 1) { |
| 1123 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568", |
| 1124 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.", |
| 1125 | pCreateInfo->mipLevels); |
| 1126 | } |
| 1127 | } |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1128 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1129 | const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1130 | if (swapchain_create_info != nullptr) { |
| 1131 | if (swapchain_create_info->swapchain != VK_NULL_HANDLE) { |
| 1132 | // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the |
| 1133 | // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information |
| 1134 | // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation |
| 1135 | const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995"; |
| 1136 | const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image"; |
| 1137 | |
| 1138 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1139 | // also implicitly forces the check above that extent.depth is 1 |
| 1140 | skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message, |
| 1141 | string_VkImageType(pCreateInfo->imageType)); |
| 1142 | } |
| 1143 | if (pCreateInfo->mipLevels != 1) { |
| 1144 | skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message, |
| 1145 | pCreateInfo->mipLevels); |
| 1146 | } |
| 1147 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1148 | skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.", |
| 1149 | base_message, string_VkSampleCountFlagBits(pCreateInfo->samples)); |
| 1150 | } |
| 1151 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1152 | skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.", |
| 1153 | base_message, string_VkImageTiling(pCreateInfo->tiling)); |
| 1154 | } |
| 1155 | if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) { |
| 1156 | skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.", |
| 1157 | base_message, string_VkImageLayout(pCreateInfo->initialLayout)); |
| 1158 | } |
| 1159 | const VkImageCreateFlags valid_flags = |
| 1160 | (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] | 1161 | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT); |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1162 | if ((image_flags & ~valid_flags) != 0) { |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1163 | 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] | 1164 | image_flags); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1165 | } |
| 1166 | } |
| 1167 | } |
sfricke-samsung | 61a57c0 | 2021-01-10 21:35:12 -0800 | [diff] [blame] | 1168 | |
| 1169 | // If Chroma subsampled format ( _420_ or _422_ ) |
| 1170 | if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) { |
| 1171 | skip |= |
| 1172 | LogError(device, "VUID-VkImageCreateInfo-format-04712", |
| 1173 | "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32 |
| 1174 | ") must be a multiple of 2.", |
| 1175 | string_VkFormat(image_format), pCreateInfo->extent.width); |
| 1176 | } |
| 1177 | if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) { |
| 1178 | skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713", |
| 1179 | "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32 |
| 1180 | ") must be a multiple of 2.", |
| 1181 | string_VkFormat(image_format), pCreateInfo->extent.height); |
| 1182 | } |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1183 | |
| 1184 | const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext); |
| 1185 | if (format_list_info) { |
| 1186 | const uint32_t viewFormatCount = format_list_info->viewFormatCount; |
| 1187 | if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) { |
| 1188 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738", |
| 1189 | "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then " |
| 1190 | "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.", |
| 1191 | viewFormatCount); |
| 1192 | } |
| 1193 | // Check if viewFormatCount is not zero that it is all compatible |
| 1194 | for (uint32_t i = 0; i < viewFormatCount; i++) { |
| 1195 | if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) { |
| 1196 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737", |
| 1197 | "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and " |
| 1198 | "VkImageCreateInfo::format (%s) are not compatible.", |
Esther O'Keefe | d37c24b | 2021-09-27 12:45:40 +1000 | [diff] [blame] | 1199 | i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format)); |
sfricke-samsung | f60b6c8 | 2021-04-05 22:59:20 -0700 | [diff] [blame] | 1200 | } |
| 1201 | } |
| 1202 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1203 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1204 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1205 | return skip; |
| 1206 | } |
| 1207 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1208 | bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 1209 | const VkAllocationCallbacks *pAllocator, VkImageView *pView) const { |
| 1210 | bool skip = false; |
| 1211 | |
| 1212 | if (pCreateInfo != nullptr) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1213 | // Validate feature set if using CUBE_ARRAY |
| 1214 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) { |
| 1215 | skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004", |
| 1216 | "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without " |
| 1217 | "enabling the imageCubeArray feature."); |
| 1218 | } |
| 1219 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1220 | if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 1221 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) { |
| 1222 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960", |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1223 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.", |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1224 | pCreateInfo->subresourceRange.layerCount); |
| 1225 | } |
| 1226 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1227 | skip |= LogError( |
| 1228 | device, "VUID-VkImageViewCreateInfo-viewType-02961", |
| 1229 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.", |
| 1230 | pCreateInfo->subresourceRange.layerCount); |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1231 | } |
| 1232 | } |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1233 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1234 | auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1235 | 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] | 1236 | if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) && |
| 1237 | (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) && |
| 1238 | (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) { |
| 1239 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230", |
| 1240 | "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be " |
| 1241 | "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32."); |
| 1242 | } |
| 1243 | if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) { |
| 1244 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084", |
| 1245 | "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and " |
| 1246 | "not an ASTC format.", |
| 1247 | string_VkFormat(pCreateInfo->format)); |
| 1248 | } |
| 1249 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1250 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1251 | auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1252 | if (ycbcr_conversion != nullptr) { |
| 1253 | if (ycbcr_conversion->conversion != VK_NULL_HANDLE) { |
| 1254 | if (IsIdentitySwizzle(pCreateInfo->components) == false) { |
| 1255 | skip |= LogError( |
| 1256 | device, "VUID-VkImageViewCreateInfo-pNext-01970", |
| 1257 | "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must " |
| 1258 | "be created with the identity swizzle. Here are the actual swizzle values:\n" |
| 1259 | "r swizzle = %s\n" |
| 1260 | "g swizzle = %s\n" |
| 1261 | "b swizzle = %s\n" |
| 1262 | "a swizzle = %s\n", |
| 1263 | string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g), |
| 1264 | string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a)); |
| 1265 | } |
| 1266 | } |
| 1267 | } |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1268 | } |
| 1269 | return skip; |
| 1270 | } |
| 1271 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1272 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1273 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1274 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1275 | |
| 1276 | // Note: for numerical correctness |
| 1277 | // - float comparisons should expect NaN (comparison always false). |
| 1278 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 1279 | |
| 1280 | 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] | 1281 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1282 | if (v1_f <= 0.0f) return true; |
| 1283 | |
| 1284 | float intpart; |
| 1285 | const float fract = modff(v1_f, &intpart); |
| 1286 | |
| 1287 | assert(std::numeric_limits<float>::radix == 2); |
| 1288 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 1289 | if (intpart >= u32_max_plus1) return false; |
| 1290 | |
| 1291 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1292 | if (v1_u32 < v2_u32) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1293 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1294 | } else if (v1_u32 == v2_u32 && fract == 0.0f) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1295 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1296 | } else { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1297 | return false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1298 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1299 | }; |
| 1300 | |
| 1301 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 1302 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 1303 | return (v1_f <= v2_f); |
| 1304 | }; |
| 1305 | |
| 1306 | // width |
| 1307 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1308 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1309 | |
| 1310 | if (!(viewport.width > 0.0f)) { |
| 1311 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1312 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 1313 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1314 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 1315 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1316 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 1317 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 1318 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1319 | } |
| 1320 | |
| 1321 | // height |
| 1322 | bool height_healthy = true; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1323 | const bool negative_height_enabled = |
| 1324 | 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] | 1325 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1326 | |
| 1327 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1328 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1329 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 1330 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1331 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1332 | height_healthy = false; |
| 1333 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1334 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 1335 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 1336 | ").", |
| 1337 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | // x |
| 1341 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1342 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1343 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1344 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 1345 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1346 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1347 | } |
| 1348 | |
| 1349 | // x + width |
| 1350 | if (x_healthy && width_healthy) { |
| 1351 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1352 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1353 | skip |= LogError( |
| 1354 | object, "VUID-VkViewport-x-01232", |
| 1355 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1356 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 1357 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | // y |
| 1362 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1363 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1364 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1365 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 1366 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1367 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1368 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1369 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1370 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 1371 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1372 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1373 | } |
| 1374 | |
| 1375 | // y + height |
| 1376 | if (y_healthy && height_healthy) { |
| 1377 | const float boundary = viewport.y + viewport.height; |
| 1378 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1379 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1380 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 1381 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1382 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 1383 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1384 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1385 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1386 | LogError(object, "VUID-VkViewport-y-01777", |
| 1387 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 1388 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 1389 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1390 | } |
| 1391 | } |
| 1392 | |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1393 | // 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] | 1394 | if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1395 | // minDepth |
| 1396 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1397 | // Also VUID-VkViewport-minDepth-02540 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1398 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1399 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 1400 | "[0.0, 1.0] range.", |
| 1401 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | // maxDepth |
| 1405 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
sfricke-samsung | fd06d42 | 2021-01-22 02:17:21 -0800 | [diff] [blame] | 1406 | // Also VUID-VkViewport-maxDepth-02541 |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1407 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1408 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 1409 | "[0.0, 1.0] range.", |
| 1410 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | return skip; |
| 1415 | } |
| 1416 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1417 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1418 | VkShadingRatePaletteEntryNV shadingRate; |
| 1419 | uint32_t width; |
| 1420 | uint32_t height; |
| 1421 | }; |
| 1422 | |
| 1423 | // All palette entries with more than one pixel per fragment |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1424 | static SampleOrderInfo sample_order_infos[] = { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1425 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 1426 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 1427 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 1428 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 1429 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 1430 | {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] | 1431 | }; |
| 1432 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 1433 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1434 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1435 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1436 | SampleOrderInfo *sample_order_info; |
| 1437 | uint32_t info_idx = 0; |
| 1438 | for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) { |
| 1439 | if (sample_order_infos[info_idx].shadingRate == order->shadingRate) { |
| 1440 | sample_order_info = &sample_order_infos[info_idx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1441 | break; |
| 1442 | } |
| 1443 | } |
| 1444 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1445 | if (sample_order_info == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1446 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 1447 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 1448 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1449 | return skip; |
| 1450 | } |
| 1451 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1452 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1453 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1454 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 1455 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 1456 | ") must " |
| 1457 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 1458 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 1459 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1460 | } |
| 1461 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1462 | 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] | 1463 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 1464 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1465 | ") must " |
| 1466 | "be equal to the product of sampleCount (=%" PRIu32 |
| 1467 | "), the fragment width for shadingRate " |
| 1468 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1469 | order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1470 | } |
| 1471 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1472 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1473 | skip |= LogError( |
| 1474 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1475 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1476 | ") must " |
| 1477 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1478 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1479 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1480 | |
| 1481 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1482 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 1483 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 1484 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1485 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1486 | uint64_t sample_locations_mask = 0; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1487 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1488 | const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i]; |
| 1489 | if (sample_loc->pixelX >= sample_order_info->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1490 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 1491 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1492 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1493 | if (sample_loc->pixelY >= sample_order_info->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1494 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 1495 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1496 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1497 | if (sample_loc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1498 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 1499 | "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] | 1500 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1501 | uint32_t idx = |
| 1502 | sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY); |
| 1503 | sample_locations_mask |= 1ULL << idx; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1504 | } |
| 1505 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1506 | uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 1507 | if (sample_locations_mask != expected_mask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1508 | skip |= LogError( |
| 1509 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1510 | "The array pSampleLocations must contain exactly one entry for " |
| 1511 | "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] | 1512 | } |
| 1513 | |
| 1514 | return skip; |
| 1515 | } |
| 1516 | |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 1517 | bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, |
| 1518 | const VkAllocationCallbacks *pAllocator, |
| 1519 | VkPipelineLayout *pPipelineLayout) const { |
| 1520 | bool skip = false; |
| 1521 | // Validate layout count against device physical limit |
| 1522 | if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) { |
| 1523 | skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286", |
| 1524 | "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).", |
| 1525 | pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets); |
| 1526 | } |
| 1527 | |
| 1528 | // Validate Push Constant ranges |
| 1529 | for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) { |
| 1530 | const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset; |
| 1531 | const uint32_t size = pCreateInfo->pPushConstantRanges[i].size; |
| 1532 | const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize; |
| 1533 | // Check that offset + size don't exceed the max. |
| 1534 | // Prevent arithetic overflow here by avoiding addition and testing in this order. |
| 1535 | if (offset >= max_push_constants_size) { |
| 1536 | skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294", |
| 1537 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this " |
| 1538 | "device's maxPushConstantSize of %u.", |
| 1539 | i, offset, max_push_constants_size); |
| 1540 | } |
| 1541 | if (size > max_push_constants_size - offset) { |
| 1542 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00298", |
| 1543 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) " |
| 1544 | "together exceeds this device's maxPushConstantSize of %u.", |
| 1545 | i, offset, size, max_push_constants_size); |
| 1546 | } |
| 1547 | |
| 1548 | // size needs to be non-zero and a multiple of 4. |
| 1549 | if (size == 0) { |
| 1550 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00296", |
| 1551 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.", |
| 1552 | i, size); |
| 1553 | } |
| 1554 | if (size & 0x3) { |
| 1555 | skip |= LogError(device, "VUID-VkPushConstantRange-size-00297", |
| 1556 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i, |
| 1557 | size); |
| 1558 | } |
| 1559 | |
| 1560 | // offset needs to be a multiple of 4. |
| 1561 | if ((offset & 0x3) != 0) { |
| 1562 | skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295", |
| 1563 | "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.", |
| 1564 | i, offset); |
| 1565 | } |
| 1566 | } |
| 1567 | |
| 1568 | // 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. |
| 1569 | for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) { |
| 1570 | for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) { |
| 1571 | if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) { |
| 1572 | skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292", |
| 1573 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j); |
| 1574 | } |
| 1575 | } |
| 1576 | } |
| 1577 | return skip; |
| 1578 | } |
| 1579 | |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 1580 | bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg, |
| 1581 | const VkPipelineShaderStageCreateInfo *pCreateInfo) const { |
| 1582 | bool skip = false; |
| 1583 | |
| 1584 | const auto *required_subgroup_size_features = |
| 1585 | LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext); |
| 1586 | |
| 1587 | if (required_subgroup_size_features) { |
| 1588 | if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) { |
| 1589 | skip |= LogError( |
| 1590 | device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754", |
| 1591 | "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while " |
| 1592 | "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.", |
| 1593 | func_name, msg, pCreateInfo->flags); |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | return skip; |
| 1598 | } |
| 1599 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1600 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 1601 | uint32_t createInfoCount, |
| 1602 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1603 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1604 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1605 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1606 | |
| 1607 | if (pCreateInfos != nullptr) { |
| 1608 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1609 | bool has_dynamic_viewport = false; |
| 1610 | bool has_dynamic_scissor = false; |
| 1611 | bool has_dynamic_line_width = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1612 | bool has_dynamic_depth_bias = false; |
| 1613 | bool has_dynamic_blend_constant = false; |
| 1614 | bool has_dynamic_depth_bounds = false; |
| 1615 | bool has_dynamic_stencil_compare = false; |
| 1616 | bool has_dynamic_stencil_write = false; |
| 1617 | bool has_dynamic_stencil_reference = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1618 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1619 | bool has_dynamic_discard_rectangle_ext = false; |
| 1620 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1621 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1622 | bool has_dynamic_shading_rate_palette_nv = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1623 | bool has_dynamic_viewport_course_sample_order_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1624 | bool has_dynamic_line_stipple = false; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1625 | bool has_dynamic_cull_mode = false; |
| 1626 | bool has_dynamic_front_face = false; |
| 1627 | bool has_dynamic_primitive_topology = false; |
| 1628 | bool has_dynamic_viewport_with_count = false; |
| 1629 | bool has_dynamic_scissor_with_count = false; |
| 1630 | bool has_dynamic_vertex_input_binding_stride = false; |
| 1631 | bool has_dynamic_depth_test_enable = false; |
| 1632 | bool has_dynamic_depth_write_enable = false; |
| 1633 | bool has_dynamic_depth_compare_op = false; |
| 1634 | bool has_dynamic_depth_bounds_test_enable = false; |
| 1635 | bool has_dynamic_stencil_test_enable = false; |
| 1636 | bool has_dynamic_stencil_op = false; |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 1637 | bool has_patch_control_points = false; |
| 1638 | bool has_rasterizer_discard_enable = false; |
| 1639 | bool has_depth_bias_enable = false; |
| 1640 | bool has_logic_op = false; |
| 1641 | bool has_primitive_restart_enable = false; |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 1642 | bool has_dynamic_vertex_input = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1643 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1644 | const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState; |
| 1645 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1646 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1647 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1648 | if (has_dynamic_viewport == true) { |
| 1649 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1650 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the " |
| 1651 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1652 | i); |
| 1653 | } |
| 1654 | has_dynamic_viewport = true; |
| 1655 | } |
| 1656 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) { |
| 1657 | if (has_dynamic_scissor == true) { |
| 1658 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1659 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the " |
| 1660 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1661 | i); |
| 1662 | } |
| 1663 | has_dynamic_scissor = true; |
| 1664 | } |
| 1665 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) { |
| 1666 | if (has_dynamic_line_width == true) { |
| 1667 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1668 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the " |
| 1669 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1670 | i); |
| 1671 | } |
| 1672 | has_dynamic_line_width = true; |
| 1673 | } |
| 1674 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) { |
| 1675 | if (has_dynamic_depth_bias == true) { |
| 1676 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1677 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the " |
| 1678 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1679 | i); |
| 1680 | } |
| 1681 | has_dynamic_depth_bias = true; |
| 1682 | } |
| 1683 | if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) { |
| 1684 | if (has_dynamic_blend_constant == true) { |
| 1685 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1686 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the " |
| 1687 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1688 | i); |
| 1689 | } |
| 1690 | has_dynamic_blend_constant = true; |
| 1691 | } |
| 1692 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) { |
| 1693 | if (has_dynamic_depth_bounds == true) { |
| 1694 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1695 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the " |
| 1696 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1697 | i); |
| 1698 | } |
| 1699 | has_dynamic_depth_bounds = true; |
| 1700 | } |
| 1701 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) { |
| 1702 | if (has_dynamic_stencil_compare == true) { |
| 1703 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1704 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in " |
| 1705 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1706 | i); |
| 1707 | } |
| 1708 | has_dynamic_stencil_compare = true; |
| 1709 | } |
| 1710 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) { |
| 1711 | if (has_dynamic_stencil_write == true) { |
| 1712 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1713 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in " |
| 1714 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1715 | i); |
| 1716 | } |
| 1717 | has_dynamic_stencil_write = true; |
| 1718 | } |
| 1719 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) { |
| 1720 | if (has_dynamic_stencil_reference == true) { |
| 1721 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1722 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in " |
| 1723 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1724 | i); |
| 1725 | } |
| 1726 | has_dynamic_stencil_reference = true; |
| 1727 | } |
| 1728 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) { |
| 1729 | if (has_dynamic_viewport_w_scaling_nv == true) { |
| 1730 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1731 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice " |
| 1732 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1733 | i); |
| 1734 | } |
| 1735 | has_dynamic_viewport_w_scaling_nv = true; |
| 1736 | } |
| 1737 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) { |
| 1738 | if (has_dynamic_discard_rectangle_ext == true) { |
| 1739 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1740 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice " |
| 1741 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1742 | i); |
| 1743 | } |
| 1744 | has_dynamic_discard_rectangle_ext = true; |
| 1745 | } |
| 1746 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) { |
| 1747 | if (has_dynamic_sample_locations_ext == true) { |
| 1748 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1749 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in " |
| 1750 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1751 | i); |
| 1752 | } |
| 1753 | has_dynamic_sample_locations_ext = true; |
| 1754 | } |
| 1755 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) { |
| 1756 | if (has_dynamic_exclusive_scissor_nv == true) { |
| 1757 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1758 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in " |
| 1759 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1760 | i); |
| 1761 | } |
| 1762 | has_dynamic_exclusive_scissor_nv = true; |
| 1763 | } |
| 1764 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) { |
| 1765 | if (has_dynamic_shading_rate_palette_nv == true) { |
| 1766 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1767 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was " |
| 1768 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1769 | i); |
| 1770 | } |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1771 | has_dynamic_shading_rate_palette_nv = true; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1772 | } |
| 1773 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) { |
| 1774 | if (has_dynamic_viewport_course_sample_order_nv == true) { |
| 1775 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1776 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was " |
| 1777 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1778 | i); |
| 1779 | } |
| 1780 | has_dynamic_viewport_course_sample_order_nv = true; |
| 1781 | } |
| 1782 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) { |
| 1783 | if (has_dynamic_line_stipple == true) { |
| 1784 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1785 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the " |
| 1786 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1787 | i); |
| 1788 | } |
| 1789 | has_dynamic_line_stipple = true; |
| 1790 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1791 | if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) { |
| 1792 | if (has_dynamic_cull_mode) { |
| 1793 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1794 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the " |
| 1795 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1796 | i); |
| 1797 | } |
| 1798 | has_dynamic_cull_mode = true; |
| 1799 | } |
| 1800 | if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) { |
| 1801 | if (has_dynamic_front_face) { |
| 1802 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1803 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the " |
| 1804 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1805 | i); |
| 1806 | } |
| 1807 | has_dynamic_front_face = true; |
| 1808 | } |
| 1809 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) { |
| 1810 | if (has_dynamic_primitive_topology) { |
| 1811 | skip |= LogError( |
| 1812 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1813 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the " |
| 1814 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1815 | i); |
| 1816 | } |
| 1817 | has_dynamic_primitive_topology = true; |
| 1818 | } |
| 1819 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) { |
| 1820 | if (has_dynamic_viewport_with_count) { |
| 1821 | skip |= LogError( |
| 1822 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1823 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the " |
| 1824 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1825 | i); |
| 1826 | } |
| 1827 | has_dynamic_viewport_with_count = true; |
| 1828 | } |
| 1829 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) { |
| 1830 | if (has_dynamic_scissor_with_count) { |
| 1831 | skip |= LogError( |
| 1832 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1833 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the " |
| 1834 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1835 | i); |
| 1836 | } |
| 1837 | has_dynamic_scissor_with_count = true; |
| 1838 | } |
| 1839 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) { |
| 1840 | if (has_dynamic_vertex_input_binding_stride) { |
| 1841 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1842 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was " |
| 1843 | "listed twice in the " |
| 1844 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1845 | i); |
| 1846 | } |
| 1847 | has_dynamic_vertex_input_binding_stride = true; |
| 1848 | } |
| 1849 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) { |
| 1850 | if (has_dynamic_depth_test_enable) { |
| 1851 | skip |= LogError( |
| 1852 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1853 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the " |
| 1854 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1855 | i); |
| 1856 | } |
| 1857 | has_dynamic_depth_test_enable = true; |
| 1858 | } |
| 1859 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) { |
| 1860 | if (has_dynamic_depth_write_enable) { |
| 1861 | skip |= LogError( |
| 1862 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1863 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the " |
| 1864 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1865 | i); |
| 1866 | } |
| 1867 | has_dynamic_depth_write_enable = true; |
| 1868 | } |
| 1869 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) { |
| 1870 | if (has_dynamic_depth_compare_op) { |
| 1871 | skip |= |
| 1872 | LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1873 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the " |
| 1874 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1875 | i); |
| 1876 | } |
| 1877 | has_dynamic_depth_compare_op = true; |
| 1878 | } |
| 1879 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) { |
| 1880 | if (has_dynamic_depth_bounds_test_enable) { |
| 1881 | skip |= LogError( |
| 1882 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1883 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the " |
| 1884 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1885 | i); |
| 1886 | } |
| 1887 | has_dynamic_depth_bounds_test_enable = true; |
| 1888 | } |
| 1889 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) { |
| 1890 | if (has_dynamic_stencil_test_enable) { |
| 1891 | skip |= LogError( |
| 1892 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1893 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the " |
| 1894 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1895 | i); |
| 1896 | } |
| 1897 | has_dynamic_stencil_test_enable = true; |
| 1898 | } |
| 1899 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) { |
| 1900 | if (has_dynamic_stencil_op) { |
| 1901 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1902 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the " |
| 1903 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1904 | i); |
| 1905 | } |
| 1906 | has_dynamic_stencil_op = true; |
| 1907 | } |
sfricke-samsung | 5f8f970 | 2021-01-29 23:30:30 -0800 | [diff] [blame] | 1908 | if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) { |
| 1909 | // Not allowed for graphics pipelines |
| 1910 | skip |= LogError( |
| 1911 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578", |
| 1912 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the " |
| 1913 | "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.", |
| 1914 | i, state_index); |
| 1915 | } |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 1916 | if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) { |
| 1917 | if (has_patch_control_points) { |
| 1918 | skip |= LogError( |
| 1919 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1920 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the " |
| 1921 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1922 | i); |
| 1923 | } |
| 1924 | has_patch_control_points = true; |
| 1925 | } |
| 1926 | if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) { |
| 1927 | if (has_rasterizer_discard_enable) { |
| 1928 | skip |= LogError( |
| 1929 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1930 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the " |
| 1931 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1932 | i); |
| 1933 | } |
| 1934 | has_rasterizer_discard_enable = true; |
| 1935 | } |
| 1936 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) { |
| 1937 | if (has_depth_bias_enable) { |
| 1938 | skip |= LogError( |
| 1939 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1940 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the " |
| 1941 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1942 | i); |
| 1943 | } |
| 1944 | has_depth_bias_enable = true; |
| 1945 | } |
| 1946 | if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) { |
| 1947 | if (has_logic_op) { |
| 1948 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1949 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the " |
| 1950 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1951 | i); |
| 1952 | } |
| 1953 | has_logic_op = true; |
| 1954 | } |
| 1955 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) { |
| 1956 | if (has_primitive_restart_enable) { |
| 1957 | skip |= LogError( |
| 1958 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1959 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the " |
| 1960 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1961 | i); |
| 1962 | } |
| 1963 | has_primitive_restart_enable = true; |
| 1964 | } |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 1965 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) { |
| 1966 | if (has_dynamic_vertex_input) { |
| 1967 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1968 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the " |
| 1969 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1970 | i); |
| 1971 | } |
| 1972 | has_dynamic_vertex_input = true; |
| 1973 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1974 | } |
| 1975 | } |
| 1976 | |
sfricke-samsung | 3b94442 | 2021-01-23 02:15:19 -0800 | [diff] [blame] | 1977 | if (has_dynamic_viewport_with_count && has_dynamic_viewport) { |
| 1978 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132", |
| 1979 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and " |
| 1980 | "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1981 | i); |
| 1982 | } |
| 1983 | |
| 1984 | if (has_dynamic_scissor_with_count && has_dynamic_scissor) { |
| 1985 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133", |
| 1986 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR " |
| 1987 | "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1988 | i); |
| 1989 | } |
| 1990 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1991 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1992 | if ((feedback_struct != nullptr) && |
| 1993 | (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1994 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668", |
| 1995 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 1996 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 1997 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
| 1998 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1999 | } |
| 2000 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2001 | // 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] | 2002 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2003 | // Collect active stages and other information |
| 2004 | // Only want to loop through pStages once |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2005 | uint32_t active_shaders = 0; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2006 | bool has_eval = false; |
| 2007 | bool has_control = false; |
| 2008 | if (pCreateInfos[i].pStages != nullptr) { |
| 2009 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 2010 | active_shaders |= pCreateInfos[i].pStages[stage_index].stage; |
| 2011 | |
| 2012 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 2013 | has_control = true; |
| 2014 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 2015 | has_eval = true; |
| 2016 | } |
| 2017 | |
| 2018 | skip |= validate_string( |
| 2019 | "vkCreateGraphicsPipelines", |
| 2020 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}), |
| 2021 | "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName); |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 2022 | |
| 2023 | std::stringstream msg; |
| 2024 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 2025 | ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(), |
| 2026 | &pCreateInfos[i].pStages[stage_index]); |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2027 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2028 | } |
| 2029 | |
| 2030 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
| 2031 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) { |
| 2032 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 2033 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 2034 | pCreateInfos[i].pTessellationState, |
| 2035 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2036 | "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
| 2037 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2038 | const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2039 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 2040 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2041 | skip |= validate_struct_pnext( |
| 2042 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
| 2043 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, |
| 2044 | ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info), |
| 2045 | allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion, |
| 2046 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 2047 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2048 | |
| 2049 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
| 2050 | pCreateInfos[i].pTessellationState->flags, |
| 2051 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 2052 | } |
| 2053 | |
| 2054 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) { |
| 2055 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 2056 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
| 2057 | pCreateInfos[i].pInputAssemblyState, |
| 2058 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2059 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 2060 | |
| 2061 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
| 2062 | pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2063 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2064 | |
| 2065 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
| 2066 | pCreateInfos[i].pInputAssemblyState->flags, |
| 2067 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 2068 | |
| 2069 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 2070 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
| 2071 | pCreateInfos[i].pInputAssemblyState->topology, |
| 2072 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 2073 | |
| 2074 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
| 2075 | pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable); |
| 2076 | } |
| 2077 | |
| 2078 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2079 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2080 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2081 | if (pCreateInfos[i].pVertexInputState->flags != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2082 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 2083 | "vkCreateGraphicsPipelines: pararameter " |
| 2084 | "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.", |
| 2085 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2086 | } |
| 2087 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2088 | const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2089 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
| 2090 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 2091 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", |
| 2092 | pCreateInfos[i].pVertexInputState->pNext, 1, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2093 | allowed_structs_vk_pipeline_vertex_input_state_create_info, |
| 2094 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2095 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2096 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 2097 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 2098 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2099 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 2100 | skip |= |
| 2101 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 2102 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
| 2103 | pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount, |
| 2104 | &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
| 2105 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 2106 | |
| 2107 | skip |= validate_array( |
| 2108 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 2109 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 2110 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 2111 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 2112 | |
| 2113 | if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2114 | for (uint32_t vertex_binding_description_index = 0; |
| 2115 | vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount; |
| 2116 | ++vertex_binding_description_index) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2117 | skip |= validate_ranged_enum( |
| 2118 | "vkCreateGraphicsPipelines", |
| 2119 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 2120 | AllVkVertexInputRateEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2121 | pCreateInfos[i] |
| 2122 | .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index] |
| 2123 | .inputRate, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2124 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 2125 | } |
| 2126 | } |
| 2127 | |
| 2128 | if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2129 | for (uint32_t vertex_attribute_description_index = 0; |
| 2130 | vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount; |
| 2131 | ++vertex_attribute_description_index) { |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2132 | const VkFormat format = |
| 2133 | pCreateInfos[i] |
| 2134 | .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index] |
| 2135 | .format; |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2136 | skip |= validate_ranged_enum( |
| 2137 | "vkCreateGraphicsPipelines", |
| 2138 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 2139 | AllVkFormatEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2140 | pCreateInfos[i] |
| 2141 | .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index] |
| 2142 | .format, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2143 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
sfricke-samsung | 2e82721 | 2021-09-28 07:52:08 -0700 | [diff] [blame] | 2144 | if (FormatIsDepthOrStencil(format)) { |
| 2145 | // Should never hopefully get here, but there are known driver advertising the wrong feature flags |
| 2146 | // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849 |
| 2147 | skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat, |
| 2148 | "vkCreateGraphicsPipelines: " |
| 2149 | "pCreateInfos[%d].pVertexInputState->pVertexAttributeDescriptions[%d].format is a " |
| 2150 | "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for " |
| 2151 | "alignment, replace with a color format.", |
| 2152 | i, vertex_attribute_description_index, string_VkFormat(format)); |
| 2153 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2154 | } |
| 2155 | } |
| 2156 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2157 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2158 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 2159 | "vkCreateGraphicsPipelines: pararameter " |
| 2160 | "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is " |
| 2161 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 2162 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2163 | } |
| 2164 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2165 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2166 | skip |= |
| 2167 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 2168 | "vkCreateGraphicsPipelines: pararameter " |
| 2169 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is " |
| 2170 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 2171 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2172 | } |
| 2173 | |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 2174 | layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2175 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 2176 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2177 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 2178 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2179 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 2180 | "vkCreateGraphicsPipelines: parameter " |
| 2181 | "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding " |
| 2182 | "(%" PRIu32 ") is not distinct.", |
| 2183 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2184 | } |
| 2185 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 2186 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2187 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2188 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 2189 | "vkCreateGraphicsPipelines: parameter " |
| 2190 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
| 2191 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 2192 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2193 | } |
| 2194 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2195 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2196 | skip |= |
| 2197 | LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 2198 | "vkCreateGraphicsPipelines: parameter " |
| 2199 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
| 2200 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).", |
| 2201 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2202 | } |
| 2203 | } |
| 2204 | |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 2205 | layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2206 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 2207 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2208 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 2209 | if (location_it != attribute_locations.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2210 | skip |= LogError( |
| 2211 | device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2212 | "vkCreateGraphicsPipelines: parameter " |
| 2213 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.", |
| 2214 | i, d, vertex_attrib_desc.location); |
| 2215 | } |
| 2216 | attribute_locations.insert(vertex_attrib_desc.location); |
| 2217 | |
| 2218 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 2219 | if (binding_it == vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2220 | skip |= LogError( |
| 2221 | device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 2222 | "vkCreateGraphicsPipelines: parameter " |
| 2223 | " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist " |
| 2224 | "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.", |
| 2225 | i, d, vertex_attrib_desc.binding, i); |
| 2226 | } |
| 2227 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2228 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2229 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 2230 | "vkCreateGraphicsPipelines: parameter " |
| 2231 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
| 2232 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 2233 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2234 | } |
| 2235 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2236 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2237 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 2238 | "vkCreateGraphicsPipelines: parameter " |
| 2239 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
| 2240 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 2241 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2242 | } |
| 2243 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2244 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2245 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 2246 | "vkCreateGraphicsPipelines: parameter " |
| 2247 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 2248 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).", |
| 2249 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2250 | } |
| 2251 | } |
| 2252 | } |
| 2253 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2254 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 2255 | if (has_control && has_eval) { |
| 2256 | if (pCreateInfos[i].pTessellationState == nullptr) { |
| 2257 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
| 2258 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 2259 | "shader stage and a tessellation evaluation shader stage, " |
| 2260 | "pCreateInfos[%d].pTessellationState must not be NULL.", |
| 2261 | i, i); |
| 2262 | } else { |
| 2263 | const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
| 2264 | skip |= validate_struct_pnext( |
| 2265 | "vkCreateGraphicsPipelines", |
| 2266 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
| 2267 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1, |
| 2268 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 2269 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2270 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2271 | skip |= validate_reserved_flags( |
| 2272 | "vkCreateGraphicsPipelines", |
| 2273 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
| 2274 | pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2275 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 2276 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
| 2277 | pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
| 2278 | skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 2279 | "vkCreateGraphicsPipelines: invalid parameter " |
| 2280 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
| 2281 | "should be >0 and <=%u.", |
| 2282 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
| 2283 | device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2284 | } |
| 2285 | } |
| 2286 | } |
| 2287 | |
| 2288 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 2289 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 2290 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 2291 | if (pCreateInfos[i].pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2292 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 2293 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 2294 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 2295 | "].pViewportState (=NULL) is not a valid pointer.", |
| 2296 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2297 | } else { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2298 | const auto &viewport_state = *pCreateInfos[i].pViewportState; |
| 2299 | |
| 2300 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2301 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 2302 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2303 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 2304 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2305 | } |
| 2306 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2307 | const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2308 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2309 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 2310 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2311 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 2312 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2313 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2314 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2315 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2316 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2317 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 2318 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
| 2319 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2320 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info), |
| 2321 | allowed_structs_vk_pipeline_viewport_state_create_info, 65, |
| 2322 | "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2323 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2324 | |
| 2325 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2326 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2327 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2328 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2329 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2330 | auto exclusive_scissor_struct = |
| 2331 | LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
| 2332 | auto shading_rate_image_struct = |
| 2333 | LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
| 2334 | auto coarse_sample_order_struct = |
| 2335 | LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2336 | const auto vp_swizzle_struct = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2337 | LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2338 | const auto vp_w_scaling_struct = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2339 | LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2340 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2341 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2342 | if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2343 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 2344 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2345 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 2346 | ") is not 1.", |
| 2347 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2348 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2349 | |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2350 | if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2351 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 2352 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2353 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2354 | ") is not 1.", |
| 2355 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2356 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2357 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2358 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 2359 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2360 | skip |= LogError( |
| 2361 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 2362 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2363 | "disabled, but pCreateInfos[%" PRIu32 |
| 2364 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 2365 | ") is not 1.", |
| 2366 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2367 | } |
| 2368 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2369 | if (shading_rate_image_struct && |
| 2370 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2371 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 2372 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2373 | "disabled, but pCreateInfos[%" PRIu32 |
| 2374 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 2375 | ") is neither 0 nor 1.", |
| 2376 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2377 | } |
| 2378 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2379 | } else { // multiViewport enabled |
| 2380 | if (viewport_state.viewportCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2381 | if (!has_dynamic_viewport_with_count) { |
| 2382 | skip |= LogError( |
| 2383 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
| 2384 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
| 2385 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2386 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2387 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 2388 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2389 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2390 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2391 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2392 | } else if (has_dynamic_viewport_with_count) { |
| 2393 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379", |
| 2394 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2395 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2396 | ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.", |
| 2397 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2398 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2399 | |
| 2400 | if (viewport_state.scissorCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2401 | if (!has_dynamic_scissor_with_count) { |
| 2402 | skip |= LogError( |
| 2403 | device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength", |
| 2404 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
| 2405 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2406 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2407 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 2408 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2409 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2410 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2411 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2412 | } else if (has_dynamic_scissor_with_count) { |
| 2413 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380", |
| 2414 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2415 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2416 | ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.", |
| 2417 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2418 | } |
| 2419 | } |
| 2420 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2421 | if (!has_dynamic_scissor && viewport_state.pScissors) { |
| 2422 | for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) { |
| 2423 | const auto &scissor = viewport_state.pScissors[scissor_i]; |
ziga-lunarg | a77dc80 | 2021-07-15 13:19:06 +0200 | [diff] [blame] | 2424 | |
| 2425 | if (scissor.offset.x < 0) { |
| 2426 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821", |
| 2427 | "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32 |
| 2428 | "].pViewportState->pScissors[%" PRIu32 "] is negative.", |
| 2429 | scissor.offset.x, i, scissor_i); |
| 2430 | } |
| 2431 | |
| 2432 | if (scissor.offset.y < 0) { |
| 2433 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821", |
| 2434 | "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32 |
| 2435 | "].pViewportState->pScissors[%" PRIu32 "] is negative.", |
| 2436 | scissor.offset.y, i, scissor_i); |
| 2437 | } |
| 2438 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2439 | const int64_t x_sum = |
| 2440 | static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 2441 | if (x_sum > std::numeric_limits<int32_t>::max()) { |
| 2442 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822", |
| 2443 | "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 |
| 2444 | " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32 |
| 2445 | "] will overflow int32_t.", |
| 2446 | scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i); |
| 2447 | } |
ziga-lunarg | a77dc80 | 2021-07-15 13:19:06 +0200 | [diff] [blame] | 2448 | |
ziga-lunarg | 845883b | 2021-07-14 15:05:00 +0200 | [diff] [blame] | 2449 | const int64_t y_sum = |
| 2450 | static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 2451 | if (y_sum > std::numeric_limits<int32_t>::max()) { |
| 2452 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823", |
| 2453 | "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 |
| 2454 | " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32 |
| 2455 | "] will overflow int32_t.", |
| 2456 | scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i); |
| 2457 | } |
| 2458 | } |
| 2459 | } |
| 2460 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2461 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2462 | skip |= |
| 2463 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 2464 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2465 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2466 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2467 | } |
| 2468 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2469 | 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] | 2470 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 2471 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2472 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2473 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2474 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2475 | } |
| 2476 | |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2477 | if (viewport_state.scissorCount != viewport_state.viewportCount && |
| 2478 | !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2479 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220", |
| 2480 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2481 | "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32 |
| 2482 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2483 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2484 | } |
| 2485 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2486 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2487 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2488 | skip |= |
| 2489 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 2490 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2491 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 2492 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2493 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2494 | } |
| 2495 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2496 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2497 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2498 | skip |= LogError( |
| 2499 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2500 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 2501 | "] " |
| 2502 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2503 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2504 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2505 | } |
| 2506 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2507 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2508 | skip |= LogError( |
| 2509 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2510 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 2511 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2512 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 2513 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2514 | } |
| 2515 | |
| 2516 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2517 | skip |= LogError( |
| 2518 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2519 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 2520 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2521 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 2522 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2523 | } |
| 2524 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2525 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2526 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 2527 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 2528 | skip |= |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2529 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2530 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 2531 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 2532 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 2533 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2534 | } |
| 2535 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2536 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2537 | shading_rate_image_struct->viewportCount > 0 && |
| 2538 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2539 | skip |= LogError( |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2540 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2541 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2542 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 2543 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2544 | i, i); |
| 2545 | } |
| 2546 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2547 | if (vp_swizzle_struct) { |
| 2548 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2549 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 2550 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 2551 | " does " |
| 2552 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 2553 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2554 | } |
| 2555 | } |
| 2556 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2557 | // validate the VkViewports |
| 2558 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 2559 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 2560 | 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] | 2561 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 2562 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 2563 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 2564 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2565 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2566 | } |
| 2567 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2568 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2569 | 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] | 2570 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2571 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2572 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 2573 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 2574 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2575 | } |
| 2576 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2577 | 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] | 2578 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2579 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2580 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 2581 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 2582 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2583 | } |
| 2584 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2585 | 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] | 2586 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2587 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2588 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 2589 | "VK_EXT_sample_locations extension is not enabled.", |
| 2590 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2591 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2592 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 2593 | 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] | 2594 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2595 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2596 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 2597 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 2598 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2599 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2600 | |
| 2601 | if (coarse_sample_order_struct && |
| 2602 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 2603 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2604 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 2605 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2606 | "] " |
| 2607 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 2608 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 2609 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2610 | } |
| 2611 | |
| 2612 | if (coarse_sample_order_struct) { |
| 2613 | 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] | 2614 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2615 | } |
| 2616 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2617 | |
| 2618 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 2619 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2620 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 2621 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2622 | "] " |
| 2623 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 2624 | ") " |
| 2625 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 2626 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2627 | } |
| 2628 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2629 | skip |= LogError( |
| 2630 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2631 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2632 | "] " |
| 2633 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 2634 | i); |
| 2635 | } |
| 2636 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2637 | } |
| 2638 | |
| 2639 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2640 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
| 2641 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 2642 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.", |
| 2643 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2644 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2645 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 2646 | LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType, |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2647 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 2648 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 2649 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2650 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2651 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2652 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2653 | "vkCreateGraphicsPipelines", |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2654 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 2655 | valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2656 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 2657 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2658 | |
| 2659 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2660 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2661 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2662 | pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2663 | |
| 2664 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2665 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2666 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 2667 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 2668 | |
| 2669 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2670 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2671 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2672 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2673 | pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2674 | true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2675 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2676 | skip |= validate_flags( |
| 2677 | "vkCreateGraphicsPipelines", |
| 2678 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2679 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2680 | kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2681 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2682 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2683 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2684 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 2685 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 2686 | |
| 2687 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2688 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2689 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 2690 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 2691 | |
| 2692 | if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 2693 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2694 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 2695 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 2696 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2697 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2698 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2699 | if (!physical_device_features.sampleRateShading) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2700 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 2701 | "vkCreateGraphicsPipelines(): parameter " |
| 2702 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.", |
| 2703 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2704 | } |
| 2705 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 2706 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
| 2707 | if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2708 | skip |= LogError( |
| 2709 | device, |
| 2710 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2711 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2712 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2713 | } |
| 2714 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2715 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2716 | const auto *line_state = |
| 2717 | LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2718 | |
| 2719 | if (line_state) { |
| 2720 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 2721 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
| 2722 | if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) { |
| 2723 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2724 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2725 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2726 | "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
| 2727 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2728 | } |
| 2729 | if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) { |
| 2730 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2731 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2732 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2733 | "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
| 2734 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2735 | } |
| 2736 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) { |
| 2737 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2738 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2739 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2740 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
| 2741 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2742 | } |
| 2743 | } |
| 2744 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 2745 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 2746 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2747 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
| 2748 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the " |
| 2749 | "range [1,256].", |
| 2750 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2751 | } |
| 2752 | } |
| 2753 | const auto *line_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2754 | LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2755 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2756 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2757 | skip |= |
| 2758 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
| 2759 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2760 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 2761 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2762 | } |
| 2763 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2764 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2765 | skip |= |
| 2766 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
| 2767 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2768 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 2769 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2770 | } |
| 2771 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2772 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2773 | skip |= |
| 2774 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
| 2775 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2776 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 2777 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2778 | } |
| 2779 | if (line_state->stippledLineEnable) { |
| 2780 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2781 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2782 | skip |= |
| 2783 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
| 2784 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2785 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 2786 | "stippledRectangularLines feature.", |
| 2787 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2788 | } |
| 2789 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2790 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2791 | skip |= |
| 2792 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
| 2793 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2794 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 2795 | "stippledBresenhamLines feature.", |
| 2796 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2797 | } |
| 2798 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2799 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2800 | skip |= |
| 2801 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
| 2802 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2803 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 2804 | "stippledSmoothLines feature.", |
| 2805 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2806 | } |
| 2807 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
| 2808 | (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2809 | skip |= |
| 2810 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
| 2811 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2812 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 2813 | "stippledRectangularLines and strictLines features.", |
| 2814 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2815 | } |
| 2816 | } |
| 2817 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2818 | } |
| 2819 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2820 | bool uses_color_attachment = false; |
| 2821 | bool uses_depthstencil_attachment = false; |
| 2822 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2823 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2824 | const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass); |
| 2825 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2826 | const auto &subpasses_uses = subpasses_uses_it->second; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2827 | if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2828 | uses_color_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2829 | } |
| 2830 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2831 | uses_depthstencil_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2832 | } |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2833 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2834 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2835 | } |
| 2836 | |
| 2837 | if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2838 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2839 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2840 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2841 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2842 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2843 | |
| 2844 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2845 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2846 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2847 | pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2848 | |
| 2849 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2850 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2851 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 2852 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 2853 | |
| 2854 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2855 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2856 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 2857 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 2858 | |
| 2859 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2860 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2861 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 2862 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2863 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2864 | |
| 2865 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2866 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2867 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 2868 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 2869 | |
| 2870 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2871 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2872 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 2873 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 2874 | |
| 2875 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2876 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2877 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 2878 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2879 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2880 | |
| 2881 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2882 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2883 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 2884 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2885 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2886 | |
| 2887 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2888 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2889 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 2890 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2891 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2892 | |
| 2893 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2894 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2895 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 2896 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2897 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2898 | |
| 2899 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2900 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2901 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
| 2902 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2903 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2904 | |
| 2905 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2906 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2907 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
| 2908 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2909 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2910 | |
| 2911 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2912 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2913 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 2914 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2915 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2916 | |
| 2917 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2918 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2919 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 2920 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2921 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2922 | |
| 2923 | if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 2924 | skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2925 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 2926 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 2927 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2928 | } |
| 2929 | } |
| 2930 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2931 | const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = { |
ziga-lunarg | 8de0916 | 2021-08-05 15:21:33 +0200 | [diff] [blame] | 2932 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT, |
| 2933 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT}; |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2934 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2935 | if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2936 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 2937 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 2938 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2939 | pCreateInfos[i].pColorBlendState, |
| 2940 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2941 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
| 2942 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2943 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2944 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2945 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
ziga-lunarg | 8de0916 | 2021-08-05 15:21:33 +0200 | [diff] [blame] | 2946 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2947 | ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info), |
| 2948 | allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2949 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 2950 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2951 | |
| 2952 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2953 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2954 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2955 | pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2956 | |
| 2957 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2958 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2959 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 2960 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 2961 | |
| 2962 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2963 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2964 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 2965 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2966 | pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2967 | true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2968 | |
| 2969 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2970 | for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 2971 | ++attachment_index) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2972 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2973 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2974 | ParameterName::IndexVector{i, attachment_index}), |
| 2975 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2976 | |
| 2977 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2978 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2979 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2980 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2981 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2982 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2983 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2984 | |
| 2985 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2986 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2987 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2988 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2989 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2990 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2991 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2992 | |
| 2993 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2994 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2995 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2996 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2997 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2998 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2999 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3000 | |
| 3001 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3002 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3003 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3004 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3005 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3006 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3007 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3008 | |
| 3009 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3010 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3011 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3012 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3013 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3014 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3015 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3016 | |
| 3017 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3018 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3019 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3020 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3021 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3022 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3023 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3024 | |
| 3025 | skip |= |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3026 | validate_flags("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3027 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3028 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3029 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3030 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 3031 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
ziga-lunarg | a283d02 | 2021-08-04 18:35:23 +0200 | [diff] [blame] | 3032 | |
| 3033 | if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) { |
| 3034 | bool invalid = false; |
| 3035 | switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) { |
| 3036 | case VK_BLEND_OP_ZERO_EXT: |
| 3037 | case VK_BLEND_OP_SRC_EXT: |
| 3038 | case VK_BLEND_OP_DST_EXT: |
| 3039 | case VK_BLEND_OP_SRC_OVER_EXT: |
| 3040 | case VK_BLEND_OP_DST_OVER_EXT: |
| 3041 | case VK_BLEND_OP_SRC_IN_EXT: |
| 3042 | case VK_BLEND_OP_DST_IN_EXT: |
| 3043 | case VK_BLEND_OP_SRC_OUT_EXT: |
| 3044 | case VK_BLEND_OP_DST_OUT_EXT: |
| 3045 | case VK_BLEND_OP_SRC_ATOP_EXT: |
| 3046 | case VK_BLEND_OP_DST_ATOP_EXT: |
| 3047 | case VK_BLEND_OP_XOR_EXT: |
| 3048 | case VK_BLEND_OP_INVERT_EXT: |
| 3049 | case VK_BLEND_OP_INVERT_RGB_EXT: |
| 3050 | case VK_BLEND_OP_LINEARDODGE_EXT: |
| 3051 | case VK_BLEND_OP_LINEARBURN_EXT: |
| 3052 | case VK_BLEND_OP_VIVIDLIGHT_EXT: |
| 3053 | case VK_BLEND_OP_LINEARLIGHT_EXT: |
| 3054 | case VK_BLEND_OP_PINLIGHT_EXT: |
| 3055 | case VK_BLEND_OP_HARDMIX_EXT: |
| 3056 | case VK_BLEND_OP_PLUS_EXT: |
| 3057 | case VK_BLEND_OP_PLUS_CLAMPED_EXT: |
| 3058 | case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT: |
| 3059 | case VK_BLEND_OP_PLUS_DARKER_EXT: |
| 3060 | case VK_BLEND_OP_MINUS_EXT: |
| 3061 | case VK_BLEND_OP_MINUS_CLAMPED_EXT: |
| 3062 | case VK_BLEND_OP_CONTRAST_EXT: |
| 3063 | case VK_BLEND_OP_INVERT_OVG_EXT: |
| 3064 | case VK_BLEND_OP_RED_EXT: |
| 3065 | case VK_BLEND_OP_GREEN_EXT: |
| 3066 | case VK_BLEND_OP_BLUE_EXT: |
| 3067 | invalid = true; |
| 3068 | break; |
| 3069 | default: |
| 3070 | break; |
| 3071 | } |
| 3072 | if (invalid) { |
| 3073 | skip |= LogError( |
| 3074 | device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409", |
| 3075 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 3076 | "].pColorBlendState->pAttachments[%" PRIu32 |
| 3077 | "].colorBlendOp (%s) is not valid when " |
| 3078 | "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is " |
| 3079 | "VK_FALSE", |
| 3080 | i, attachment_index, |
| 3081 | string_VkBlendOp( |
| 3082 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp)); |
| 3083 | } |
| 3084 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3085 | } |
| 3086 | } |
| 3087 | |
| 3088 | if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 3089 | skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3090 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 3091 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 3092 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3093 | } |
| 3094 | |
| 3095 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 3096 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 3097 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3098 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3099 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3100 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, |
| 3101 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3102 | } |
| 3103 | } |
| 3104 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3105 | |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3106 | const VkPipelineCreateFlags flags = pCreateInfos[i].flags; |
| 3107 | if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 3108 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 3109 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3110 | skip |= |
| 3111 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3112 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3113 | "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] | 3114 | "and pCreateInfos->basePipelineIndex is not -1.", |
| 3115 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3116 | } |
| 3117 | } |
| 3118 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 3119 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 3120 | if (pCreateInfos[i].basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3121 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3122 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3123 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3124 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 3125 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3126 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 3127 | } else { |
Mike Schuchardt | e5c15cf | 2020-04-06 22:57:13 -0700 | [diff] [blame] | 3128 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3129 | skip |= |
| 3130 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
| 3131 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid" |
| 3132 | "index into the pCreateInfos array, of size %d.", |
| 3133 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 3134 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3135 | } |
| 3136 | } |
| 3137 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 3138 | if (pCreateInfos[i].pRasterizationState) { |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3139 | if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3140 | if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
| 3141 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3142 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 3143 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 3144 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 3145 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3146 | } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 3147 | (physical_device_features.fillModeNonSolid == false)) { |
sfricke-samsung | a44586f | 2020-08-23 22:19:44 -0700 | [diff] [blame] | 3148 | skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3149 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3150 | "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
| 3151 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 3152 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3153 | } |
| 3154 | } else { |
| 3155 | if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 3156 | (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
| 3157 | (physical_device_features.fillModeNonSolid == false)) { |
| 3158 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3159 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 3160 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 3161 | "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
| 3162 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 3163 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 3164 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3165 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3166 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3167 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3168 | (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3169 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 3170 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 3171 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 3172 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 3173 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
| 3174 | i, i, pCreateInfos[i].pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3175 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3176 | } |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3177 | |
| 3178 | // Validate no flags not allowed are used |
| 3179 | if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) { |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3180 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764", |
| 3181 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3182 | "VK_PIPELINE_CREATE_DISPATCH_BASE.", |
| 3183 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3184 | } |
| 3185 | if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) { |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3186 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371", |
| 3187 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3188 | "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.", |
| 3189 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3190 | } |
| 3191 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) { |
| 3192 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372", |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3193 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3194 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.", |
| 3195 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3196 | } |
| 3197 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) { |
| 3198 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373", |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3199 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3200 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.", |
| 3201 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3202 | } |
| 3203 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) { |
| 3204 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374", |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3205 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3206 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.", |
| 3207 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3208 | } |
| 3209 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) { |
| 3210 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375", |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3211 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3212 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.", |
| 3213 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3214 | } |
| 3215 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) { |
| 3216 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376", |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3217 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3218 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.", |
| 3219 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3220 | } |
| 3221 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) { |
| 3222 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377", |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3223 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3224 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.", |
| 3225 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3226 | } |
| 3227 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) { |
| 3228 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577", |
sfricke-samsung | ad00890 | 2021-04-16 01:25:34 -0700 | [diff] [blame] | 3229 | "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3230 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.", |
| 3231 | i, flags); |
sfricke-samsung | 5ea45bd | 2021-01-23 02:38:36 -0800 | [diff] [blame] | 3232 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3233 | } |
| 3234 | } |
| 3235 | |
| 3236 | return skip; |
| 3237 | } |
| 3238 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3239 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 3240 | uint32_t createInfoCount, |
| 3241 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 3242 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3243 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3244 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3245 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3246 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3247 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 3248 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3249 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 3250 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3251 | skip |= |
| 3252 | LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669", |
| 3253 | "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32 |
| 3254 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".", |
| 3255 | i, feedback_struct->pipelineStageCreationFeedbackCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 3256 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 3257 | |
| 3258 | // Make sure compute stage is selected |
| 3259 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3260 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
| 3261 | "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
| 3262 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 3263 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3264 | |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3265 | const VkPipelineCreateFlags flags = pCreateInfos[i].flags; |
| 3266 | // Validate no flags not allowed are used |
| 3267 | if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) { |
| 3268 | skip |= LogError( |
| 3269 | device, "VUID-VkComputePipelineCreateInfo-flags-03364", |
| 3270 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.", |
| 3271 | i, flags); |
| 3272 | } |
| 3273 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) { |
| 3274 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365", |
| 3275 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3276 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.", |
| 3277 | i, flags); |
| 3278 | } |
| 3279 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) { |
| 3280 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366", |
| 3281 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3282 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.", |
| 3283 | i, flags); |
| 3284 | } |
| 3285 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) { |
| 3286 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367", |
| 3287 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3288 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.", |
| 3289 | i, flags); |
| 3290 | } |
| 3291 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) { |
| 3292 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368", |
| 3293 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3294 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.", |
| 3295 | i, flags); |
| 3296 | } |
| 3297 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) { |
| 3298 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369", |
| 3299 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3300 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.", |
| 3301 | i, flags); |
| 3302 | } |
| 3303 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) { |
| 3304 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370", |
| 3305 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3306 | "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.", |
| 3307 | i, flags); |
| 3308 | } |
| 3309 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) { |
| 3310 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576", |
| 3311 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3312 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.", |
| 3313 | i, flags); |
| 3314 | } |
ziga-lunarg | f51e65f | 2021-07-18 23:51:57 +0200 | [diff] [blame] | 3315 | if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) { |
| 3316 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945", |
| 3317 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3318 | "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.", |
| 3319 | i, flags); |
| 3320 | } |
sfricke-samsung | eb54901 | 2021-04-16 01:25:51 -0700 | [diff] [blame] | 3321 | if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) { |
| 3322 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874", |
| 3323 | "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include " |
| 3324 | "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.", |
| 3325 | i, flags); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3326 | } |
ziga-lunarg | 065f240 | 2021-07-22 11:56:05 +0200 | [diff] [blame] | 3327 | if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 3328 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 3329 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 3330 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699", |
| 3331 | "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32 |
| 3332 | "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the " |
| 3333 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.", |
| 3334 | i); |
| 3335 | } |
| 3336 | } |
| 3337 | |
| 3338 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 3339 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 3340 | skip |= LogError( |
| 3341 | device, "VUID-VkComputePipelineCreateInfo-flags-00700", |
| 3342 | "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32 |
| 3343 | "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT " |
| 3344 | "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 3345 | i); |
| 3346 | } |
| 3347 | } else { |
| 3348 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
| 3349 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698", |
| 3350 | "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32 |
| 3351 | ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".", |
| 3352 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 3353 | } |
| 3354 | } |
| 3355 | } |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 3356 | |
| 3357 | std::stringstream msg; |
| 3358 | msg << "pCreateInfos[%" << i << "].stage"; |
| 3359 | ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3360 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3361 | return skip; |
| 3362 | } |
| 3363 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3364 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3365 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3366 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3367 | |
| 3368 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3369 | const auto &features = physical_device_features; |
| 3370 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3371 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3372 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 3373 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3374 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 3375 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 3376 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 3377 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3378 | } |
| 3379 | |
| 3380 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 3381 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3382 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 3383 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 3384 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3385 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3386 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3387 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3388 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 3389 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3390 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 3391 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3392 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 3393 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3394 | } |
| 3395 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3396 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 3397 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3398 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 3399 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3400 | } |
| 3401 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3402 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 3403 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3404 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 3405 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3406 | } |
| 3407 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 3408 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 3409 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 3410 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3411 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 3412 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 3413 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 3414 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 3415 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 3416 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3417 | } |
| 3418 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3419 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 3420 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 3421 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 3422 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3423 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3424 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 3425 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 3426 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 3427 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3428 | } |
| 3429 | |
| 3430 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 3431 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3432 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 3433 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3434 | const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 3435 | if (sampler_reduction != nullptr) { |
| 3436 | if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
| 3437 | skip |= LogError( |
| 3438 | device, "VUID-VkSamplerCreateInfo-compareEnable-01423", |
| 3439 | "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE."); |
| 3440 | } |
| 3441 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3442 | } |
| 3443 | |
| 3444 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 3445 | // valid VkBorderColor value |
| 3446 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 3447 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 3448 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3449 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 3450 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3451 | } |
| 3452 | |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 3453 | // Checks for the IMG cubic filtering extension |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3454 | if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 3455 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 3456 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3457 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 3458 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 3459 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 3460 | } |
| 3461 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 3462 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 3463 | // Check for valid Lod range |
| 3464 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 3465 | skip |= |
| 3466 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 3467 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 3468 | } |
| 3469 | |
| 3470 | // Check mipLodBias to device limit |
| 3471 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 3472 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 3473 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 3474 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 3475 | } |
| 3476 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3477 | const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 3478 | if (sampler_conversion != nullptr) { |
| 3479 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 3480 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 3481 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 3482 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3483 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 3484 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 3485 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 3486 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 3487 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 3488 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 3489 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 3490 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 3491 | } |
| 3492 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 3493 | |
| 3494 | if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) { |
| 3495 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
| 3496 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574", |
| 3497 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3498 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 3499 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
| 3500 | } |
| 3501 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
| 3502 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575", |
| 3503 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3504 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 3505 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
| 3506 | } |
| 3507 | if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) { |
| 3508 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576", |
| 3509 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3510 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.", |
| 3511 | pCreateInfo->minLod, pCreateInfo->maxLod); |
| 3512 | } |
| 3513 | if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3514 | (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) || |
| 3515 | ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3516 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) { |
| 3517 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577", |
| 3518 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3519 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be " |
| 3520 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER", |
| 3521 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 3522 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
| 3523 | } |
| 3524 | if (pCreateInfo->anisotropyEnable) { |
| 3525 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578", |
| 3526 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3527 | "pCreateInfo->anisotropyEnable must be VK_FALSE"); |
| 3528 | } |
| 3529 | if (pCreateInfo->compareEnable) { |
| 3530 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579", |
| 3531 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3532 | "pCreateInfo->compareEnable must be VK_FALSE"); |
| 3533 | } |
| 3534 | if (pCreateInfo->unnormalizedCoordinates) { |
| 3535 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580", |
| 3536 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3537 | "pCreateInfo->unnormalizedCoordinates must be VK_FALSE"); |
| 3538 | } |
| 3539 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3540 | } |
| 3541 | |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3542 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 3543 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3544 | if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) { |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3545 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 3546 | "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n", |
| 3547 | string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 3548 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3549 | auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext); |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3550 | if (!custom_create_info) { |
| 3551 | skip |= |
| 3552 | LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011", |
| 3553 | "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT " |
| 3554 | "struct in pNext chain.\n", |
| 3555 | string_VkBorderColor(pCreateInfo->borderColor)); |
| 3556 | } else { |
| 3557 | if ((custom_create_info->format != VK_FORMAT_UNDEFINED) && |
| 3558 | ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) || |
| 3559 | (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT && |
| 3560 | !FormatIsSampledFloat(custom_create_info->format)))) { |
| 3561 | skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013", |
| 3562 | "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s " |
| 3563 | "whose type does not match\n", |
| 3564 | string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format)); |
| 3565 | ; |
| 3566 | } |
| 3567 | } |
| 3568 | } |
| 3569 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3570 | return skip; |
| 3571 | } |
| 3572 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3573 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 3574 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 3575 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3576 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3577 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3578 | |
| 3579 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3580 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 3581 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 3582 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3583 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3584 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 3585 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 3586 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 3587 | ++descriptor_index) { |
| 3588 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Spencer Fricke | b0e3082 | 2020-03-23 10:32:30 -0700 | [diff] [blame] | 3589 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3590 | "vkCreateDescriptorSetLayout: required parameter " |
| 3591 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE", |
| 3592 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3593 | } |
| 3594 | } |
| 3595 | } |
| 3596 | |
| 3597 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 3598 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3599 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3600 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
| 3601 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 3602 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits " |
| 3603 | "values.", |
| 3604 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3605 | } |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 3606 | |
| 3607 | if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) && |
| 3608 | (pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3609 | (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) { |
| 3610 | skip |= |
| 3611 | LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510", |
| 3612 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and " |
| 3613 | "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags " |
| 3614 | "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s", |
| 3615 | i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str()); |
| 3616 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3617 | } |
| 3618 | } |
| 3619 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3620 | return skip; |
| 3621 | } |
| 3622 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3623 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 3624 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3625 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3626 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3627 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3628 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3629 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 3630 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3631 | } |
| 3632 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3633 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 3634 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3635 | const bool validateDstSet) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3636 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3637 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3638 | if (pDescriptorWrites != NULL) { |
| 3639 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 3640 | // descriptorCount must be greater than 0 |
| 3641 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 3642 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3643 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 3644 | "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3645 | } |
| 3646 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3647 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
| 3648 | if (validateDstSet) { |
| 3649 | // dstSet must be a valid VkDescriptorSet handle |
| 3650 | skip |= validate_required_handle(vkCallingFunction, |
| 3651 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 3652 | pDescriptorWrites[i].dstSet); |
| 3653 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3654 | |
| 3655 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3656 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 3657 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 3658 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 3659 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 3660 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 3661 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3662 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures. |
| 3663 | // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3664 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3665 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322", |
| 3666 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3667 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 3668 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 3669 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.", |
| 3670 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3671 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 3672 | // 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] | 3673 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout |
| 3674 | // member of any given element of pImageInfo must be a valid VkImageLayout |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3675 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 3676 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3677 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3678 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 3679 | ParameterName::IndexVector{i, descriptor_index}), |
| 3680 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3681 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3682 | } |
| 3683 | } |
| 3684 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3685 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3686 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 3687 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 3688 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 3689 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 3690 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3691 | // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3692 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3693 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
| 3694 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3695 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 3696 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
| 3697 | "pDescriptorWrites[%d].pBufferInfo must not be NULL.", |
| 3698 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3699 | } else { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3700 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3701 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3702 | if (robustness2_features && robustness2_features->nullDescriptor) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3703 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 3704 | ++descriptor_index) { |
| 3705 | if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE && |
| 3706 | (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 || |
| 3707 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3708 | skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999", |
| 3709 | "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, " |
baldurk | 751594b | 2020-09-09 09:41:02 +0100 | [diff] [blame] | 3710 | "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] | 3711 | vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset, |
| 3712 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3713 | } |
| 3714 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3715 | } |
| 3716 | } |
| 3717 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 3718 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3719 | // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3720 | } |
| 3721 | |
| 3722 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3723 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3724 | VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3725 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3726 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3727 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3728 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3729 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
| 3730 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3731 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3732 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3733 | } |
| 3734 | } |
| 3735 | } |
| 3736 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3737 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3738 | VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3739 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3740 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3741 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3742 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3743 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
| 3744 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3745 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3746 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3747 | } |
| 3748 | } |
| 3749 | } |
| 3750 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3751 | // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR |
| 3752 | // or VkWriteDescriptorSetInlineUniformBlockEX |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3753 | if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3754 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3755 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 3756 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382", |
| 3757 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext" |
| 3758 | "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose " |
| 3759 | "accelerationStructureCount %d member equals descriptorCount %d.", |
| 3760 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 3761 | pDescriptorWrites[i].descriptorCount); |
| 3762 | } |
| 3763 | // further checks only if we have right structtype |
| 3764 | if (pnext_struct) { |
| 3765 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 3766 | skip |= LogError( |
| 3767 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236", |
| 3768 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 3769 | ".", |
| 3770 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3771 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3772 | if (pnext_struct->accelerationStructureCount == 0) { |
| 3773 | skip |= LogError(device, |
| 3774 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 3775 | "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3776 | } |
| 3777 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3778 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3779 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 3780 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 3781 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 3782 | skip |= LogError(device, |
| 3783 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580", |
| 3784 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 3785 | "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3786 | } |
| 3787 | } |
| 3788 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3789 | } |
| 3790 | } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3791 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3792 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 3793 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817", |
| 3794 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext" |
| 3795 | "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose " |
| 3796 | "accelerationStructureCount %d member equals descriptorCount %d.", |
| 3797 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 3798 | pDescriptorWrites[i].descriptorCount); |
| 3799 | } |
| 3800 | // further checks only if we have right structtype |
| 3801 | if (pnext_struct) { |
| 3802 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 3803 | skip |= LogError( |
| 3804 | device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747", |
| 3805 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 3806 | ".", |
| 3807 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3808 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3809 | if (pnext_struct->accelerationStructureCount == 0) { |
| 3810 | skip |= LogError(device, |
| 3811 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 3812 | "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3813 | } |
| 3814 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3815 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3816 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 3817 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 3818 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 3819 | skip |= LogError(device, |
| 3820 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749", |
| 3821 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 3822 | "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3823 | } |
| 3824 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3825 | } |
| 3826 | } |
| 3827 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3828 | } |
| 3829 | } |
| 3830 | return skip; |
| 3831 | } |
| 3832 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3833 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 3834 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3835 | uint32_t descriptorCopyCount, |
| 3836 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
| 3837 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites); |
| 3838 | } |
| 3839 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3840 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3841 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3842 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3843 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 3844 | } |
| 3845 | |
sfricke-samsung | 681ab7b | 2020-10-29 01:53:35 -0700 | [diff] [blame] | 3846 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
| 3847 | const VkAllocationCallbacks *pAllocator, |
| 3848 | VkRenderPass *pRenderPass) const { |
| 3849 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 3850 | } |
| 3851 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3852 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3853 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3854 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3855 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 3856 | } |
| 3857 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3858 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 3859 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3860 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3861 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3862 | |
| 3863 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3864 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3865 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3866 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 3867 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3868 | return skip; |
| 3869 | } |
| 3870 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3871 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3872 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3873 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3874 | |
| 3875 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 3876 | const char *cmd_name = "vkBeginCommandBuffer"; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3877 | bool cb_is_secondary; |
| 3878 | { |
| 3879 | auto lock = cb_read_lock(); |
| 3880 | cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end()); |
| 3881 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3882 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3883 | if (cb_is_secondary) { |
| 3884 | // Implicit VUs |
| 3885 | // validate only sType here; pointer has to be validated in core_validation |
| 3886 | const bool k_not_required = false; |
| 3887 | const char *k_no_vuid = nullptr; |
| 3888 | const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo; |
| 3889 | 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] | 3890 | info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid, |
| 3891 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3892 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3893 | if (info) { |
| 3894 | const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = { |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 3895 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT, |
| 3896 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV}; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3897 | skip |= validate_struct_pnext( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3898 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", |
| 3899 | info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info), |
| 3900 | allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion, |
| 3901 | "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3902 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3903 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3904 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3905 | // Explicit VUs |
| 3906 | if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3907 | skip |= LogError( |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3908 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
| 3909 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 3910 | cmd_name); |
| 3911 | } |
| 3912 | |
| 3913 | if (physical_device_features.inheritedQueries) { |
| 3914 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3915 | AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags, |
| 3916 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
| 3917 | } else { // !inheritedQueries |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3918 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3919 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3920 | } |
| 3921 | |
| 3922 | if (physical_device_features.pipelineStatisticsQuery) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3923 | skip |= |
| 3924 | validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
| 3925 | AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags, |
| 3926 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
| 3927 | } else { // !pipelineStatisticsQuery |
| 3928 | skip |= |
| 3929 | validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics, |
| 3930 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3931 | } |
| 3932 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3933 | const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3934 | if (conditional_rendering) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3935 | const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3936 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 3937 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
| 3938 | skip |= LogError( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 3939 | commandBuffer, |
| 3940 | "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3941 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 3942 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 3943 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 3944 | } |
ziga-lunarg | 9d01913 | 2021-07-19 01:05:31 +0200 | [diff] [blame] | 3945 | |
| 3946 | auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext); |
| 3947 | if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport && |
| 3948 | p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE && |
| 3949 | p_inherited_viewport_scissor_info->viewportDepthCount != 1) { |
| 3950 | skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783", |
| 3951 | "vkBeginCommandBuffer: multiViewport feature is disabled, but " |
| 3952 | "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in " |
| 3953 | "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1."); |
| 3954 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 3955 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3956 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3957 | return skip; |
| 3958 | } |
| 3959 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3960 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3961 | uint32_t viewportCount, const VkViewport *pViewports) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3962 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3963 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3964 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3965 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3966 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 3967 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 3968 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3969 | } |
| 3970 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3971 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 3972 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 3973 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3974 | } |
| 3975 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 3976 | 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] | 3977 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3978 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 3979 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3980 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3981 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3982 | } |
| 3983 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3984 | |
| 3985 | if (pViewports) { |
| 3986 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 3987 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 3988 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3989 | skip |= manual_PreCallValidateViewport( |
| 3990 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3991 | } |
| 3992 | } |
| 3993 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3994 | return skip; |
| 3995 | } |
| 3996 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3997 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3998 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3999 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4000 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4001 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4002 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4003 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 4004 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 4005 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4006 | } |
| 4007 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4008 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 4009 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 4010 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4011 | } |
| 4012 | } else { // multiViewport enabled |
| 4013 | 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] | 4014 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4015 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 4016 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4017 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4018 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4019 | } |
| 4020 | } |
| 4021 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4022 | if (pScissors) { |
| 4023 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 4024 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4025 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4026 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4027 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 4028 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 4029 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4030 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4031 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4032 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4033 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 4034 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 4035 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4036 | } |
| 4037 | |
| 4038 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 4039 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4040 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 4041 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4042 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4043 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4044 | } |
| 4045 | |
| 4046 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 4047 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4048 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 4049 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4050 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4051 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4052 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4053 | } |
| 4054 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 4055 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4056 | return skip; |
| 4057 | } |
| 4058 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4059 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4060 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4061 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4062 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4063 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 4064 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 4065 | } |
| 4066 | |
| 4067 | return skip; |
| 4068 | } |
| 4069 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4070 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4071 | uint32_t drawCount, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4072 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4073 | |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4074 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 41ce65b | 2020-10-30 12:17:06 -0600 | [diff] [blame] | 4075 | skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718", |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4076 | "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount); |
| 4077 | } |
| 4078 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 4079 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4080 | "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount, |
| 4081 | device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4082 | } |
| 4083 | return skip; |
| 4084 | } |
| 4085 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4086 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4087 | VkDeviceSize offset, uint32_t drawCount, |
| 4088 | uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4089 | bool skip = false; |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4090 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4091 | skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718", |
| 4092 | "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", |
| 4093 | drawCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4094 | } |
| 4095 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 4096 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4097 | "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", |
| 4098 | drawCount, device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4099 | } |
| 4100 | return skip; |
| 4101 | } |
| 4102 | |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4103 | bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 4104 | VkDeviceSize countBufferOffset, bool khr) const { |
| 4105 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4106 | const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4107 | if (offset & 3) { |
| 4108 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4109 | "%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] | 4110 | } |
| 4111 | |
| 4112 | if (countBufferOffset & 3) { |
| 4113 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4114 | "%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] | 4115 | countBufferOffset); |
| 4116 | } |
| 4117 | return skip; |
| 4118 | } |
| 4119 | |
| 4120 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4121 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4122 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 4123 | uint32_t stride) const { |
| 4124 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 4125 | } |
| 4126 | |
| 4127 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4128 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4129 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 4130 | uint32_t stride) const { |
| 4131 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 4132 | } |
| 4133 | |
| 4134 | bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 4135 | VkDeviceSize countBufferOffset, bool khr) const { |
| 4136 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4137 | const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 4138 | if (offset & 3) { |
| 4139 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4140 | "%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] | 4141 | } |
| 4142 | |
| 4143 | if (countBufferOffset & 3) { |
| 4144 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4145 | "%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] | 4146 | countBufferOffset); |
| 4147 | } |
| 4148 | return skip; |
| 4149 | } |
| 4150 | |
| 4151 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4152 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4153 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 4154 | uint32_t stride) const { |
| 4155 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 4156 | } |
| 4157 | |
| 4158 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4159 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4160 | VkDeviceSize countBufferOffset, |
| 4161 | uint32_t maxDrawCount, uint32_t stride) const { |
| 4162 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 4163 | } |
| 4164 | |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 4165 | bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 4166 | const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount, |
| 4167 | uint32_t firstInstance, uint32_t stride) const { |
| 4168 | bool skip = false; |
| 4169 | if (stride & 3) { |
| 4170 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936", |
| 4171 | "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride); |
| 4172 | } |
| 4173 | if (drawCount && nullptr == pVertexInfo) { |
| 4174 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935", |
| 4175 | "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing " |
| 4176 | "one or more valid instances of VkMultiDrawInfoEXT structures"); |
| 4177 | } |
| 4178 | return skip; |
| 4179 | } |
| 4180 | |
| 4181 | bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 4182 | const VkMultiDrawIndexedInfoEXT *pIndexInfo, |
| 4183 | uint32_t instanceCount, uint32_t firstInstance, |
| 4184 | uint32_t stride, const int32_t *pVertexOffset) const { |
| 4185 | bool skip = false; |
| 4186 | if (stride & 3) { |
| 4187 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941", |
| 4188 | "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride); |
| 4189 | } |
| 4190 | if (drawCount && nullptr == pIndexInfo) { |
| 4191 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940", |
| 4192 | "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to " |
| 4193 | "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures"); |
| 4194 | } |
| 4195 | return skip; |
| 4196 | } |
| 4197 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4198 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 4199 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4200 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4201 | bool skip = false; |
| 4202 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 4203 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4204 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
| 4205 | "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4206 | } |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 4207 | if (pRects[rect].rect.extent.width == 0) { |
| 4208 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682", |
| 4209 | "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect); |
| 4210 | } |
| 4211 | if (pRects[rect].rect.extent.height == 0) { |
| 4212 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683", |
| 4213 | "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect); |
| 4214 | } |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 4215 | } |
| 4216 | return skip; |
| 4217 | } |
| 4218 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4219 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 4220 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 4221 | VkImageFormatProperties2 *pImageFormatProperties, |
| 4222 | const char *apiName) const { |
| 4223 | bool skip = false; |
| 4224 | |
| 4225 | if (pImageFormatInfo != nullptr) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4226 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4227 | if (image_stencil_struct != nullptr) { |
| 4228 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 4229 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 4230 | // No flags other than the legal attachment bits may be set |
| 4231 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 4232 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4233 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 4234 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 4235 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 4236 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 4237 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4238 | } |
| 4239 | } |
| 4240 | } |
ziga-lunarg | d3da253 | 2021-08-11 11:50:12 +0200 | [diff] [blame] | 4241 | const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext); |
| 4242 | if (image_drm_format) { |
| 4243 | if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 4244 | skip |= LogError( |
| 4245 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", |
| 4246 | "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, " |
| 4247 | "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", |
| 4248 | apiName, string_VkImageTiling(pImageFormatInfo->tiling)); |
| 4249 | } |
| 4250 | } else { |
| 4251 | if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 4252 | skip |= LogError( |
| 4253 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", |
| 4254 | "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include " |
| 4255 | "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", |
| 4256 | apiName); |
| 4257 | } |
| 4258 | } |
| 4259 | if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT && |
| 4260 | (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) { |
| 4261 | const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext); |
| 4262 | if (!format_list || format_list->viewFormatCount == 0) { |
| 4263 | skip |= LogError( |
| 4264 | physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313", |
| 4265 | "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT " |
| 4266 | "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.", |
| 4267 | apiName); |
| 4268 | } |
| 4269 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 4270 | } |
| 4271 | |
| 4272 | return skip; |
| 4273 | } |
| 4274 | |
| 4275 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 4276 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 4277 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 4278 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 4279 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 4280 | } |
| 4281 | |
| 4282 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 4283 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 4284 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 4285 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 4286 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 4287 | } |
| 4288 | |
Lionel Landwerlin | 5fe5275 | 2020-07-22 08:18:14 +0300 | [diff] [blame] | 4289 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties( |
| 4290 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, |
| 4291 | VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const { |
| 4292 | bool skip = false; |
| 4293 | |
| 4294 | if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 4295 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248", |
| 4296 | "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT."); |
| 4297 | } |
| 4298 | |
| 4299 | return skip; |
| 4300 | } |
| 4301 | |
ziga-lunarg | 73b5ef2 | 2021-07-29 20:25:06 +0200 | [diff] [blame] | 4302 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR( |
| 4303 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo, |
| 4304 | uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const { |
| 4305 | bool skip = false; |
| 4306 | |
| 4307 | if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR | |
| 4308 | VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) { |
| 4309 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844", |
| 4310 | "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of " |
| 4311 | "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, " |
| 4312 | "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR."); |
| 4313 | } |
| 4314 | |
ziga-lunarg | 42f884b | 2021-08-25 16:13:20 +0200 | [diff] [blame] | 4315 | return skip; |
ziga-lunarg | 73b5ef2 | 2021-07-29 20:25:06 +0200 | [diff] [blame] | 4316 | } |
| 4317 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 4318 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 4319 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 4320 | bool skip = false; |
| 4321 | |
| 4322 | if (pRegions != nullptr) { |
| 4323 | for (uint32_t i = 0; i < regionCount; i++) { |
| 4324 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4325 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
| 4326 | "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 4327 | } |
| 4328 | } |
| 4329 | } |
| 4330 | return skip; |
| 4331 | } |
| 4332 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 4333 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, |
| 4334 | const VkCopyBufferInfo2KHR *pCopyBufferInfo) const { |
| 4335 | bool skip = false; |
| 4336 | |
| 4337 | if (pCopyBufferInfo->pRegions != nullptr) { |
| 4338 | for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) { |
| 4339 | if (pCopyBufferInfo->pRegions[i].size == 0) { |
| 4340 | skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988", |
| 4341 | "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i); |
| 4342 | } |
| 4343 | } |
| 4344 | } |
| 4345 | return skip; |
| 4346 | } |
| 4347 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4348 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4349 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 4350 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4351 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4352 | |
| 4353 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4354 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 4355 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 4356 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4357 | } |
| 4358 | |
| 4359 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4360 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 4361 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 4362 | "), must be greater than zero and less than or equal to 65536.", |
| 4363 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4364 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4365 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 4366 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 4367 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4368 | } |
| 4369 | return skip; |
| 4370 | } |
| 4371 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4372 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4373 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4374 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4375 | |
| 4376 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4377 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 4378 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 4379 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4380 | } |
| 4381 | |
| 4382 | if (size != VK_WHOLE_SIZE) { |
| 4383 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4384 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4385 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 4386 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4387 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4388 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 4389 | "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] | 4390 | } |
| 4391 | } |
| 4392 | return skip; |
| 4393 | } |
| 4394 | |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 4395 | bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4396 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4397 | |
| 4398 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4399 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4400 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 4401 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 4402 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4403 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 4404 | "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 4405 | "pCreateInfo->queueFamilyIndexCount must be greater than 1.", |
| 4406 | func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4407 | } |
| 4408 | |
| 4409 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 4410 | // queueFamilyIndexCount uint32_t values |
| 4411 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4412 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 4413 | "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4414 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 4415 | "pCreateInfo->queueFamilyIndexCount uint32_t values.", |
| 4416 | func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4417 | } |
| 4418 | } |
| 4419 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 4420 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 4421 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4422 | |
sfricke-samsung | a1d0027 | 2021-03-10 21:37:41 -0800 | [diff] [blame] | 4423 | // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo |
| 4424 | const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext); |
| 4425 | if (format_list_info) { |
| 4426 | const uint32_t viewFormatCount = format_list_info->viewFormatCount; |
| 4427 | if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) { |
| 4428 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100", |
| 4429 | "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then " |
| 4430 | "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.", |
| 4431 | func_name, viewFormatCount); |
| 4432 | } |
| 4433 | |
| 4434 | // Using the first format, compare the rest of the formats against it that they are compatible |
| 4435 | for (uint32_t i = 1; i < viewFormatCount; i++) { |
| 4436 | if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) != |
| 4437 | FormatCompatibilityClass(format_list_info->pViewFormats[i])) { |
| 4438 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099", |
| 4439 | "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and " |
| 4440 | "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.", |
| 4441 | func_name, string_VkFormat(format_list_info->pViewFormats[0]), i, |
| 4442 | string_VkFormat(format_list_info->pViewFormats[i])); |
| 4443 | } |
| 4444 | } |
| 4445 | } |
| 4446 | |
| 4447 | // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR |
| 4448 | if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) { |
| 4449 | if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) { |
| 4450 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 4451 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the " |
| 4452 | "VK_KHR_swapchain_mutable_format extension, which has not been enabled.", |
| 4453 | func_name); |
| 4454 | } else { |
| 4455 | if (format_list_info == nullptr) { |
| 4456 | skip |= LogError( |
| 4457 | device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 4458 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of " |
| 4459 | "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.", |
| 4460 | func_name); |
| 4461 | } else if (format_list_info->viewFormatCount == 0) { |
| 4462 | skip |= LogError( |
| 4463 | device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 4464 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount " |
| 4465 | "member of VkImageFormatListCreateInfo in the pNext chain is zero.", |
| 4466 | func_name); |
| 4467 | } else { |
| 4468 | bool found_base_format = false; |
| 4469 | for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) { |
| 4470 | if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) { |
| 4471 | found_base_format = true; |
| 4472 | break; |
| 4473 | } |
| 4474 | } |
| 4475 | if (!found_base_format) { |
| 4476 | skip |= |
| 4477 | LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168", |
| 4478 | "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the " |
| 4479 | "elements of the pViewFormats member of VkImageFormatListCreateInfo match " |
| 4480 | "pCreateInfo->imageFormat.", |
| 4481 | func_name); |
| 4482 | } |
| 4483 | } |
| 4484 | } |
| 4485 | } |
| 4486 | } |
| 4487 | return skip; |
| 4488 | } |
| 4489 | |
| 4490 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 4491 | const VkAllocationCallbacks *pAllocator, |
| 4492 | VkSwapchainKHR *pSwapchain) const { |
| 4493 | bool skip = false; |
| 4494 | skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo); |
| 4495 | return skip; |
| 4496 | } |
| 4497 | |
| 4498 | bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, |
| 4499 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 4500 | const VkAllocationCallbacks *pAllocator, |
| 4501 | VkSwapchainKHR *pSwapchains) const { |
| 4502 | bool skip = false; |
| 4503 | if (pCreateInfos) { |
| 4504 | for (uint32_t i = 0; i < swapchainCount; i++) { |
| 4505 | std::stringstream func_name; |
| 4506 | func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()"; |
| 4507 | skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]); |
| 4508 | } |
| 4509 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4510 | return skip; |
| 4511 | } |
| 4512 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4513 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4514 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4515 | |
| 4516 | if (pPresentInfo && pPresentInfo->pNext) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4517 | const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 4518 | if (present_regions) { |
| 4519 | // 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] | 4520 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 4521 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 4522 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
sfricke-samsung | a4cc4ff | 2020-08-23 22:05:49 -0700 | [diff] [blame] | 4523 | skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4524 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 4525 | "extension swapchainCount is %i. These values must be equal.", |
| 4526 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 4527 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4528 | 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] | 4529 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 4530 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4531 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 4532 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 4533 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 4534 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4535 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4536 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 4537 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4538 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4539 | } |
| 4540 | } |
| 4541 | |
| 4542 | return skip; |
| 4543 | } |
| 4544 | |
sfricke-samsung | 5c1b739 | 2020-12-13 22:17:15 -0800 | [diff] [blame] | 4545 | bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 4546 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 4547 | const VkAllocationCallbacks *pAllocator, |
| 4548 | VkDisplayModeKHR *pMode) const { |
| 4549 | bool skip = false; |
| 4550 | |
| 4551 | const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters; |
| 4552 | if (display_mode_parameters.visibleRegion.width == 0) { |
| 4553 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990", |
| 4554 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0."); |
| 4555 | } |
| 4556 | if (display_mode_parameters.visibleRegion.height == 0) { |
| 4557 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991", |
| 4558 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0."); |
| 4559 | } |
| 4560 | if (display_mode_parameters.refreshRate == 0) { |
| 4561 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992", |
| 4562 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0."); |
| 4563 | } |
| 4564 | |
| 4565 | return skip; |
| 4566 | } |
| 4567 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4568 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4569 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 4570 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 4571 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4572 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4573 | bool skip = false; |
| 4574 | |
| 4575 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4576 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 4577 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | return skip; |
| 4581 | } |
| 4582 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 4583 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4584 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4585 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4586 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 4587 | bool skip = false; |
| 4588 | |
| 4589 | if (pCreateInfo) { |
| 4590 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4591 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 4592 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 4593 | } |
| 4594 | |
| 4595 | if (pCreateInfo->pPoolSizes) { |
| 4596 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 4597 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4598 | skip |= LogError( |
| 4599 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4600 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 4601 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 4602 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 4603 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4604 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 4605 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 4606 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 4607 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 4608 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 4609 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 4610 | } |
| 4611 | } |
ziga-lunarg | 0cf8521 | 2021-07-19 01:26:17 +0200 | [diff] [blame] | 4612 | |
| 4613 | if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) && |
| 4614 | (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) { |
| 4615 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607", |
| 4616 | "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both " |
| 4617 | "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT"); |
| 4618 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 4619 | } |
| 4620 | |
| 4621 | return skip; |
| 4622 | } |
| 4623 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4624 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4625 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4626 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4627 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4628 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4629 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4630 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 4631 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 4632 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4633 | } |
| 4634 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4635 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4636 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4637 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 4638 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 4639 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4640 | } |
| 4641 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4642 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4643 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4644 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 4645 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 4646 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4647 | } |
| 4648 | |
| 4649 | return skip; |
| 4650 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4651 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4652 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4653 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 4654 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 4655 | |
| 4656 | if ((offset % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4657 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
| 4658 | "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 4659 | } |
| 4660 | return skip; |
| 4661 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4662 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4663 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 4664 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4665 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4666 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4667 | |
| 4668 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4669 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4670 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4671 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 4672 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 4673 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 4674 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4675 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4676 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 4677 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 4678 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 4679 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4680 | } |
| 4681 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4682 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4683 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4684 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 4685 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 4686 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 4687 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4688 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4689 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 4690 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 4691 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 4692 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4693 | } |
| 4694 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4695 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4696 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4697 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 4698 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 4699 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 4700 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4701 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4702 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 4703 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 4704 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 4705 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4706 | } |
| 4707 | |
| 4708 | return skip; |
| 4709 | } |
| 4710 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4711 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 4712 | VkPipelineBindPoint pipelineBindPoint, |
| 4713 | VkPipelineLayout layout, uint32_t set, |
| 4714 | uint32_t descriptorWriteCount, |
| 4715 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
| 4716 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false); |
| 4717 | } |
| 4718 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4719 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 4720 | uint32_t firstExclusiveScissor, |
| 4721 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4722 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4723 | bool skip = false; |
| 4724 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4725 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4726 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4727 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4728 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 4729 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 4730 | ") is not 0.", |
| 4731 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4732 | } |
| 4733 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4734 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4735 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 4736 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 4737 | ") is not 1.", |
| 4738 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4739 | } |
| 4740 | } else { // multiViewport enabled |
| 4741 | 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] | 4742 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4743 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 4744 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 4745 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4746 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4747 | } |
| 4748 | } |
| 4749 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4750 | if (pExclusiveScissors) { |
| 4751 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 4752 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 4753 | |
| 4754 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4755 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4756 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 4757 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4758 | } |
| 4759 | |
| 4760 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4761 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4762 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 4763 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4764 | } |
| 4765 | |
| 4766 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 4767 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4768 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 4769 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4770 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4771 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4772 | } |
| 4773 | |
| 4774 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 4775 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4776 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 4777 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4778 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4779 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4780 | } |
| 4781 | } |
| 4782 | } |
| 4783 | |
| 4784 | return skip; |
| 4785 | } |
| 4786 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4787 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 4788 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4789 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4790 | bool skip = false; |
Shannon McPherson | 169d0c7 | 2020-11-13 18:48:19 -0700 | [diff] [blame] | 4791 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 4792 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
| 4793 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 4794 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4795 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 4796 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4797 | } |
| 4798 | |
| 4799 | return skip; |
| 4800 | } |
| 4801 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4802 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 4803 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4804 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4805 | bool skip = false; |
| 4806 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4807 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4808 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4809 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4810 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 4811 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 4812 | ") is not 0.", |
| 4813 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4814 | } |
| 4815 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4816 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4817 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 4818 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 4819 | ") is not 1.", |
| 4820 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4821 | } |
| 4822 | } |
| 4823 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4824 | 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] | 4825 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4826 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 4827 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 4828 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4829 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4830 | } |
| 4831 | |
| 4832 | return skip; |
| 4833 | } |
| 4834 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4835 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 4836 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 4837 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4838 | bool skip = false; |
| 4839 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4840 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4841 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 4842 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 4843 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4844 | } |
| 4845 | |
| 4846 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4847 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4848 | } |
| 4849 | |
| 4850 | return skip; |
| 4851 | } |
| 4852 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4853 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4854 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4855 | bool skip = false; |
| 4856 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4857 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4858 | skip |= LogError( |
| 4859 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4860 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 4861 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4862 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4863 | } |
| 4864 | |
| 4865 | return skip; |
| 4866 | } |
| 4867 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4868 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4869 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4870 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4871 | bool skip = false; |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4872 | static const int condition_multiples = 0b0011; |
| 4873 | if (offset & condition_multiples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4874 | skip |= LogError( |
| 4875 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4876 | "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] | 4877 | } |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4878 | if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4879 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 4880 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 4881 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 4882 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4883 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4884 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4885 | skip |= LogError( |
| 4886 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
| 4887 | "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount); |
Jeff Bolz | b574c34 | 2018-11-08 15:36:57 -0600 | [diff] [blame] | 4888 | } |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4889 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 4890 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4891 | "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).", |
| 4892 | drawCount, device_limits.maxDrawIndirectCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4893 | } |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4894 | return skip; |
| 4895 | } |
| 4896 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4897 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4898 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4899 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4900 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4901 | bool skip = false; |
| 4902 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4903 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4904 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 4905 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 4906 | "), is not a multiple of 4.", |
| 4907 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4908 | } |
| 4909 | |
| 4910 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4911 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 4912 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 4913 | "), is not a multiple of 4.", |
| 4914 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4915 | } |
| 4916 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4917 | return skip; |
| 4918 | } |
| 4919 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4920 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4921 | const VkAllocationCallbacks *pAllocator, |
| 4922 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4923 | bool skip = false; |
| 4924 | |
| 4925 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4926 | if (pCreateInfo != nullptr) { |
| 4927 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 4928 | // VkQueryPipelineStatisticFlagBits values |
| 4929 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 4930 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4931 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 4932 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 4933 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 4934 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4935 | } |
sfricke-samsung | 7d69d0d | 2020-04-25 10:27:27 -0700 | [diff] [blame] | 4936 | if (pCreateInfo->queryCount == 0) { |
| 4937 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763", |
| 4938 | "vkCreateQueryPool(): queryCount must be greater than zero."); |
| 4939 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 4940 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4941 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4942 | } |
| 4943 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4944 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 4945 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4946 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4947 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 4948 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4949 | } |
| 4950 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4951 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4952 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4953 | VkResult result) { |
| 4954 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4955 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4956 | } |
| 4957 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4958 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4959 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4960 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4961 | // 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] | 4962 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4963 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4964 | } |
| 4965 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4966 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 4967 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4968 | // 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] | 4969 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4970 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4971 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4972 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4973 | void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4974 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4975 | if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) { |
| 4976 | auto lock = cb_write_lock(); |
| 4977 | for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) { |
Jeremy Gebben | fc6f815 | 2021-03-18 16:58:55 -0600 | [diff] [blame] | 4978 | secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4979 | } |
| 4980 | } |
| 4981 | } |
| 4982 | |
| 4983 | void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4984 | const VkCommandBuffer *pCommandBuffers) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4985 | auto lock = cb_write_lock(); |
| 4986 | for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) { |
| 4987 | secondary_cb_map.erase(pCommandBuffers[cb_index]); |
| 4988 | } |
| 4989 | } |
| 4990 | |
| 4991 | void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4992 | const VkAllocationCallbacks *pAllocator) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4993 | auto lock = cb_write_lock(); |
| 4994 | for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) { |
| 4995 | if (item->second == commandPool) { |
| 4996 | item = secondary_cb_map.erase(item); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 4997 | } else { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4998 | ++item; |
| 4999 | } |
| 5000 | } |
| 5001 | } |
| 5002 | |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5003 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5004 | const VkAllocationCallbacks *pAllocator, |
| 5005 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5006 | bool skip = false; |
| 5007 | |
| 5008 | if (pAllocateInfo) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5009 | auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5010 | 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] | 5011 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 5012 | "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] | 5013 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5014 | |
| 5015 | VkMemoryAllocateFlags flags = 0; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5016 | auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5017 | if (flags_info) { |
| 5018 | flags = flags_info->flags; |
| 5019 | } |
| 5020 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5021 | auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5022 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5023 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5024 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 5025 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5026 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5027 | } |
| 5028 | |
| 5029 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5030 | auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5031 | #endif |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5032 | auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 5033 | auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5034 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5035 | auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5036 | #endif |
| 5037 | |
| 5038 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5039 | skip |= LogError( |
| 5040 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5041 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 5042 | } |
| 5043 | if ( |
| 5044 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 5045 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 5046 | #endif |
| 5047 | (import_memory_fd && import_memory_fd->handleType) || |
| 5048 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 5049 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 5050 | #endif |
| 5051 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5052 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 5053 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5054 | } |
| 5055 | } |
| 5056 | |
ziga-lunarg | 1d5e11d | 2021-07-18 13:13:40 +0200 | [diff] [blame] | 5057 | auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext); |
| 5058 | if (export_memory) { |
| 5059 | auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext); |
| 5060 | if (export_memory_nv) { |
| 5061 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640", |
| 5062 | "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and " |
| 5063 | "VkExportMemoryAllocateInfoNV"); |
| 5064 | } |
| 5065 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 5066 | auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext); |
| 5067 | if (export_memory_win32_nv) { |
| 5068 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640", |
| 5069 | "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and " |
| 5070 | "VkExportMemoryWin32HandleInfoNV"); |
| 5071 | } |
| 5072 | #endif |
| 5073 | } |
| 5074 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5075 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 5076 | VkBool32 capture_replay = false; |
| 5077 | VkBool32 buffer_device_address = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5078 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 5079 | if (vulkan_12_features) { |
| 5080 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 5081 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 5082 | } else { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5083 | const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 5084 | if (bda_features) { |
| 5085 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 5086 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 5087 | } |
| 5088 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5089 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5090 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5091 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5092 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 5093 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5094 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5095 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5096 | "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] | 5097 | } |
| 5098 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 5099 | } |
| 5100 | return skip; |
| 5101 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5102 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5103 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5104 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5105 | bool skip = false; |
| 5106 | |
| 5107 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 5108 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 5109 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5110 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5111 | } else { |
| 5112 | uint32_t vertex_component_size = 0; |
| 5113 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 5114 | vertex_component_size = 4; |
| 5115 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 5116 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 5117 | vertex_component_size = 2; |
| 5118 | } |
| 5119 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5120 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5121 | } |
| 5122 | } |
| 5123 | |
| 5124 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 5125 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5126 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5127 | } else { |
| 5128 | uint32_t index_element_size = 0; |
| 5129 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 5130 | index_element_size = 4; |
| 5131 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 5132 | index_element_size = 2; |
| 5133 | } |
| 5134 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5135 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5136 | } |
| 5137 | } |
| 5138 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 5139 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5140 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5141 | } |
| 5142 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5143 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5144 | } |
| 5145 | } |
| 5146 | |
| 5147 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5148 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5149 | } |
| 5150 | |
| 5151 | return skip; |
| 5152 | } |
| 5153 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5154 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 5155 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5156 | bool skip = false; |
| 5157 | |
| 5158 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5159 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5160 | } |
| 5161 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5162 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5163 | } |
| 5164 | |
| 5165 | return skip; |
| 5166 | } |
| 5167 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5168 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 5169 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5170 | bool skip = false; |
| 5171 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5172 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5173 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5174 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5175 | } |
| 5176 | return skip; |
| 5177 | } |
| 5178 | |
| 5179 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5180 | VkAccelerationStructureNV object_handle, const char *func_name, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5181 | bool is_cmd) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5182 | bool skip = false; |
| 5183 | 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] | 5184 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 5185 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 5186 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5187 | } |
| 5188 | 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] | 5189 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 5190 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 5191 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5192 | } |
ziga-lunarg | 10309ee | 2021-08-02 13:11:21 +0200 | [diff] [blame] | 5193 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 5194 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623", |
| 5195 | "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR."); |
| 5196 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5197 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 5198 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5199 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 5200 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 5201 | "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] | 5202 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5203 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5204 | skip |= LogError(object_handle, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5205 | is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241" |
| 5206 | : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5207 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 5208 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5209 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5210 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5211 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 5212 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 5213 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5214 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 5215 | 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] | 5216 | uint64_t total_triangle_count = 0; |
| 5217 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 5218 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5219 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5220 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 5221 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5222 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 5223 | continue; |
| 5224 | } |
| 5225 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 5226 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5227 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5228 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 5229 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 5230 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5231 | } |
| 5232 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 5233 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 5234 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 5235 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 5236 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 5237 | if (geometry.geometryType != first_geometry_type) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5238 | skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5239 | "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match " |
| 5240 | "info.pGeometries[0].geometryType.", |
| 5241 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 5242 | } |
| 5243 | } |
| 5244 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5245 | for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) { |
| 5246 | if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV || |
| 5247 | info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) { |
| 5248 | skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503", |
| 5249 | "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV" |
| 5250 | "or VK_GEOMETRY_TYPE_AABBS_NV."); |
| 5251 | } |
| 5252 | } |
| 5253 | skip |= |
| 5254 | validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV, |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 5255 | info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5256 | return skip; |
| 5257 | } |
| 5258 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5259 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 5260 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5261 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5262 | bool skip = false; |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5263 | if (pCreateInfo) { |
| 5264 | if ((pCreateInfo->compactedSize != 0) && |
| 5265 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5266 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 5267 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 5268 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 5269 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5270 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5271 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5272 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5273 | "vkCreateAccelerationStructureNV()", false); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5274 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 5275 | return skip; |
| 5276 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5277 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5278 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 5279 | const VkAccelerationStructureInfoNV *pInfo, |
| 5280 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 5281 | VkBool32 update, VkAccelerationStructureNV dst, |
| 5282 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 5283 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5284 | bool skip = false; |
| 5285 | |
| 5286 | if (pInfo != nullptr) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5287 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5288 | } |
| 5289 | |
| 5290 | return skip; |
| 5291 | } |
| 5292 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5293 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR( |
| 5294 | VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 5295 | VkAccelerationStructureKHR *pAccelerationStructure) const { |
| 5296 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5297 | const auto *acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5298 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5299 | if (!acceleration_structure_features || |
| 5300 | (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) { |
| 5301 | skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611", |
| 5302 | "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled"); |
| 5303 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5304 | if (pCreateInfo) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5305 | if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR && |
| 5306 | (!acceleration_structure_features || |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5307 | (acceleration_structure_features && |
| 5308 | acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5309 | skip |= |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5310 | LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613", |
| 5311 | "vkCreateAccelerationStructureKHR(): If createFlags includes " |
| 5312 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, " |
| 5313 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5314 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5315 | if (pCreateInfo->deviceAddress && |
| 5316 | !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
| 5317 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612", |
| 5318 | "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include " |
| 5319 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR"); |
| 5320 | } |
ziga-lunarg | 8ddbe46 | 2021-09-06 16:14:17 +0200 | [diff] [blame] | 5321 | if (pCreateInfo->deviceAddress && (!acceleration_structure_features || |
| 5322 | (acceleration_structure_features && |
| 5323 | acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
| 5324 | skip |= LogError( |
| 5325 | device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488", |
| 5326 | "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but " |
| 5327 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled."); |
| 5328 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5329 | if (SafeModulo(pCreateInfo->offset, 256) != 0) { |
| 5330 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734", |
ziga-lunarg | 8ddbe46 | 2021-09-06 16:14:17 +0200 | [diff] [blame] | 5331 | "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", |
| 5332 | pCreateInfo->offset); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5333 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5334 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5335 | return skip; |
| 5336 | } |
| 5337 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5338 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 5339 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5340 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5341 | bool skip = false; |
| 5342 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5343 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 5344 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 5345 | } |
| 5346 | return skip; |
| 5347 | } |
| 5348 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5349 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV( |
| 5350 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures, |
| 5351 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 5352 | bool skip = false; |
Mark Lobodzinski | c0df6b6 | 2021-01-08 12:34:11 -0700 | [diff] [blame] | 5353 | if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 5354 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5355 | "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be " |
Mark Lobodzinski | c0df6b6 | 2021-01-08 12:34:11 -0700 | [diff] [blame] | 5356 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5357 | } |
| 5358 | return skip; |
| 5359 | } |
| 5360 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 5361 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 5362 | uint32_t createInfoCount, |
| 5363 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 5364 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5365 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 5366 | bool skip = false; |
| 5367 | |
| 5368 | for (uint32_t i = 0; i < createInfoCount; i++) { |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 5369 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 5370 | std::stringstream msg; |
| 5371 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 5372 | ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]); |
| 5373 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5374 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 5375 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5376 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5377 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 5378 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 5379 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 5380 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 5381 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5382 | |
| 5383 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5384 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5385 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 5386 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 5387 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 5388 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905", |
| 5389 | "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled," |
| 5390 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 5391 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 5392 | } |
| 5393 | } |
| 5394 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5395 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 5396 | skip |= |
| 5397 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904", |
| 5398 | "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 5399 | } |
| 5400 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) && |
| 5401 | (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) { |
| 5402 | skip |= |
| 5403 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957", |
| 5404 | "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and" |
| 5405 | "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time."); |
| 5406 | } |
| 5407 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 5408 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 5409 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 5410 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423", |
| 5411 | "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be " |
| 5412 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 5413 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 5414 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5415 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5416 | skip |= |
| 5417 | LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415", |
| 5418 | "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the" |
| 5419 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element" |
| 5420 | "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to " |
| 5421 | "that element."); |
| 5422 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5423 | } |
| 5424 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 5425 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5426 | skip |= |
| 5427 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422", |
| 5428 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 5429 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling" |
| 5430 | "commands pCreateInfos parameter."); |
| 5431 | } |
| 5432 | } else { |
| 5433 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 5434 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424", |
| 5435 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 5436 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 5437 | } |
| 5438 | } |
| 5439 | } |
| 5440 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 5441 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456", |
| 5442 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR."); |
| 5443 | } |
| 5444 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) { |
| 5445 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458", |
| 5446 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 5447 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR."); |
| 5448 | } |
| 5449 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) { |
| 5450 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459", |
| 5451 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 5452 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR."); |
| 5453 | } |
| 5454 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) { |
| 5455 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460", |
| 5456 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 5457 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR."); |
| 5458 | } |
| 5459 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) { |
| 5460 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461", |
| 5461 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 5462 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR."); |
| 5463 | } |
| 5464 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 5465 | skip |= LogError( |
| 5466 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462", |
| 5467 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 5468 | } |
| 5469 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 5470 | skip |= LogError( |
| 5471 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463", |
| 5472 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 5473 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5474 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) { |
| 5475 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588", |
| 5476 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 5477 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 5478 | } |
| 5479 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 5480 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816", |
| 5481 | "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
| 5482 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 5483 | } |
| 5484 | |
| 5485 | return skip; |
| 5486 | } |
| 5487 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5488 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR( |
| 5489 | VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 5490 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5491 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5492 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5493 | if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) { |
| 5494 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586", |
| 5495 | "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5496 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5497 | for (uint32_t i = 0; i < createInfoCount; i++) { |
ziga-lunarg | c634137 | 2021-07-28 12:57:42 +0200 | [diff] [blame] | 5498 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 5499 | std::stringstream msg; |
| 5500 | msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]"; |
| 5501 | ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(), |
| 5502 | &pCreateInfos[i].pStages[i]); |
| 5503 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5504 | if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) { |
| 5505 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 5506 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596", |
| 5507 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 5508 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 5509 | } |
| 5510 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 5511 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597", |
| 5512 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 5513 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR."); |
| 5514 | } |
| 5515 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5516 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5517 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
| 5518 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5519 | "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32 |
| 5520 | "], When chained to VkRayTracingPipelineCreateInfoKHR, " |
| 5521 | "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5522 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").", |
| 5523 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
| 5524 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5525 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5526 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5527 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 5528 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 5529 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 5530 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5531 | "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled," |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5532 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 5533 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 5534 | } |
| 5535 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5536 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5537 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904", |
| 5538 | "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5539 | } |
| 5540 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5541 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5542 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5543 | "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, " |
| 5544 | "pLibraryInterface must not be NULL."); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5545 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5546 | } |
| 5547 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 5548 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816", |
| 5549 | "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5550 | } |
| 5551 | for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) { |
| 5552 | if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) || |
| 5553 | (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) { |
| 5554 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) && |
| 5555 | (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) { |
| 5556 | skip |= LogError( |
| 5557 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5558 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 5559 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5560 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 5561 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element " |
| 5562 | "must not be VK_SHADER_UNUSED_KHR"); |
| 5563 | } |
| 5564 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) && |
| 5565 | (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) { |
| 5566 | skip |= LogError( |
| 5567 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5568 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 5569 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5570 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 5571 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that " |
| 5572 | "element must not be VK_SHADER_UNUSED_KHR"); |
| 5573 | } |
| 5574 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5575 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE && |
| 5576 | pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) { |
| 5577 | if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) { |
| 5578 | skip |= LogError( |
| 5579 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599", |
| 5580 | "vkCreateRayTracingPipelinesKHR: If " |
| 5581 | "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is " |
| 5582 | "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must " |
| 5583 | "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 5584 | } |
| 5585 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5586 | } |
| 5587 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 5588 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 5589 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 5590 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5591 | "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be " |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5592 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 5593 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 5594 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5595 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5596 | skip |= |
| 5597 | LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415", |
| 5598 | "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the" |
| 5599 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is" |
| 5600 | "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that " |
| 5601 | "element."); |
| 5602 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5603 | } |
| 5604 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 5605 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5606 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5607 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5608 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling" |
| 5609 | "commands pCreateInfos parameter %d.", |
| 5610 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 5611 | } |
| 5612 | } else { |
| 5613 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 5614 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5615 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 5616 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 5617 | } |
| 5618 | } |
| 5619 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5620 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR && |
| 5621 | (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) { |
| 5622 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598", |
| 5623 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 5624 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, " |
| 5625 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled."); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5626 | } |
| 5627 | bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library); |
| 5628 | if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) { |
| 5629 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595", |
| 5630 | "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, " |
| 5631 | "pLibraryInfo and pLibraryInterface must be NULL."); |
| 5632 | } |
| 5633 | if (pCreateInfos[i].pLibraryInfo) { |
| 5634 | if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) { |
| 5635 | if (pCreateInfos[i].stageCount == 0) { |
| 5636 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600", |
| 5637 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 5638 | "stageCount must not be 0."); |
| 5639 | } |
| 5640 | if (pCreateInfos[i].groupCount == 0) { |
| 5641 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601", |
| 5642 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 5643 | "groupCount must not be 0."); |
| 5644 | } |
| 5645 | } else { |
| 5646 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
| 5647 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590", |
| 5648 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member " |
| 5649 | "is greater than 0, its " |
| 5650 | "pLibraryInterface member must not be NULL."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5651 | } |
| 5652 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5653 | } |
| 5654 | if (pCreateInfos[i].pLibraryInterface) { |
| 5655 | if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize > |
| 5656 | phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) { |
| 5657 | skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605", |
| 5658 | "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to " |
| 5659 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize."); |
| 5660 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5661 | } |
| 5662 | if (deferredOperation != VK_NULL_HANDLE) { |
| 5663 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) { |
| 5664 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587", |
| 5665 | "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of " |
| 5666 | "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] | 5667 | } |
| 5668 | } |
ziga-lunarg | dea7658 | 2021-09-17 14:38:08 +0200 | [diff] [blame] | 5669 | if (pCreateInfos[i].pDynamicState) { |
| 5670 | for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) { |
| 5671 | if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) { |
| 5672 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602", |
| 5673 | "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32 |
| 5674 | "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.", |
| 5675 | i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j])); |
| 5676 | } |
| 5677 | } |
| 5678 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 5679 | } |
| 5680 | |
| 5681 | return skip; |
| 5682 | } |
| 5683 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5684 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 5685 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 5686 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5687 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5688 | bool skip = false; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 5689 | if (!IsExtEnabled(device_extensions.vk_khr_swapchain)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5690 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 5691 | if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5692 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 5693 | if (!IsExtEnabled(device_extensions.vk_khr_surface)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5694 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 5695 | if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5696 | skip |= |
| 5697 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 5698 | if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive)) |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5699 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 5700 | skip |= validate_struct_type( |
| 5701 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 5702 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 5703 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 5704 | if (pSurfaceInfo != NULL) { |
| 5705 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 5706 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 5707 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 5708 | |
| 5709 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 5710 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 5711 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 5712 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 5713 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 5714 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 5715 | |
| 5716 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 5717 | } |
| 5718 | return skip; |
| 5719 | } |
| 5720 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 5721 | |
| 5722 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 5723 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5724 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 5725 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 5726 | bool skip = false; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 5727 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 5728 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 5729 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 5730 | } |
| 5731 | return skip; |
| 5732 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 5733 | |
| 5734 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5735 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 5736 | bool skip = false; |
| 5737 | |
| 5738 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5739 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
| 5740 | "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 5741 | } |
| 5742 | |
| 5743 | return skip; |
| 5744 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5745 | |
| 5746 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5747 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5748 | bool skip = false; |
| 5749 | |
| 5750 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5751 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 5752 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5753 | } |
| 5754 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5755 | const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext); |
Mark Lobodzinski | 804fde8 | 2020-05-08 07:49:25 -0600 | [diff] [blame] | 5756 | 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] | 5757 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 5758 | "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] | 5759 | } |
| 5760 | |
| 5761 | return skip; |
| 5762 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5763 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 5764 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 5765 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 5766 | const VkDeviceSize *pOffsets) const { |
| 5767 | bool skip = false; |
| 5768 | if (firstBinding > device_limits.maxVertexInputBindings) { |
| 5769 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 5770 | "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding, |
| 5771 | device_limits.maxVertexInputBindings); |
| 5772 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 5773 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
| 5774 | "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 5775 | "maxVertexInputBindings (%u)", |
| 5776 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 5777 | } |
| 5778 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 5779 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5780 | if (pBuffers[i] == VK_NULL_HANDLE) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5781 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 5782 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 5783 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001", |
| 5784 | "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 5785 | } else { |
| 5786 | if (pOffsets[i] != 0) { |
| 5787 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002", |
| 5788 | "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 5789 | } |
| 5790 | } |
| 5791 | } |
| 5792 | } |
| 5793 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 5794 | return skip; |
| 5795 | } |
| 5796 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5797 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5798 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5799 | bool skip = false; |
| 5800 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5801 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 5802 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5803 | } |
| 5804 | return skip; |
| 5805 | } |
| 5806 | |
| 5807 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5808 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5809 | bool skip = false; |
| 5810 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5811 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 5812 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5813 | } |
| 5814 | return skip; |
| 5815 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5816 | |
| 5817 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 5818 | VkSemaphore semaphore, VkFence fence, |
| 5819 | uint32_t *pImageIndex) const { |
| 5820 | bool skip = false; |
| 5821 | |
| 5822 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5823 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 5824 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5825 | } |
| 5826 | |
| 5827 | return skip; |
| 5828 | } |
| 5829 | |
| 5830 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 5831 | uint32_t *pImageIndex) const { |
| 5832 | bool skip = false; |
| 5833 | |
| 5834 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5835 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 5836 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5837 | } |
| 5838 | |
| 5839 | return skip; |
| 5840 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5841 | |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 5842 | bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, |
| 5843 | uint32_t firstBinding, uint32_t bindingCount, |
| 5844 | const VkBuffer *pBuffers, |
| 5845 | const VkDeviceSize *pOffsets, |
| 5846 | const VkDeviceSize *pSizes) const { |
| 5847 | bool skip = false; |
| 5848 | |
| 5849 | char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT"; |
| 5850 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5851 | if (pOffsets[i] & 3) { |
| 5852 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359", |
| 5853 | "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]); |
| 5854 | } |
| 5855 | } |
| 5856 | |
| 5857 | if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5858 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356", |
| 5859 | "%s: The firstBinding(%" PRIu32 |
| 5860 | ") index is greater than or equal to " |
| 5861 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5862 | cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5863 | } |
| 5864 | |
| 5865 | if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5866 | skip |= |
| 5867 | LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357", |
| 5868 | "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32 |
| 5869 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5870 | cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5871 | } |
| 5872 | |
| 5873 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5874 | // pSizes is optional and may be nullptr. |
| 5875 | if (pSizes != nullptr) { |
| 5876 | if (pSizes[i] != VK_WHOLE_SIZE && |
| 5877 | pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) { |
| 5878 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361", |
| 5879 | "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64 |
| 5880 | ") is not VK_WHOLE_SIZE and is greater than " |
| 5881 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.", |
| 5882 | cmd_name, i, pSizes[i]); |
| 5883 | } |
| 5884 | } |
| 5885 | } |
| 5886 | |
| 5887 | return skip; |
| 5888 | } |
| 5889 | |
| 5890 | bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5891 | uint32_t firstCounterBuffer, |
| 5892 | uint32_t counterBufferCount, |
| 5893 | const VkBuffer *pCounterBuffers, |
| 5894 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5895 | bool skip = false; |
| 5896 | |
| 5897 | char const *const cmd_name = "CmdBeginTransformFeedbackEXT"; |
| 5898 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5899 | skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368", |
| 5900 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5901 | ") index is greater than or equal to " |
| 5902 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5903 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5904 | } |
| 5905 | |
| 5906 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5907 | skip |= |
| 5908 | LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369", |
| 5909 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5910 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5911 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5912 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5913 | } |
| 5914 | |
| 5915 | return skip; |
| 5916 | } |
| 5917 | |
| 5918 | bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5919 | uint32_t firstCounterBuffer, uint32_t counterBufferCount, |
| 5920 | const VkBuffer *pCounterBuffers, |
| 5921 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5922 | bool skip = false; |
| 5923 | |
| 5924 | char const *const cmd_name = "CmdEndTransformFeedbackEXT"; |
| 5925 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5926 | skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376", |
| 5927 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5928 | ") index is greater than or equal to " |
| 5929 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5930 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5931 | } |
| 5932 | |
| 5933 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5934 | skip |= |
| 5935 | LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377", |
| 5936 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5937 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5938 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5939 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5940 | } |
| 5941 | |
| 5942 | return skip; |
| 5943 | } |
| 5944 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5945 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 5946 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 5947 | VkDeviceSize counterBufferOffset, |
| 5948 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 5949 | bool skip = false; |
| 5950 | |
| 5951 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5952 | skip |= LogError( |
| 5953 | counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5954 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).", |
| 5955 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
| 5956 | } |
| 5957 | |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5958 | if ((counterOffset % 4) != 0) { |
sfricke-samsung | 6886c4b | 2021-01-16 08:37:35 -0800 | [diff] [blame] | 5959 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 5960 | "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset); |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5961 | } |
| 5962 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5963 | return skip; |
| 5964 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5965 | |
| 5966 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 5967 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 5968 | const VkAllocationCallbacks *pAllocator, |
| 5969 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 5970 | const char *apiName) const { |
| 5971 | bool skip = false; |
| 5972 | |
| 5973 | // Check samplerYcbcrConversion feature is set |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5974 | const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5975 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5976 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5977 | if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) { |
| 5978 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5979 | "%s: samplerYcbcrConversion must be enabled.", apiName); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5980 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5981 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5982 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5983 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 5984 | const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5985 | 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] | 5986 | #else |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5987 | const bool is_external_format = false; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5988 | #endif |
| 5989 | |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5990 | const VkFormat format = pCreateInfo->format; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5991 | |
| 5992 | // 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] | 5993 | if (!is_external_format) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5994 | const VkComponentMapping components = pCreateInfo->components; |
| 5995 | // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec |
| 5996 | if (FormatIsXChromaSubsampled(format) == true) { |
| 5997 | if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) { |
| 5998 | skip |= |
| 5999 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6000 | "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G " |
| 6001 | "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6002 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6003 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6004 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6005 | if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 6006 | (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) { |
| 6007 | skip |= LogError( |
| 6008 | device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582", |
| 6009 | "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or " |
| 6010 | "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.", |
| 6011 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a)); |
| 6012 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6013 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6014 | if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 6015 | (components.r != VK_COMPONENT_SWIZZLE_B)) { |
| 6016 | skip |= |
| 6017 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6018 | "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R " |
| 6019 | "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] | 6020 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6021 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6022 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6023 | if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 6024 | (components.b != VK_COMPONENT_SWIZZLE_R)) { |
| 6025 | skip |= |
| 6026 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6027 | "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B " |
| 6028 | "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] | 6029 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6030 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6031 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6032 | // If one is identity, both need to be |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6033 | const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 6034 | const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 6035 | if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6036 | skip |= |
| 6037 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6038 | "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) " |
| 6039 | "are an identity swizzle, then both need to be an identity swizzle.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6040 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r), |
| 6041 | string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6042 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6043 | } |
| 6044 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6045 | if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) { |
| 6046 | // Checks same VU multiple ways in order to give a more useful error message |
| 6047 | const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655"; |
| 6048 | if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) || |
| 6049 | (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) || |
| 6050 | (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) { |
| 6051 | skip |= LogError( |
| 6052 | device, vuid, |
| 6053 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6054 | "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.", |
| 6055 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6056 | string_VkComponentSwizzle(components.b)); |
| 6057 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 6058 | |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6059 | // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA" |
| 6060 | // 4 component format = no issue |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6061 | // 3 = no [a] |
| 6062 | // 2 = no [b,a] |
| 6063 | // 1 = no [g,b,a] |
| 6064 | // 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] | 6065 | const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6066 | |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6067 | if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) || |
| 6068 | (components.b == VK_COMPONENT_SWIZZLE_A))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6069 | skip |= LogError(device, vuid, |
| 6070 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6071 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.", |
| 6072 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6073 | string_VkComponentSwizzle(components.b)); |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6074 | } else if ((component_count < 3) && |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6075 | ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) || |
| 6076 | (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) { |
| 6077 | skip |= LogError(device, vuid, |
| 6078 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6079 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B " |
| 6080 | "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 6081 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6082 | string_VkComponentSwizzle(components.b)); |
sfricke-samsung | ed028b0 | 2021-09-06 23:14:51 -0700 | [diff] [blame] | 6083 | } else if ((component_count < 2) && |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 6084 | ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) || |
| 6085 | (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) { |
| 6086 | skip |= LogError(device, vuid, |
| 6087 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 6088 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G " |
| 6089 | "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 6090 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 6091 | string_VkComponentSwizzle(components.b)); |
| 6092 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 6093 | } |
| 6094 | } |
| 6095 | |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 6096 | return skip; |
| 6097 | } |
| 6098 | |
| 6099 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 6100 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 6101 | const VkAllocationCallbacks *pAllocator, |
| 6102 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 6103 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 6104 | "vkCreateSamplerYcbcrConversion"); |
| 6105 | } |
| 6106 | |
| 6107 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 6108 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 6109 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 6110 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 6111 | "vkCreateSamplerYcbcrConversionKHR"); |
| 6112 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 6113 | |
| 6114 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR( |
| 6115 | VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const { |
| 6116 | bool skip = false; |
| 6117 | VkExternalSemaphoreHandleTypeFlags supported_handle_types = |
| 6118 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 6119 | |
| 6120 | if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 6121 | skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", |
| 6122 | "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).", |
| 6123 | report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(), |
| 6124 | string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType), |
| 6125 | string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 6126 | } |
| 6127 | return skip; |
| 6128 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6129 | |
| 6130 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6131 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6132 | bool skip = false; |
| 6133 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 6134 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 6135 | "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 6136 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6137 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6138 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 6139 | skip |= LogError( |
| 6140 | device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584", |
| 6141 | "vkCopyAccelerationStructureToMemoryKHR: The " |
| 6142 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 6143 | } |
| 6144 | skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress, |
| 6145 | "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732"); |
| 6146 | if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) { |
| 6147 | skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751", |
| 6148 | "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes."); |
| 6149 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6150 | return skip; |
| 6151 | } |
| 6152 | |
| 6153 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR( |
| 6154 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 6155 | bool skip = false; |
| 6156 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 6157 | skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update |
| 6158 | LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 6159 | "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 6160 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6161 | if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) { |
| 6162 | skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 6163 | "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6164 | pInfo->dst.deviceAddress); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6165 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6166 | return skip; |
| 6167 | } |
| 6168 | |
| 6169 | bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 6170 | const char *api_name) const { |
| 6171 | bool skip = false; |
| 6172 | if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR || |
| 6173 | pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) { |
| 6174 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410", |
| 6175 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR" |
| 6176 | "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.", |
| 6177 | api_name); |
| 6178 | } |
| 6179 | return skip; |
| 6180 | } |
| 6181 | |
| 6182 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6183 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6184 | bool skip = false; |
| 6185 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()"); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6186 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6187 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6188 | skip |= LogError( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6189 | device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582", |
| 6190 | "vkCopyAccelerationStructureKHR: The " |
| 6191 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6192 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6193 | return skip; |
| 6194 | } |
| 6195 | |
| 6196 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR( |
| 6197 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 6198 | bool skip = false; |
| 6199 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()"); |
| 6200 | return skip; |
| 6201 | } |
| 6202 | |
| 6203 | bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 6204 | const char *api_name, bool is_cmd) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6205 | bool skip = false; |
| 6206 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6207 | skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413", |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6208 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name); |
| 6209 | } |
| 6210 | return skip; |
| 6211 | } |
| 6212 | |
| 6213 | bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6214 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6215 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6216 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6217 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6218 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 6219 | skip |= LogError( |
| 6220 | device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583", |
| 6221 | "vkCopyMemoryToAccelerationStructureKHR: The " |
| 6222 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6223 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6224 | skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress, |
| 6225 | "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6226 | return skip; |
| 6227 | } |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 6228 | |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 6229 | bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR( |
| 6230 | VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 6231 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6232 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6233 | if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) { |
| 6234 | skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 6235 | "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6236 | pInfo->src.deviceAddress); |
| 6237 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6238 | return skip; |
| 6239 | } |
| 6240 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR( |
| 6241 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 6242 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 6243 | bool skip = false; |
| 6244 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 6245 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 6246 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 6247 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 6248 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 6249 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 6250 | } |
| 6251 | return skip; |
| 6252 | } |
| 6253 | bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR( |
| 6254 | VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 6255 | VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const { |
| 6256 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6257 | const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6258 | if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 6259 | skip |= LogError( |
| 6260 | device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585", |
| 6261 | "vkCmdWriteAccelerationStructuresPropertiesKHR: The " |
| 6262 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 6263 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6264 | if (dataSize < accelerationStructureCount * stride) { |
| 6265 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452", |
| 6266 | "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to " |
| 6267 | "accelerationStructureCount (%d) *stride(%zu).", |
| 6268 | dataSize, accelerationStructureCount, stride); |
| 6269 | } |
| 6270 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 6271 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 6272 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 6273 | "vkWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 6274 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 6275 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 6276 | } |
| 6277 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) { |
| 6278 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 6279 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448", |
| 6280 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 6281 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR," |
| 6282 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 6283 | stride); |
| 6284 | } |
| 6285 | } |
| 6286 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) { |
| 6287 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 6288 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450", |
| 6289 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 6290 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR," |
| 6291 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 6292 | stride); |
| 6293 | } |
| 6294 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6295 | return skip; |
| 6296 | } |
| 6297 | bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR( |
| 6298 | VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const { |
| 6299 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6300 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6301 | if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) { |
| 6302 | skip |= LogError( |
| 6303 | device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606", |
| 6304 | "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::" |
| 6305 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6306 | } |
| 6307 | return skip; |
| 6308 | } |
| 6309 | |
| 6310 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6311 | const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 6312 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, |
| 6313 | const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 6314 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6315 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 6316 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6317 | // RayGen |
| 6318 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 6319 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023", |
| 6320 | "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] | 6321 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6322 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 6323 | 0) { |
| 6324 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682", |
| 6325 | "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 6326 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 6327 | } |
| 6328 | // Callable |
| 6329 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 6330 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694", |
| 6331 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 6332 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6333 | } |
| 6334 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 6335 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041", |
| 6336 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6337 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 6338 | } |
| 6339 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 6340 | 0) { |
| 6341 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693", |
| 6342 | "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 6343 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6344 | } |
| 6345 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6346 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 6347 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690", |
| 6348 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 6349 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6350 | } |
| 6351 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 6352 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6353 | "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to " |
| 6354 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6355 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6356 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 6357 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689", |
| 6358 | "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 6359 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 6360 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6361 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6362 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 6363 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686", |
| 6364 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of " |
| 6365 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6366 | } |
| 6367 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 6368 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029", |
| 6369 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6370 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 6371 | } |
| 6372 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 6373 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685", |
| 6374 | "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 6375 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 6376 | } |
| 6377 | if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) { |
| 6378 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629", |
| 6379 | "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to " |
| 6380 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount"); |
| 6381 | } |
| 6382 | if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) { |
| 6383 | skip |= |
| 6384 | LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626", |
| 6385 | "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] " |
| 6386 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6387 | } |
| 6388 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6389 | if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) { |
| 6390 | skip |= |
| 6391 | LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627", |
| 6392 | "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] " |
| 6393 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]"); |
| 6394 | } |
| 6395 | |
| 6396 | if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) { |
| 6397 | skip |= |
| 6398 | LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628", |
| 6399 | "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] " |
| 6400 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6401 | } |
| 6402 | return skip; |
| 6403 | } |
| 6404 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6405 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR( |
| 6406 | VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 6407 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 6408 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6409 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6410 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6411 | if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) { |
| 6412 | skip |= LogError( |
| 6413 | device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637", |
| 6414 | "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect " |
| 6415 | "feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6416 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6417 | // RayGen |
| 6418 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 6419 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023", |
| 6420 | "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] | 6421 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6422 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 6423 | 0) { |
| 6424 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682", |
| 6425 | "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 6426 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 6427 | } |
| 6428 | // Callabe |
| 6429 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 6430 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694", |
| 6431 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 6432 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6433 | } |
| 6434 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 6435 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6436 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal " |
| 6437 | "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 6438 | } |
| 6439 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 6440 | 0) { |
| 6441 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693", |
| 6442 | "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 6443 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6444 | } |
| 6445 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6446 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 6447 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690", |
| 6448 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 6449 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6450 | } |
| 6451 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 6452 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6453 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to " |
| 6454 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6455 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6456 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 6457 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689", |
| 6458 | "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 6459 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 6460 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6461 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6462 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 6463 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686", |
| 6464 | "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of " |
| 6465 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6466 | } |
| 6467 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 6468 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6469 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to " |
| 6470 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 6471 | } |
| 6472 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 6473 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685", |
| 6474 | "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 6475 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6476 | } |
| 6477 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6478 | if (SafeModulo(indirectDeviceAddress, 4) != 0) { |
| 6479 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634", |
| 6480 | "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6481 | } |
| 6482 | return skip; |
| 6483 | } |
| 6484 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV( |
| 6485 | VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, |
| 6486 | VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 6487 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, |
| 6488 | VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 6489 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 6490 | bool skip = false; |
| 6491 | if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 6492 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462", |
| 6493 | "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of " |
| 6494 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 6495 | } |
| 6496 | if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 6497 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465", |
| 6498 | "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of " |
| 6499 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 6500 | } |
| 6501 | if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 6502 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468", |
| 6503 | "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to " |
| 6504 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. "); |
| 6505 | } |
| 6506 | |
| 6507 | // hitShader |
| 6508 | if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 6509 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460", |
| 6510 | "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of " |
| 6511 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 6512 | } |
| 6513 | if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 6514 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464", |
| 6515 | "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of " |
| 6516 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 6517 | } |
| 6518 | if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 6519 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467", |
| 6520 | "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to " |
| 6521 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 6522 | } |
| 6523 | |
| 6524 | // missShader |
| 6525 | if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 6526 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458", |
| 6527 | "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of " |
| 6528 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 6529 | } |
| 6530 | if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 6531 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463", |
| 6532 | "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of " |
| 6533 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 6534 | } |
| 6535 | if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 6536 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466", |
| 6537 | "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to " |
| 6538 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 6539 | } |
| 6540 | |
| 6541 | // raygenShader |
| 6542 | if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 6543 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456", |
| 6544 | "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of " |
sourav parmar | d152180 | 2020-06-07 21:49:02 -0700 | [diff] [blame] | 6545 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 6546 | } |
| 6547 | if (width > device_limits.maxComputeWorkGroupCount[0]) { |
| 6548 | skip |= |
| 6549 | LogError(device, "VUID-vkCmdTraceRaysNV-width-02469", |
| 6550 | "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o]."); |
| 6551 | } |
| 6552 | if (height > device_limits.maxComputeWorkGroupCount[1]) { |
| 6553 | skip |= |
| 6554 | LogError(device, "VUID-vkCmdTraceRaysNV-height-02470", |
| 6555 | "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1]."); |
| 6556 | } |
| 6557 | if (depth > device_limits.maxComputeWorkGroupCount[2]) { |
| 6558 | skip |= |
| 6559 | LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471", |
| 6560 | "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2]."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6561 | } |
| 6562 | return skip; |
| 6563 | } |
| 6564 | |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6565 | bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6566 | VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo, |
| 6567 | VkAccelerationStructureCompatibilityKHR *pCompatibility) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6568 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6569 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
| 6570 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 6571 | if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) || |
| 6572 | (raytracing_features && !raytracing_features->rayTracingPipeline))) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6573 | skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661", |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 6574 | "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled."); |
| 6575 | } |
| 6576 | return skip; |
| 6577 | } |
| 6578 | |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 6579 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 6580 | const VkViewport *pViewports) const { |
| 6581 | bool skip = false; |
| 6582 | |
| 6583 | if (!physical_device_features.multiViewport) { |
| 6584 | if (viewportCount != 1) { |
| 6585 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395", |
| 6586 | "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 6587 | ") is not 1.", |
| 6588 | viewportCount); |
| 6589 | } |
| 6590 | } else { // multiViewport enabled |
| 6591 | if (viewportCount < 1 || viewportCount > device_limits.maxViewports) { |
| 6592 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394", |
| 6593 | "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32 |
| 6594 | ") must " |
| 6595 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 6596 | viewportCount, device_limits.maxViewports); |
| 6597 | } |
| 6598 | } |
| 6599 | |
| 6600 | if (pViewports) { |
| 6601 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 6602 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
| 6603 | const char *fn_name = "vkCmdSetViewportWithCountEXT"; |
| 6604 | skip |= manual_PreCallValidateViewport( |
| 6605 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
| 6606 | } |
| 6607 | } |
| 6608 | |
| 6609 | return skip; |
| 6610 | } |
| 6611 | |
| 6612 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 6613 | const VkRect2D *pScissors) const { |
| 6614 | bool skip = false; |
| 6615 | |
| 6616 | if (!physical_device_features.multiViewport) { |
| 6617 | if (scissorCount != 1) { |
| 6618 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398", |
| 6619 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 6620 | ") must " |
| 6621 | "be 1 when the multiViewport feature is disabled.", |
| 6622 | scissorCount); |
| 6623 | } |
| 6624 | } else { // multiViewport enabled |
| 6625 | if (scissorCount == 0) { |
| 6626 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 6627 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 6628 | ") must " |
| 6629 | "be great than zero.", |
| 6630 | scissorCount); |
| 6631 | } else if (scissorCount > device_limits.maxViewports) { |
| 6632 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 6633 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 6634 | ") must " |
| 6635 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 6636 | scissorCount, device_limits.maxViewports); |
| 6637 | } |
| 6638 | } |
| 6639 | |
| 6640 | if (pScissors) { |
| 6641 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 6642 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
| 6643 | |
| 6644 | if (scissor.offset.x < 0) { |
| 6645 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 6646 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 6647 | scissor.offset.x); |
| 6648 | } |
| 6649 | |
| 6650 | if (scissor.offset.y < 0) { |
| 6651 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 6652 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 6653 | scissor.offset.y); |
| 6654 | } |
| 6655 | |
| 6656 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 6657 | if (x_sum > INT32_MAX) { |
| 6658 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400", |
| 6659 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 6660 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 6661 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
| 6662 | } |
| 6663 | |
| 6664 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 6665 | if (y_sum > INT32_MAX) { |
| 6666 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401", |
| 6667 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 6668 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 6669 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
| 6670 | } |
| 6671 | } |
| 6672 | } |
| 6673 | |
| 6674 | return skip; |
| 6675 | } |
| 6676 | |
| 6677 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 6678 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 6679 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 6680 | const VkDeviceSize *pStrides) const { |
| 6681 | bool skip = false; |
| 6682 | if (firstBinding >= device_limits.maxVertexInputBindings) { |
| 6683 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355", |
| 6684 | "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)", |
| 6685 | firstBinding, device_limits.maxVertexInputBindings); |
| 6686 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 6687 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356", |
| 6688 | "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 6689 | "maxVertexInputBindings (%u)", |
| 6690 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 6691 | } |
| 6692 | |
| 6693 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 6694 | if (pBuffers[i] == VK_NULL_HANDLE) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 6695 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 6696 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 6697 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111", |
| 6698 | "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 6699 | } else { |
| 6700 | if (pOffsets[i] != 0) { |
| 6701 | skip |= |
| 6702 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112", |
| 6703 | "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 6704 | } |
| 6705 | } |
| 6706 | } |
| 6707 | if (pStrides) { |
| 6708 | if (pStrides[i] > device_limits.maxVertexInputBindingStride) { |
| 6709 | skip |= |
| 6710 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 6711 | "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i, |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 6712 | pStrides[i], device_limits.maxVertexInputBindingStride); |
| 6713 | } |
| 6714 | } |
| 6715 | } |
| 6716 | |
| 6717 | return skip; |
| 6718 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6719 | |
| 6720 | bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR( |
| 6721 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const { |
| 6722 | bool skip = false; |
| 6723 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6724 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 6725 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654", |
| 6726 | "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name); |
| 6727 | } |
| 6728 | if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR && |
| 6729 | pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) { |
| 6730 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796", |
| 6731 | "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set," |
| 6732 | "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.", |
| 6733 | api_name); |
| 6734 | } |
| 6735 | if (pInfos[i].pGeometries && pInfos[i].ppGeometries) { |
| 6736 | skip |= |
| 6737 | LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788", |
| 6738 | "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name); |
| 6739 | } |
| 6740 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) { |
| 6741 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790", |
| 6742 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name); |
| 6743 | } |
| 6744 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && |
| 6745 | pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) { |
| 6746 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793", |
| 6747 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be" |
| 6748 | " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount", |
| 6749 | api_name); |
| 6750 | } |
| 6751 | if (pInfos[i].pGeometries) { |
| 6752 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6753 | skip |= validate_ranged_enum( |
| 6754 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}), |
| 6755 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType, |
| 6756 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 6757 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6758 | skip |= validate_struct_type( |
| 6759 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}), |
| 6760 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6761 | &(pInfos[i].pGeometries[j].geometry.triangles), |
| 6762 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 6763 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 6764 | skip |= validate_struct_pnext( |
| 6765 | api_name, |
| 6766 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 6767 | NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6768 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6769 | skip |= |
| 6770 | validate_ranged_enum(api_name, |
| 6771 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat", |
| 6772 | ParameterName::IndexVector{i, j}), |
| 6773 | "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat, |
| 6774 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 6775 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 6776 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6777 | &pInfos[i].pGeometries[j].geometry.triangles, |
| 6778 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 6779 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 6780 | skip |= validate_ranged_enum( |
| 6781 | api_name, |
| 6782 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}), |
| 6783 | "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType, |
| 6784 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 6785 | |
| 6786 | if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) { |
| 6787 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 6788 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 6789 | } |
| 6790 | if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 6791 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 6792 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 6793 | skip |= |
| 6794 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 6795 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 6796 | api_name); |
| 6797 | } |
| 6798 | } |
| 6799 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6800 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 6801 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6802 | &pInfos[i].pGeometries[j].geometry.instances, |
| 6803 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 6804 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 6805 | skip |= validate_struct_type( |
| 6806 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}), |
| 6807 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6808 | &(pInfos[i].pGeometries[j].geometry.instances), |
| 6809 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 6810 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 6811 | skip |= validate_struct_pnext( |
| 6812 | api_name, |
| 6813 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 6814 | NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6815 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6816 | |
| 6817 | skip |= validate_bool32(api_name, |
| 6818 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers", |
| 6819 | ParameterName::IndexVector{i, j}), |
| 6820 | pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers); |
| 6821 | } |
| 6822 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6823 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 6824 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6825 | &pInfos[i].pGeometries[j].geometry.aabbs, |
| 6826 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 6827 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 6828 | skip |= validate_struct_type( |
| 6829 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 6830 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6831 | &(pInfos[i].pGeometries[j].geometry.aabbs), |
| 6832 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 6833 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 6834 | skip |= validate_struct_pnext( |
| 6835 | api_name, |
| 6836 | ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 6837 | pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6838 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 6839 | if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) { |
| 6840 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 6841 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 6842 | } |
| 6843 | } |
| 6844 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 6845 | pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6846 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 6847 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 6848 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6849 | api_name); |
| 6850 | } |
| 6851 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 6852 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6853 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 6854 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 6855 | "of elements of" |
| 6856 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6857 | api_name); |
| 6858 | } |
| 6859 | if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) { |
| 6860 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 6861 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 6862 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 6863 | api_name); |
| 6864 | } |
| 6865 | } |
| 6866 | } |
| 6867 | } |
| 6868 | if (pInfos[i].ppGeometries != NULL) { |
| 6869 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6870 | skip |= validate_ranged_enum( |
| 6871 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}), |
| 6872 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType, |
| 6873 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 6874 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6875 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 6876 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6877 | &pInfos[i].ppGeometries[j]->geometry.triangles, |
| 6878 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 6879 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 6880 | skip |= validate_struct_type( |
| 6881 | api_name, |
| 6882 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}), |
| 6883 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6884 | &(pInfos[i].ppGeometries[j]->geometry.triangles), |
| 6885 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 6886 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 6887 | skip |= validate_struct_pnext( |
| 6888 | api_name, |
| 6889 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 6890 | NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6891 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6892 | skip |= validate_ranged_enum(api_name, |
| 6893 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat", |
| 6894 | ParameterName::IndexVector{i, j}), |
| 6895 | "VkFormat", AllVkFormatEnums, |
| 6896 | pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat, |
| 6897 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 6898 | skip |= validate_ranged_enum(api_name, |
| 6899 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType", |
| 6900 | ParameterName::IndexVector{i, j}), |
| 6901 | "VkIndexType", AllVkIndexTypeEnums, |
| 6902 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType, |
| 6903 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 6904 | if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) { |
| 6905 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 6906 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 6907 | } |
| 6908 | if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 6909 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 6910 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 6911 | skip |= |
| 6912 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 6913 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 6914 | api_name); |
| 6915 | } |
| 6916 | } |
| 6917 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6918 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 6919 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6920 | &pInfos[i].ppGeometries[j]->geometry.instances, |
| 6921 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 6922 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 6923 | skip |= validate_struct_type( |
| 6924 | api_name, |
| 6925 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}), |
| 6926 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6927 | &(pInfos[i].ppGeometries[j]->geometry.instances), |
| 6928 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 6929 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 6930 | skip |= validate_struct_pnext( |
| 6931 | api_name, |
| 6932 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 6933 | NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6934 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6935 | skip |= validate_bool32(api_name, |
| 6936 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers", |
| 6937 | ParameterName::IndexVector{i, j}), |
| 6938 | pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers); |
| 6939 | } |
| 6940 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6941 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 6942 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6943 | &pInfos[i].ppGeometries[j]->geometry.aabbs, |
| 6944 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 6945 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 6946 | skip |= validate_struct_type( |
| 6947 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 6948 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6949 | &(pInfos[i].ppGeometries[j]->geometry.aabbs), |
| 6950 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 6951 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 6952 | skip |= validate_struct_pnext( |
| 6953 | api_name, |
| 6954 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 6955 | pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6956 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 6957 | if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) { |
| 6958 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 6959 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 6960 | } |
| 6961 | } |
| 6962 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 6963 | pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6964 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 6965 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 6966 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6967 | api_name); |
| 6968 | } |
| 6969 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 6970 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6971 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 6972 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 6973 | "of elements of" |
| 6974 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6975 | api_name); |
| 6976 | } |
| 6977 | if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) { |
| 6978 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 6979 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 6980 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 6981 | api_name); |
| 6982 | } |
| 6983 | } |
| 6984 | } |
| 6985 | } |
| 6986 | } |
| 6987 | return skip; |
| 6988 | } |
| 6989 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR( |
| 6990 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 6991 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 6992 | bool skip = false; |
| 6993 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR"); |
| 6994 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6995 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 6996 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 6997 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710", |
| 6998 | "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its " |
| 6999 | "scratchData.deviceAddress member must be a multiple of " |
| 7000 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 7001 | } |
| 7002 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 7003 | if (i == k) continue; |
| 7004 | bool found = false; |
| 7005 | if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 7006 | skip |= LogError( |
| 7007 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 7008 | "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must " |
| 7009 | "not be " |
| 7010 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 7011 | i, k); |
| 7012 | found = true; |
| 7013 | } |
| 7014 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 7015 | skip |= LogError( |
| 7016 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403", |
| 7017 | "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must " |
| 7018 | "not be " |
| 7019 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 7020 | i, k); |
| 7021 | found = true; |
| 7022 | } |
| 7023 | if (found) break; |
| 7024 | } |
| 7025 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 7026 | if (pInfos[i].pGeometries) { |
| 7027 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7028 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7029 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7030 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 7031 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7032 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7033 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7034 | } |
| 7035 | } else { |
| 7036 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 7037 | skip |= |
| 7038 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 7039 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7040 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7041 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7042 | } |
| 7043 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7044 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7045 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7046 | skip |= LogError( |
| 7047 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 7048 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7049 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7050 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7051 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7052 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7053 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 7054 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 7055 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 7056 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 7057 | } |
| 7058 | } |
| 7059 | } else if (pInfos[i].ppGeometries) { |
| 7060 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7061 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7062 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7063 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 7064 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7065 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7066 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7067 | } |
| 7068 | } else { |
| 7069 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 7070 | skip |= |
| 7071 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 7072 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7073 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7074 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7075 | } |
| 7076 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7077 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7078 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7079 | skip |= LogError( |
| 7080 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 7081 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 7082 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7083 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 7084 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7085 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7086 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 7087 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 7088 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 7089 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 7090 | } |
| 7091 | } |
| 7092 | } |
| 7093 | } |
| 7094 | } |
| 7095 | return skip; |
| 7096 | } |
| 7097 | |
| 7098 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR( |
| 7099 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 7100 | const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides, |
| 7101 | const uint32_t *const *ppMaxPrimitiveCounts) const { |
| 7102 | bool skip = false; |
| 7103 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR"); |
| 7104 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7105 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7106 | if (!ray_tracing_acceleration_structure_features || |
| 7107 | ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) { |
| 7108 | skip |= LogError( |
| 7109 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650", |
| 7110 | "vkCmdBuildAccelerationStructuresIndirectKHR: The " |
| 7111 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled."); |
| 7112 | } |
| 7113 | for (uint32_t i = 0; i < infoCount; ++i) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7114 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 7115 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 7116 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710", |
| 7117 | "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its " |
| 7118 | "scratchData.deviceAddress member must be a multiple of " |
| 7119 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 7120 | } |
| 7121 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 7122 | if (i == k) continue; |
| 7123 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 7124 | skip |= |
| 7125 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403", |
| 7126 | "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) " |
| 7127 | "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of " |
| 7128 | "any other element [%d) of pInfos.", |
| 7129 | i, k); |
| 7130 | break; |
| 7131 | } |
| 7132 | } |
| 7133 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 7134 | if (pInfos[i].pGeometries) { |
| 7135 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7136 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7137 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7138 | skip |= LogError( |
| 7139 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 7140 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7141 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7142 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7143 | } |
| 7144 | } else { |
| 7145 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 7146 | skip |= LogError( |
| 7147 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 7148 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7149 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7150 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7151 | } |
| 7152 | } |
| 7153 | } |
| 7154 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 7155 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 7156 | skip |= LogError( |
| 7157 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 7158 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7159 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7160 | } |
| 7161 | } |
| 7162 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7163 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 7164 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 7165 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 7166 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 7167 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 7168 | } |
| 7169 | } |
| 7170 | } else if (pInfos[i].ppGeometries) { |
| 7171 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 7172 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 7173 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7174 | skip |= LogError( |
| 7175 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 7176 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7177 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 7178 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7179 | } |
| 7180 | } else { |
| 7181 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 7182 | skip |= LogError( |
| 7183 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 7184 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7185 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 7186 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 7187 | } |
| 7188 | } |
| 7189 | } |
| 7190 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 7191 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 7192 | skip |= LogError( |
| 7193 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 7194 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 7195 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 7196 | } |
| 7197 | } |
| 7198 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 7199 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 7200 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 7201 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 7202 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 7203 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 7204 | } |
| 7205 | } |
| 7206 | } |
| 7207 | } |
| 7208 | } |
| 7209 | return skip; |
| 7210 | } |
| 7211 | |
| 7212 | bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR( |
| 7213 | VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, |
| 7214 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 7215 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 7216 | bool skip = false; |
| 7217 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR"); |
| 7218 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7219 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7220 | if (!ray_tracing_acceleration_structure_features || |
| 7221 | ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 7222 | skip |= |
| 7223 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581", |
| 7224 | "vkBuildAccelerationStructuresKHR: The " |
| 7225 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled"); |
| 7226 | } |
| 7227 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 7228 | for (uint32_t j = 0; j < infoCount; ++j) { |
| 7229 | if (i == j) continue; |
| 7230 | bool found = false; |
| 7231 | if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
| 7232 | skip |= LogError( |
| 7233 | device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 7234 | "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must " |
| 7235 | "not be " |
| 7236 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 7237 | i, j); |
| 7238 | found = true; |
| 7239 | } |
| 7240 | if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
| 7241 | skip |= LogError( |
| 7242 | device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403", |
| 7243 | "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must " |
| 7244 | "not be " |
| 7245 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 7246 | i, j); |
| 7247 | found = true; |
| 7248 | } |
| 7249 | if (found) break; |
| 7250 | } |
| 7251 | } |
| 7252 | return skip; |
| 7253 | } |
| 7254 | |
| 7255 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR( |
| 7256 | VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo, |
| 7257 | const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const { |
| 7258 | bool skip = false; |
| 7259 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR"); |
| 7260 | const auto *ray_tracing_pipeline_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 7261 | LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 7262 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 7263 | if (!(ray_tracing_pipeline_features || ray_query_features) || |
| 7264 | ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) || |
| 7265 | (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) { |
| 7266 | skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617", |
| 7267 | "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled"); |
| 7268 | } |
| 7269 | return skip; |
| 7270 | } |
sfricke-samsung | ecafb19 | 2021-01-17 08:21:14 -0800 | [diff] [blame] | 7271 | |
| 7272 | bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device, |
| 7273 | const VkPrivateDataSlotCreateInfoEXT *pCreateInfo, |
| 7274 | const VkAllocationCallbacks *pAllocator, |
| 7275 | VkPrivateDataSlotEXT *pPrivateDataSlot) const { |
| 7276 | bool skip = false; |
| 7277 | const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext); |
| 7278 | if (private_data_features && private_data_features->privateData == VK_FALSE) { |
| 7279 | skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564", |
| 7280 | "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled."); |
| 7281 | } |
| 7282 | return skip; |
Jeremy Gebben | cbf2286 | 2021-03-03 12:01:22 -0700 | [diff] [blame] | 7283 | } |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7284 | |
| 7285 | bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT( |
| 7286 | VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount, |
| 7287 | const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount, |
| 7288 | const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const { |
| 7289 | bool skip = false; |
| 7290 | const auto *vertex_input_dynamic_state_features = |
| 7291 | LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext); |
| 7292 | const auto *vertex_attribute_divisor_features = |
| 7293 | LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext); |
| 7294 | |
| 7295 | // VUID-vkCmdSetVertexInputEXT-None-04790 |
| 7296 | if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) { |
| 7297 | skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790", |
| 7298 | "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled."); |
| 7299 | } |
| 7300 | |
| 7301 | // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791 |
| 7302 | if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
| 7303 | skip |= |
| 7304 | LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791", |
| 7305 | "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit"); |
| 7306 | } |
| 7307 | |
| 7308 | // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792 |
| 7309 | if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
| 7310 | skip |= LogError( |
| 7311 | device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792", |
| 7312 | "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit"); |
| 7313 | } |
| 7314 | |
| 7315 | // VUID-vkCmdSetVertexInputEXT-binding-04793 |
| 7316 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) { |
| 7317 | bool binding_found = false; |
| 7318 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) { |
| 7319 | if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) { |
| 7320 | binding_found = true; |
| 7321 | break; |
| 7322 | } |
| 7323 | } |
| 7324 | if (!binding_found) { |
| 7325 | skip |= |
| 7326 | LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793", |
| 7327 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute); |
| 7328 | } |
| 7329 | } |
| 7330 | |
| 7331 | // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794 |
| 7332 | if (vertexBindingDescriptionCount > 1) { |
| 7333 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) { |
| 7334 | uint32_t binding_value = pVertexBindingDescriptions[binding].binding; |
| 7335 | for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) { |
| 7336 | if (binding_value == pVertexBindingDescriptions[next_binding].binding) { |
| 7337 | skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794", |
| 7338 | "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value); |
| 7339 | } |
| 7340 | } |
| 7341 | } |
| 7342 | } |
| 7343 | |
| 7344 | // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795 |
| 7345 | if (vertexAttributeDescriptionCount > 1) { |
| 7346 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) { |
| 7347 | uint32_t location = pVertexAttributeDescriptions[attribute].location; |
| 7348 | for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) { |
| 7349 | if (location == pVertexAttributeDescriptions[next_attribute].location) { |
| 7350 | skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795", |
| 7351 | "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location); |
| 7352 | } |
| 7353 | } |
| 7354 | } |
| 7355 | } |
| 7356 | |
| 7357 | for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) { |
| 7358 | // VUID-VkVertexInputBindingDescription2EXT-binding-04796 |
| 7359 | if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) { |
| 7360 | skip |= LogError( |
| 7361 | device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796", |
| 7362 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding); |
| 7363 | } |
| 7364 | |
| 7365 | // VUID-VkVertexInputBindingDescription2EXT-stride-04797 |
| 7366 | if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) { |
| 7367 | skip |= LogError( |
| 7368 | device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797", |
| 7369 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride", |
| 7370 | binding); |
| 7371 | } |
| 7372 | |
| 7373 | // VUID-VkVertexInputBindingDescription2EXT-divisor-04798 |
| 7374 | if (pVertexBindingDescriptions[binding].divisor == 0 && |
| 7375 | (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) { |
| 7376 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798", |
| 7377 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but " |
| 7378 | "vertexAttributeInstanceRateZeroDivisor is not enabled", |
| 7379 | binding); |
| 7380 | } |
| 7381 | |
| 7382 | if (pVertexBindingDescriptions[binding].divisor > 1) { |
| 7383 | // VUID-VkVertexInputBindingDescription2EXT-divisor-04799 |
| 7384 | if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) { |
| 7385 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799", |
| 7386 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but " |
| 7387 | "vertexAttributeInstanceRateDivisor is not enabled", |
| 7388 | binding); |
| 7389 | } else { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7390 | // VUID-VkVertexInputBindingDescription2EXT-divisor-06226 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7391 | if (pVertexBindingDescriptions[binding].divisor > |
| 7392 | phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) { |
| 7393 | skip |= LogError( |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7394 | device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226", |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7395 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor", |
| 7396 | binding); |
| 7397 | } |
| 7398 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7399 | // VUID-VkVertexInputBindingDescription2EXT-divisor-06227 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7400 | if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) { |
| 7401 | skip |= |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7402 | LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227", |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7403 | "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate " |
| 7404 | "is not VK_VERTEX_INPUT_RATE_INSTANCE", |
| 7405 | binding); |
| 7406 | } |
| 7407 | } |
| 7408 | } |
| 7409 | } |
| 7410 | |
| 7411 | for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) { |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7412 | // VUID-VkVertexInputAttributeDescription2EXT-location-06228 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7413 | if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) { |
| 7414 | skip |= LogError( |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7415 | device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228", |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7416 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes", |
| 7417 | attribute); |
| 7418 | } |
| 7419 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7420 | // VUID-VkVertexInputAttributeDescription2EXT-binding-06229 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7421 | if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) { |
| 7422 | skip |= LogError( |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7423 | device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229", |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7424 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings", |
| 7425 | attribute); |
| 7426 | } |
| 7427 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7428 | // VUID-VkVertexInputAttributeDescription2EXT-offset-06230 |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7429 | if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) { |
| 7430 | skip |= LogError( |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 7431 | device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230", |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 7432 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset", |
| 7433 | attribute); |
| 7434 | } |
| 7435 | |
| 7436 | // VUID-VkVertexInputAttributeDescription2EXT-format-04805 |
| 7437 | VkFormatProperties properties; |
| 7438 | DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties); |
| 7439 | if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) { |
| 7440 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805", |
| 7441 | "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a " |
| 7442 | "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format", |
| 7443 | attribute); |
| 7444 | } |
| 7445 | } |
| 7446 | |
| 7447 | return skip; |
| 7448 | } |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 7449 | |
| 7450 | bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, |
| 7451 | VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, |
| 7452 | const void *pValues) const { |
| 7453 | bool skip = false; |
| 7454 | const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize; |
| 7455 | // Check that offset + size don't exceed the max. |
| 7456 | // Prevent arithetic overflow here by avoiding addition and testing in this order. |
| 7457 | if (offset >= max_push_constants_size) { |
| 7458 | skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370", |
| 7459 | "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset, |
| 7460 | max_push_constants_size); |
| 7461 | } |
| 7462 | if (size > max_push_constants_size - offset) { |
| 7463 | skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371", |
| 7464 | "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.", |
| 7465 | offset, size, max_push_constants_size); |
| 7466 | } |
| 7467 | |
| 7468 | // size needs to be non-zero and a multiple of 4. |
| 7469 | if (size & 0x3) { |
| 7470 | skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.", |
| 7471 | size); |
| 7472 | } |
| 7473 | |
| 7474 | // offset needs to be a multiple of 4. |
| 7475 | if ((offset & 0x3) != 0) { |
| 7476 | skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368", |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 7477 | "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset); |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 7478 | } |
| 7479 | return skip; |
Jeremy Gebben | da6b48f | 2021-05-13 10:46:18 -0600 | [diff] [blame] | 7480 | } |
ziga-lunarg | b1dd8a2 | 2021-07-15 17:47:19 +0200 | [diff] [blame] | 7481 | |
| 7482 | bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, |
| 7483 | uint32_t srcCacheCount, |
| 7484 | const VkPipelineCache *pSrcCaches) const { |
| 7485 | bool skip = false; |
| 7486 | if (pSrcCaches) { |
| 7487 | for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) { |
| 7488 | if (pSrcCaches[index0] == dstCache) { |
| 7489 | skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770", |
| 7490 | "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.", |
| 7491 | report_data->FormatHandle(dstCache).c_str()); |
| 7492 | break; |
| 7493 | } |
| 7494 | } |
| 7495 | } |
| 7496 | return skip; |
| 7497 | } |
Nathaniel Cesario | 298d3cb | 2021-08-03 13:49:02 -0600 | [diff] [blame] | 7498 | |
| 7499 | bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, |
| 7500 | VkImageLayout imageLayout, const VkClearColorValue *pColor, |
| 7501 | uint32_t rangeCount, |
| 7502 | const VkImageSubresourceRange *pRanges) const { |
| 7503 | bool skip = false; |
| 7504 | if (!pColor) { |
| 7505 | skip |= |
| 7506 | LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null"); |
| 7507 | } |
| 7508 | return skip; |
| 7509 | } |
| 7510 | |
| 7511 | bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name, |
| 7512 | const VkRenderPassBeginInfo *const rp_begin) const { |
| 7513 | bool skip = false; |
| 7514 | if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) { |
| 7515 | skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962", |
| 7516 | "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32 |
ziga-lunarg | 47109fb | 2021-09-03 18:41:12 +0200 | [diff] [blame] | 7517 | "), but VkRenderPassBeginInfo::pClearValues is null.", |
Nathaniel Cesario | 298d3cb | 2021-08-03 13:49:02 -0600 | [diff] [blame] | 7518 | func_name, rp_begin->clearValueCount); |
| 7519 | } |
| 7520 | return skip; |
| 7521 | } |
| 7522 | |
| 7523 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 7524 | VkSubpassContents) const { |
| 7525 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin); |
| 7526 | return skip; |
| 7527 | } |
| 7528 | |
| 7529 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer, |
| 7530 | const VkRenderPassBeginInfo *pRenderPassBegin, |
| 7531 | const VkSubpassBeginInfo *) const { |
| 7532 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin); |
| 7533 | return skip; |
| 7534 | } |
| 7535 | |
| 7536 | bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 7537 | const VkSubpassBeginInfo *) const { |
| 7538 | bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin); |
| 7539 | return skip; |
| 7540 | } |
ziga-lunarg | c7bb56a | 2021-08-10 09:28:52 +0200 | [diff] [blame] | 7541 | |
| 7542 | bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer, |
| 7543 | uint32_t firstDiscardRectangle, |
| 7544 | uint32_t discardRectangleCount, |
| 7545 | const VkRect2D *pDiscardRectangles) const { |
| 7546 | bool skip = false; |
| 7547 | |
| 7548 | if (pDiscardRectangles) { |
| 7549 | for (uint32_t i = 0; i < discardRectangleCount; ++i) { |
| 7550 | const int64_t x_sum = |
| 7551 | static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width); |
| 7552 | if (x_sum > std::numeric_limits<int32_t>::max()) { |
| 7553 | skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588", |
| 7554 | "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 7555 | ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.", |
| 7556 | pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i); |
| 7557 | } |
| 7558 | |
| 7559 | const int64_t y_sum = |
| 7560 | static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height); |
| 7561 | if (y_sum > std::numeric_limits<int32_t>::max()) { |
| 7562 | skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589", |
| 7563 | "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 7564 | ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.", |
| 7565 | pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i); |
| 7566 | } |
| 7567 | } |
| 7568 | } |
| 7569 | |
| 7570 | return skip; |
| 7571 | } |
ziga-lunarg | 3c37dfb | 2021-08-24 12:51:07 +0200 | [diff] [blame] | 7572 | |
| 7573 | bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, |
| 7574 | uint32_t queryCount, size_t dataSize, void *pData, |
| 7575 | VkDeviceSize stride, VkQueryResultFlags flags) const { |
| 7576 | bool skip = false; |
| 7577 | |
| 7578 | if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) { |
| 7579 | skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811", |
| 7580 | "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit."); |
| 7581 | } |
| 7582 | |
| 7583 | return skip; |
| 7584 | } |
ziga-lunarg | cf340c4 | 2021-08-19 00:13:38 +0200 | [diff] [blame] | 7585 | |
| 7586 | bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT( |
| 7587 | VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const { |
| 7588 | bool skip = false; |
| 7589 | |
| 7590 | if ((pConditionalRenderingBegin->offset & 3) != 0) { |
| 7591 | skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984", |
| 7592 | "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64 |
| 7593 | ") is not a multiple of 4.", |
| 7594 | pConditionalRenderingBegin->offset); |
| 7595 | } |
| 7596 | |
| 7597 | return skip; |
| 7598 | } |