sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2020 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2020 Valve Corporation |
| 3 | * Copyright (c) 2015-2020 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2020 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" |
Tobias Hector | d942eb9 | 2018-10-22 15:18:56 +0100 | [diff] [blame] | 27 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 28 | static const int kMaxParamCheckerStringLength = 256; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 29 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 30 | template <typename T> |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 31 | 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] | 32 | // Using only < for generality and || for early abort |
| 33 | return !((value < min) || (max < value)); |
| 34 | } |
| 35 | |
Mark Lobodzinski | 21b91fe | 2020-12-03 15:44:24 -0700 | [diff] [blame] | 36 | read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); } |
| 37 | write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); } |
| 38 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 39 | static std::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{}; |
| 40 | static ReadWriteLock secondary_cb_map_mutex; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 41 | static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); } |
| 42 | 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] | 43 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 44 | 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] | 45 | const char *validateString) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 46 | bool skip = false; |
| 47 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 48 | VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 49 | |
| 50 | if (result == VK_STRING_ERROR_NONE) { |
| 51 | return skip; |
| 52 | } else if (result & VK_STRING_ERROR_LENGTH) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 53 | 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] | 54 | kMaxParamCheckerStringLength); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 55 | } else if (result & VK_STRING_ERROR_BAD_DATA) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 56 | skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName, |
| 57 | stringName.get_name().c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 58 | } |
| 59 | return skip; |
| 60 | } |
| 61 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 62 | 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] | 63 | bool skip = false; |
| 64 | uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0); |
| 65 | if (api_version_nopatch != effective_api_version) { |
sfricke-samsung | 6aec21b | 2020-11-01 07:49:43 -0800 | [diff] [blame] | 66 | if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) { |
| 67 | skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 68 | "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 69 | "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 70 | 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] | 71 | } else { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 72 | skip |= LogWarning(instance, kVUIDUndefined, |
| 73 | "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 74 | "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 75 | 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] | 76 | } |
| 77 | } |
| 78 | return skip; |
| 79 | } |
| 80 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 81 | bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const { |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 82 | bool skip = false; |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 83 | // Create and use a local instance extension object, as an actual instance has not been created yet |
| 84 | uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0); |
| 85 | InstanceExtensions local_instance_extensions; |
| 86 | local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo); |
| 87 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 88 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 89 | skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388", |
| 90 | "instance", pCreateInfo->ppEnabledExtensionNames[i]); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | return skip; |
| 94 | } |
| 95 | |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 96 | bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const { |
| 97 | if (instance_extensions.vk_khr_get_physical_device_properties_2) { |
| 98 | // Struct is legal IF it's supported |
| 99 | const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device); |
| 100 | if (dev_exts_enumerated == device_extensions_enumerated.end()) return true; |
| 101 | auto enum_iter = dev_exts_enumerated->second.find(ext_name); |
| 102 | if (enum_iter != dev_exts_enumerated->second.cend()) { |
| 103 | return true; |
| 104 | } |
| 105 | } |
| 106 | return false; |
| 107 | } |
| 108 | |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 109 | bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo, |
| 110 | const VkValidationFeaturesEXT *validation_features) const { |
| 111 | bool skip = false; |
| 112 | bool debug_printf = false; |
| 113 | bool gpu_assisted = false; |
| 114 | bool reserve_slot = false; |
| 115 | for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) { |
| 116 | switch (validation_features->pEnabledValidationFeatures[i]) { |
| 117 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT: |
| 118 | gpu_assisted = true; |
| 119 | break; |
| 120 | |
| 121 | case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT: |
| 122 | debug_printf = true; |
| 123 | break; |
| 124 | |
| 125 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT: |
| 126 | reserve_slot = true; |
| 127 | break; |
| 128 | |
| 129 | default: |
| 130 | break; |
| 131 | } |
| 132 | } |
| 133 | if (reserve_slot && !gpu_assisted) { |
| 134 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967", |
| 135 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, " |
| 136 | "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures."); |
| 137 | } |
| 138 | if (gpu_assisted && debug_printf) { |
| 139 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968", |
| 140 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, " |
| 141 | "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures."); |
| 142 | } |
| 143 | |
| 144 | return skip; |
| 145 | } |
| 146 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 147 | template <typename ExtensionState> |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 148 | ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) { |
| 149 | if (!extension_name) return kNotEnabled; // null strings specify nothing |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 150 | auto info = ExtensionState::get_info(extension_name); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 151 | ExtEnabled state = |
| 152 | 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] | 153 | return state; |
| 154 | } |
| 155 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 156 | bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 157 | const VkAllocationCallbacks *pAllocator, |
| 158 | VkInstance *pInstance) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 159 | bool skip = false; |
| 160 | // Note: From the spec-- |
| 161 | // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing |
| 162 | // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0) |
| 163 | uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion) |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 164 | ? pCreateInfo->pApplicationInfo->apiVersion |
| 165 | : VK_API_VERSION_1_0; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 166 | skip |= validate_api_version(local_api_version, api_version); |
| 167 | skip |= validate_instance_extensions(pCreateInfo); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 168 | const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext); |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 169 | if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features); |
| 170 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 171 | return skip; |
| 172 | } |
| 173 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 174 | void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 175 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, |
| 176 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 177 | auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 178 | // Copy extension data into local object |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 179 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 180 | this->instance_extensions = instance_data->instance_extensions; |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 181 | |
| 182 | uint32_t pdev_count = 0; |
| 183 | DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, nullptr); |
| 184 | std::vector<VkPhysicalDevice> physical_devices; |
| 185 | physical_devices.resize(pdev_count); |
| 186 | DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, physical_devices.data()); |
| 187 | |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 188 | for (uint32_t i = 0; i < physical_devices.size(); i++) { |
| 189 | auto phys_dev_props = new VkPhysicalDeviceProperties; |
| 190 | DispatchGetPhysicalDeviceProperties(physical_devices[i], phys_dev_props); |
| 191 | physical_device_properties_map[physical_devices[i]] = phys_dev_props; |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 192 | |
| 193 | // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state |
| 194 | uint32_t ext_count = 0; |
| 195 | std::unordered_set<std::string> dev_exts_enumerated{}; |
| 196 | std::vector<VkExtensionProperties> ext_props{}; |
| 197 | instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, nullptr); |
| 198 | ext_props.resize(ext_count); |
| 199 | instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, ext_props.data()); |
| 200 | for (uint32_t j = 0; j < ext_count; j++) { |
| 201 | dev_exts_enumerated.insert(ext_props[j].extensionName); |
| 202 | } |
| 203 | device_extensions_enumerated[physical_devices[i]] = std::move(dev_exts_enumerated); |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 204 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 207 | void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 208 | for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) { |
| 209 | delete (it->second); |
| 210 | it = physical_device_properties_map.erase(it); |
| 211 | } |
| 212 | }; |
| 213 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 214 | void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 215 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 216 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 217 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 218 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); |
| 219 | StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 220 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 221 | // Parmeter validation also uses extension data |
| 222 | stateless_validation->device_extensions = this->device_extensions; |
| 223 | |
| 224 | VkPhysicalDeviceProperties device_properties = {}; |
| 225 | // Need to get instance and do a getlayerdata call... |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 226 | DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 227 | memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 228 | |
| 229 | if (device_extensions.vk_nv_shading_rate_image) { |
| 230 | // Get the needed shading rate image limits |
| 231 | auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 232 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&shading_rate_image_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 233 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 234 | phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; |
| 235 | } |
| 236 | |
| 237 | if (device_extensions.vk_nv_mesh_shader) { |
| 238 | // Get the needed mesh shader limits |
| 239 | auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 240 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&mesh_shader_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 241 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 242 | phys_dev_ext_props.mesh_shader_props = mesh_shader_props; |
| 243 | } |
| 244 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 245 | if (device_extensions.vk_nv_ray_tracing) { |
| 246 | // Get the needed ray tracing limits |
| 247 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 248 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 249 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 250 | phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props; |
| 251 | } |
| 252 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 253 | if (device_extensions.vk_khr_ray_tracing_pipeline) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 254 | // Get the needed ray tracing limits |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 255 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 256 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 257 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 258 | phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props; |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 259 | } |
| 260 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 261 | if (device_extensions.vk_khr_acceleration_structure) { |
| 262 | // Get the needed ray tracing acc structure limits |
| 263 | auto acc_structure_props = lvl_init_struct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 264 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&acc_structure_props); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 265 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 266 | phys_dev_ext_props.acc_structure_props = acc_structure_props; |
| 267 | } |
| 268 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 269 | if (device_extensions.vk_ext_transform_feedback) { |
| 270 | // Get the needed transform feedback limits |
| 271 | auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 272 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&transform_feedback_props); |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 273 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 274 | phys_dev_ext_props.transform_feedback_props = transform_feedback_props; |
| 275 | } |
| 276 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 277 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 278 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 279 | // Save app-enabled features in this device's validation object |
| 280 | // 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^] | 281 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 282 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 283 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 284 | if (features2) { |
| 285 | tmp_features2_state.features = features2->features; |
| 286 | } else if (pCreateInfo->pEnabledFeatures) { |
| 287 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 288 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 289 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 290 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 291 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 292 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 293 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 294 | } |
| 295 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 296 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 297 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 298 | bool skip = false; |
| 299 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 300 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 301 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 302 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 303 | } |
| 304 | |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 305 | // If this device supports VK_KHR_portability_subset, it must be enabled |
| 306 | const std::string portability_extension_name("VK_KHR_portability_subset"); |
| 307 | const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice); |
| 308 | const bool portability_supported = dev_extensions.count(portability_extension_name) != 0; |
| 309 | bool portability_requested = false; |
| 310 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 311 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 312 | skip |= |
| 313 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 314 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 315 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 316 | pCreateInfo->ppEnabledExtensionNames[i]); |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 317 | if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) { |
| 318 | portability_requested = true; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | if (portability_supported && !portability_requested) { |
| 323 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451", |
| 324 | "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it", |
| 325 | report_data->FormatHandle(physicalDevice).c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 326 | } |
| 327 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 328 | { |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 329 | bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME)); |
| 330 | bool negative_viewport = |
| 331 | 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] | 332 | if (maint1 && negative_viewport) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 333 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 334 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
| 335 | "VK_AMD_negative_viewport_height."); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 336 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 337 | } |
| 338 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 339 | { |
| 340 | bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 341 | bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 342 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 343 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 344 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 345 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 349 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 350 | // Check for get_physical_device_properties2 struct |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 351 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 352 | if (features2) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 353 | // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 354 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 355 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 356 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 360 | auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 361 | const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 362 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 363 | if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { |
| 364 | skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", |
| 365 | "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); |
| 366 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 367 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 368 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed && |
| 369 | !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) { |
| 370 | skip |= LogError( |
| 371 | device, |
| 372 | "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575", |
| 373 | "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay " |
| 374 | "must also be VK_TRUE."); |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 375 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 376 | auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
Mark Lobodzinski | 3e66ae8 | 2020-08-12 16:27:29 -0600 | [diff] [blame] | 377 | if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) { |
| 378 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 379 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 380 | "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] | 381 | } |
| 382 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 383 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 384 | if (vulkan_11_features) { |
| 385 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 386 | while (current) { |
| 387 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 388 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 389 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 390 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 391 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 392 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 393 | skip |= LogError( |
| 394 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 395 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 396 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 397 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 398 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 399 | break; |
| 400 | } |
| 401 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 402 | } |
| 403 | } |
| 404 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 405 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 406 | if (vulkan_12_features) { |
| 407 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 408 | while (current) { |
| 409 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 410 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 411 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 412 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 413 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 414 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 415 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 416 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 417 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 418 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 419 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 420 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 421 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 422 | skip |= LogError( |
| 423 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 424 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 425 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 426 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 427 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 428 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 429 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 430 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 431 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 432 | break; |
| 433 | } |
| 434 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 435 | } |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 436 | // Check features are enabled if matching extension is passed in as well |
| 437 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 438 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 439 | if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 440 | (vulkan_12_features->drawIndirectCount == VK_FALSE)) { |
| 441 | skip |= LogError( |
| 442 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831", |
| 443 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", |
| 444 | VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 445 | } |
| 446 | if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 447 | (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { |
| 448 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832", |
| 449 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " |
| 450 | "is not VK_TRUE.", |
| 451 | VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); |
| 452 | } |
| 453 | if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 454 | (vulkan_12_features->descriptorIndexing == VK_FALSE)) { |
| 455 | skip |= LogError( |
| 456 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833", |
| 457 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", |
| 458 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 459 | } |
| 460 | if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 461 | (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { |
| 462 | skip |= LogError( |
| 463 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834", |
| 464 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", |
| 465 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 466 | } |
| 467 | if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 468 | ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || |
| 469 | (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { |
| 470 | skip |= |
| 471 | LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835", |
| 472 | "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " |
| 473 | "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", |
| 474 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); |
| 475 | } |
| 476 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 479 | // Validate pCreateInfo->pQueueCreateInfos |
| 480 | if (pCreateInfo->pQueueCreateInfos) { |
| 481 | std::unordered_set<uint32_t> set; |
| 482 | |
| 483 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 484 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
| 485 | const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 486 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 487 | skip |= |
| 488 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 489 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 490 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 491 | "index value.", |
| 492 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 493 | } else if (set.count(requested_queue_family)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 494 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372", |
| 495 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 |
| 496 | ") is not unique within pCreateInfo->pQueueCreateInfos array.", |
| 497 | i, requested_queue_family); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 498 | } else { |
| 499 | set.insert(requested_queue_family); |
| 500 | } |
| 501 | |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 502 | if (queue_create_info.pQueuePriorities != nullptr) { |
| 503 | for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { |
| 504 | const float queue_priority = queue_create_info.pQueuePriorities[j]; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 505 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 506 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 507 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 508 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 509 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 510 | } |
| 511 | } |
| 512 | } |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 513 | |
| 514 | // 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] | 515 | VkBool32 protected_memory = VK_FALSE; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 516 | const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 517 | LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 518 | if (protected_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 519 | protected_memory = protected_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 520 | } else if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 521 | protected_memory = vulkan_11_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 522 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 523 | 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] | 524 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", |
| 525 | "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " |
| 526 | "protectedMemory feature being set as well."); |
| 527 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 531 | // feature dependencies for VK_KHR_variable_pointers |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 532 | const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 533 | VkBool32 variable_pointers = VK_FALSE; |
| 534 | VkBool32 variable_pointers_storage_buffer = VK_FALSE; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 535 | if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 536 | variable_pointers = vulkan_11_features->variablePointers; |
| 537 | variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 538 | } else if (variable_pointers_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 539 | variable_pointers = variable_pointers_features->variablePointers; |
| 540 | variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 541 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 542 | if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) { |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 543 | skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431", |
| 544 | "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE"); |
| 545 | } |
| 546 | |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 547 | // feature dependencies for VK_KHR_multiview |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 548 | const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 549 | VkBool32 multiview = VK_FALSE; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 550 | VkBool32 multiview_geometry_shader = VK_FALSE; |
| 551 | VkBool32 multiview_tessellation_shader = VK_FALSE; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 552 | if (vulkan_11_features) { |
| 553 | multiview = vulkan_11_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 554 | multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader; |
| 555 | multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 556 | } else if (multiview_features) { |
| 557 | multiview = multiview_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 558 | multiview_geometry_shader = multiview_features->multiviewGeometryShader; |
| 559 | multiview_tessellation_shader = multiview_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 560 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 561 | if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 562 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580", |
| 563 | "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 564 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 565 | if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 566 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581", |
| 567 | "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 568 | } |
| 569 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 570 | return skip; |
| 571 | } |
| 572 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 573 | 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] | 574 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 575 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 576 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 577 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 578 | } |
| 579 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 580 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 581 | } |
| 582 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 583 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 584 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 585 | bool skip = false; |
| 586 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 587 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 588 | skip |= |
| 589 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 590 | |
| 591 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 592 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 593 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 594 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 595 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 596 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 597 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 601 | // queueFamilyIndexCount uint32_t values |
| 602 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 603 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 604 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 605 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 606 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 607 | } |
| 608 | } |
| 609 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 610 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
| 611 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915", |
| 612 | "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the " |
| 613 | "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set."); |
| 614 | } |
| 615 | |
| 616 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) { |
| 617 | skip |= |
| 618 | LogError(device, "VUID-VkBufferCreateInfo-flags-00916", |
| 619 | "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with " |
| 620 | "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set."); |
| 621 | } |
| 622 | |
| 623 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 624 | skip |= |
| 625 | LogError(device, "VUID-VkBufferCreateInfo-flags-00917", |
| 626 | "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with " |
| 627 | "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set."); |
| 628 | } |
| 629 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 630 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 631 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 632 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 633 | ((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] | 634 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 635 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 636 | "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] | 637 | } |
| 638 | } |
| 639 | |
| 640 | return skip; |
| 641 | } |
| 642 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 643 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 644 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 645 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 646 | |
| 647 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 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-VkImageCreateInfo-sharingMode-00942", |
| 653 | "vkCreateImage(): 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-VkImageCreateInfo-sharingMode-00941", |
| 661 | "vkCreateImage(): 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 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 667 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 668 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 669 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 670 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 671 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 672 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 673 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 674 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 675 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 676 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 677 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 678 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 679 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 680 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 681 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 682 | skip |= LogError( |
| 683 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 684 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 685 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 686 | } |
| 687 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 688 | // 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] | 689 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 690 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 691 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 692 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 693 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 697 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 698 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 699 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 700 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 701 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 702 | ") are not equal.", |
| 703 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 707 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 708 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 709 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 710 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 711 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 715 | skip |= LogError( |
| 716 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 717 | "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] | 718 | } |
| 719 | } |
| 720 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 721 | // 3D image may have only 1 layer |
| 722 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 723 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 724 | "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] | 725 | } |
| 726 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 727 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 728 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 729 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 730 | // At least one of the legal attachment bits must be set |
| 731 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 732 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 733 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 734 | } |
| 735 | // No flags other than the legal attachment bits may be set |
| 736 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 737 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 738 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 739 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 740 | } |
| 741 | } |
| 742 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 743 | // 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] | 744 | 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] | 745 | // Max mip levels is different for corner-sampled images vs normal images. |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 746 | uint32_t max_mip_levels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) |
| 747 | ? static_cast<uint32_t>(ceil(log2(max_dim))) |
| 748 | : static_cast<uint32_t>(floor(log2(max_dim)) + 1); |
| 749 | if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 750 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 751 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 752 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 753 | "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] | 754 | } |
| 755 | |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 756 | if ((pCreateInfo->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] | 757 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 758 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 759 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 760 | } |
| 761 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 762 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 763 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 764 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 765 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 766 | } |
| 767 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 768 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 769 | skip |= LogError( |
| 770 | device, "VUID-VkImageCreateInfo-flags-01924", |
| 771 | "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the " |
| 772 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set."); |
| 773 | } |
| 774 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 775 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 776 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
| 777 | if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 778 | ((pCreateInfo->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] | 779 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 780 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 781 | "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] | 782 | } |
| 783 | |
| 784 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
| 785 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
| 786 | // Linear tiling is unsupported |
| 787 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
sfricke-samsung | 9801d75 | 2020-08-23 22:00:16 -0700 | [diff] [blame] | 788 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 789 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 790 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | // Sparse 1D image isn't valid |
| 794 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 795 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 796 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 800 | 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] | 801 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 802 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 803 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 807 | 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] | 808 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 809 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 810 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | // Multi-sample 2D image when device doesn't support it |
| 814 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 815 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 816 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 817 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 818 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 819 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 820 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 821 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 822 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 823 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 824 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 825 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 826 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 827 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 828 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 829 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 830 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 831 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 832 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 833 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 834 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 835 | } |
| 836 | } |
| 837 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 838 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 839 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 840 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 841 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 842 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 843 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 844 | } |
| 845 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 846 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 847 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 848 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 849 | } |
| 850 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 851 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 852 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 853 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 854 | } |
| 855 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 856 | |
| 857 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 858 | 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] | 859 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 860 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 861 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 862 | } |
| 863 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 864 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 865 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 866 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 867 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must " |
| 868 | "not be a depth/stencil format."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 869 | } |
| 870 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 871 | 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] | 872 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 873 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 874 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 875 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 876 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 877 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 878 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 879 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 880 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 881 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 882 | } |
| 883 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 884 | |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 885 | if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) && |
| 886 | (FormatHasDepth(pCreateInfo->format) == false)) { |
| 887 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533", |
| 888 | "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the " |
| 889 | "format must be a depth or depth/stencil format."); |
| 890 | } |
| 891 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 892 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 893 | if (image_stencil_struct != nullptr) { |
| 894 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 895 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 896 | // No flags other than the legal attachment bits may be set |
| 897 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 898 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 899 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 900 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 901 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 902 | "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] | 903 | } |
| 904 | } |
| 905 | |
| 906 | if (FormatIsDepthOrStencil(pCreateInfo->format)) { |
| 907 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 908 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
| 909 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 910 | LogError(device, "VUID-VkImageCreateInfo-Format-02536", |
| 911 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 912 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device " |
| 913 | "maxFramebufferWidth"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
| 917 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 918 | LogError(device, "VUID-VkImageCreateInfo-format-02537", |
| 919 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 920 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device " |
| 921 | "maxFramebufferHeight"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 922 | } |
| 923 | } |
| 924 | |
| 925 | if (!physical_device_features.shaderStorageImageMultisample && |
| 926 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 927 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 928 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 929 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 930 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 931 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 932 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 936 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 937 | skip |= LogError( |
| 938 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 939 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 940 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 941 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 942 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 943 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 944 | skip |= LogError( |
| 945 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 946 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 947 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 948 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 949 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 950 | } |
| 951 | |
| 952 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 953 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 954 | skip |= LogError( |
| 955 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 956 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 957 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 958 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 959 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 960 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 961 | skip |= LogError( |
| 962 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 963 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 964 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 965 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 966 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 967 | } |
| 968 | } |
| 969 | } |
Spencer Fricke | ca52b5c | 2020-03-16 17:34:00 -0700 | [diff] [blame] | 970 | |
| 971 | if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 972 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 973 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968", |
| 974 | "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images " |
| 975 | "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
| 976 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 977 | |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 978 | std::vector<uint64_t> image_create_drm_format_modifiers; |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 979 | if (device_extensions.vk_ext_image_drm_format_modifier) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 980 | const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext); |
| 981 | const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext); |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 982 | if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 983 | if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) || |
| 984 | ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) { |
| 985 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261", |
| 986 | "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have " |
| 987 | "either VkImageDrmFormatModifierListCreateInfoEXT or " |
| 988 | "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain"); |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 989 | } else if (drm_format_mod_list != nullptr) { |
| 990 | image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier); |
| 991 | } else if (drm_format_mod_list != nullptr) { |
| 992 | for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) { |
| 993 | image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers); |
| 994 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 995 | } |
| 996 | } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) { |
| 997 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262", |
| 998 | "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a " |
| 999 | "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT " |
| 1000 | "in the pNext chain"); |
| 1001 | } |
| 1002 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1003 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1004 | static const uint64_t drm_format_mod_linear = 0; |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1005 | bool image_create_maybe_linear = false; |
| 1006 | if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) { |
| 1007 | image_create_maybe_linear = true; |
| 1008 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) { |
| 1009 | image_create_maybe_linear = false; |
| 1010 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1011 | image_create_maybe_linear = |
| 1012 | (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] | 1013 | drm_format_mod_linear) != image_create_drm_format_modifiers.end()); |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 1017 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
| 1018 | ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || |
| 1019 | (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) { |
| 1020 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 1021 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
| 1022 | } |
| 1023 | |
| 1024 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) && |
| 1025 | ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || |
| 1026 | image_create_maybe_linear)) { |
| 1027 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259", |
| 1028 | "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips."); |
| 1029 | } |
| 1030 | |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1031 | if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) { |
| 1032 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1033 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557", |
| 1034 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1035 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1036 | } |
| 1037 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1038 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558", |
| 1039 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1040 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
| 1041 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1042 | } |
| 1043 | if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) { |
| 1044 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1045 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565", |
| 1046 | "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1047 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 1048 | } |
| 1049 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1050 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566", |
| 1051 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1052 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1053 | } |
| 1054 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 1055 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567", |
| 1056 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1057 | "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT."); |
| 1058 | } |
| 1059 | if (pCreateInfo->mipLevels != 1) { |
| 1060 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568", |
| 1061 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.", |
| 1062 | pCreateInfo->mipLevels); |
| 1063 | } |
| 1064 | } |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1065 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 1066 | const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1067 | if (swapchain_create_info != nullptr) { |
| 1068 | if (swapchain_create_info->swapchain != VK_NULL_HANDLE) { |
| 1069 | // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the |
| 1070 | // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information |
| 1071 | // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation |
| 1072 | const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995"; |
| 1073 | const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image"; |
| 1074 | |
| 1075 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1076 | // also implicitly forces the check above that extent.depth is 1 |
| 1077 | skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message, |
| 1078 | string_VkImageType(pCreateInfo->imageType)); |
| 1079 | } |
| 1080 | if (pCreateInfo->mipLevels != 1) { |
| 1081 | skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message, |
| 1082 | pCreateInfo->mipLevels); |
| 1083 | } |
| 1084 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1085 | skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.", |
| 1086 | base_message, string_VkSampleCountFlagBits(pCreateInfo->samples)); |
| 1087 | } |
| 1088 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1089 | skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.", |
| 1090 | base_message, string_VkImageTiling(pCreateInfo->tiling)); |
| 1091 | } |
| 1092 | if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) { |
| 1093 | skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.", |
| 1094 | base_message, string_VkImageLayout(pCreateInfo->initialLayout)); |
| 1095 | } |
| 1096 | const VkImageCreateFlags valid_flags = |
| 1097 | (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] | 1098 | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1099 | if ((pCreateInfo->flags & ~valid_flags) != 0) { |
| 1100 | skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message, |
| 1101 | pCreateInfo->flags); |
| 1102 | } |
| 1103 | } |
| 1104 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1105 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1106 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1107 | return skip; |
| 1108 | } |
| 1109 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1110 | bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 1111 | const VkAllocationCallbacks *pAllocator, VkImageView *pView) const { |
| 1112 | bool skip = false; |
| 1113 | |
| 1114 | if (pCreateInfo != nullptr) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1115 | // Validate feature set if using CUBE_ARRAY |
| 1116 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) { |
| 1117 | skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004", |
| 1118 | "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without " |
| 1119 | "enabling the imageCubeArray feature."); |
| 1120 | } |
| 1121 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1122 | if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 1123 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) { |
| 1124 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960", |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1125 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.", |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1126 | pCreateInfo->subresourceRange.layerCount); |
| 1127 | } |
| 1128 | 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] | 1129 | skip |= LogError( |
| 1130 | device, "VUID-VkImageViewCreateInfo-viewType-02961", |
| 1131 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.", |
| 1132 | pCreateInfo->subresourceRange.layerCount); |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1133 | } |
| 1134 | } |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1135 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 1136 | auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext); |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1137 | if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) { |
| 1138 | if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) && |
| 1139 | (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) && |
| 1140 | (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) { |
| 1141 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230", |
| 1142 | "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be " |
| 1143 | "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32."); |
| 1144 | } |
| 1145 | if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) { |
| 1146 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084", |
| 1147 | "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and " |
| 1148 | "not an ASTC format.", |
| 1149 | string_VkFormat(pCreateInfo->format)); |
| 1150 | } |
| 1151 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1152 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 1153 | auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1154 | if (ycbcr_conversion != nullptr) { |
| 1155 | if (ycbcr_conversion->conversion != VK_NULL_HANDLE) { |
| 1156 | if (IsIdentitySwizzle(pCreateInfo->components) == false) { |
| 1157 | skip |= LogError( |
| 1158 | device, "VUID-VkImageViewCreateInfo-pNext-01970", |
| 1159 | "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must " |
| 1160 | "be created with the identity swizzle. Here are the actual swizzle values:\n" |
| 1161 | "r swizzle = %s\n" |
| 1162 | "g swizzle = %s\n" |
| 1163 | "b swizzle = %s\n" |
| 1164 | "a swizzle = %s\n", |
| 1165 | string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g), |
| 1166 | string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a)); |
| 1167 | } |
| 1168 | } |
| 1169 | } |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1170 | } |
| 1171 | return skip; |
| 1172 | } |
| 1173 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1174 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1175 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1176 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1177 | |
| 1178 | // Note: for numerical correctness |
| 1179 | // - float comparisons should expect NaN (comparison always false). |
| 1180 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 1181 | |
| 1182 | 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] | 1183 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1184 | if (v1_f <= 0.0f) return true; |
| 1185 | |
| 1186 | float intpart; |
| 1187 | const float fract = modff(v1_f, &intpart); |
| 1188 | |
| 1189 | assert(std::numeric_limits<float>::radix == 2); |
| 1190 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 1191 | if (intpart >= u32_max_plus1) return false; |
| 1192 | |
| 1193 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1194 | if (v1_u32 < v2_u32) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1195 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1196 | } else if (v1_u32 == v2_u32 && fract == 0.0f) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1197 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1198 | } else { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1199 | return false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1200 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1201 | }; |
| 1202 | |
| 1203 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 1204 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 1205 | return (v1_f <= v2_f); |
| 1206 | }; |
| 1207 | |
| 1208 | // width |
| 1209 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1210 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1211 | |
| 1212 | if (!(viewport.width > 0.0f)) { |
| 1213 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1214 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 1215 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1216 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 1217 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1218 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 1219 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 1220 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | // height |
| 1224 | bool height_healthy = true; |
Mark Lobodzinski | a09ab94 | 2020-02-20 11:01:59 -0700 | [diff] [blame] | 1225 | const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1226 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1227 | |
| 1228 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1229 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1230 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 1231 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1232 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1233 | height_healthy = false; |
| 1234 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1235 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 1236 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 1237 | ").", |
| 1238 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | // x |
| 1242 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1243 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1244 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1245 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 1246 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1247 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1248 | } |
| 1249 | |
| 1250 | // x + width |
| 1251 | if (x_healthy && width_healthy) { |
| 1252 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1253 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1254 | skip |= LogError( |
| 1255 | object, "VUID-VkViewport-x-01232", |
| 1256 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1257 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 1258 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1259 | } |
| 1260 | } |
| 1261 | |
| 1262 | // y |
| 1263 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1264 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1265 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1266 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 1267 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1268 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1269 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1270 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1271 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 1272 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1273 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | // y + height |
| 1277 | if (y_healthy && height_healthy) { |
| 1278 | const float boundary = viewport.y + viewport.height; |
| 1279 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1280 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1281 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 1282 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1283 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 1284 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1285 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1286 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1287 | LogError(object, "VUID-VkViewport-y-01777", |
| 1288 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 1289 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 1290 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1291 | } |
| 1292 | } |
| 1293 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1294 | if (!device_extensions.vk_ext_depth_range_unrestricted) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1295 | // minDepth |
| 1296 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1297 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1298 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1299 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 1300 | "[0.0, 1.0] range.", |
| 1301 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | // maxDepth |
| 1305 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1306 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1307 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1308 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 1309 | "[0.0, 1.0] range.", |
| 1310 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | return skip; |
| 1315 | } |
| 1316 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1317 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1318 | VkShadingRatePaletteEntryNV shadingRate; |
| 1319 | uint32_t width; |
| 1320 | uint32_t height; |
| 1321 | }; |
| 1322 | |
| 1323 | // All palette entries with more than one pixel per fragment |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1324 | static SampleOrderInfo sample_order_infos[] = { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1325 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 1326 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 1327 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 1328 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 1329 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 1330 | {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] | 1331 | }; |
| 1332 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 1333 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1334 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1335 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1336 | SampleOrderInfo *sample_order_info; |
| 1337 | uint32_t info_idx = 0; |
| 1338 | for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) { |
| 1339 | if (sample_order_infos[info_idx].shadingRate == order->shadingRate) { |
| 1340 | sample_order_info = &sample_order_infos[info_idx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1341 | break; |
| 1342 | } |
| 1343 | } |
| 1344 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1345 | if (sample_order_info == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1346 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 1347 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 1348 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1349 | return skip; |
| 1350 | } |
| 1351 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1352 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1353 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1354 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 1355 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 1356 | ") must " |
| 1357 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 1358 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 1359 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1360 | } |
| 1361 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1362 | 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] | 1363 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 1364 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1365 | ") must " |
| 1366 | "be equal to the product of sampleCount (=%" PRIu32 |
| 1367 | "), the fragment width for shadingRate " |
| 1368 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1369 | order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1370 | } |
| 1371 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1372 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1373 | skip |= LogError( |
| 1374 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1375 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1376 | ") must " |
| 1377 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1378 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1379 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1380 | |
| 1381 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1382 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 1383 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 1384 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1385 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1386 | uint64_t sample_locations_mask = 0; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1387 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1388 | const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i]; |
| 1389 | if (sample_loc->pixelX >= sample_order_info->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1390 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 1391 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1392 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1393 | if (sample_loc->pixelY >= sample_order_info->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1394 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 1395 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1396 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1397 | if (sample_loc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1398 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 1399 | "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] | 1400 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1401 | uint32_t idx = |
| 1402 | sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY); |
| 1403 | sample_locations_mask |= 1ULL << idx; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1404 | } |
| 1405 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1406 | uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 1407 | if (sample_locations_mask != expected_mask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1408 | skip |= LogError( |
| 1409 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1410 | "The array pSampleLocations must contain exactly one entry for " |
| 1411 | "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] | 1412 | } |
| 1413 | |
| 1414 | return skip; |
| 1415 | } |
| 1416 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1417 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 1418 | uint32_t createInfoCount, |
| 1419 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1420 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1421 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1422 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1423 | |
| 1424 | if (pCreateInfos != nullptr) { |
| 1425 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1426 | bool has_dynamic_viewport = false; |
| 1427 | bool has_dynamic_scissor = false; |
| 1428 | bool has_dynamic_line_width = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1429 | bool has_dynamic_depth_bias = false; |
| 1430 | bool has_dynamic_blend_constant = false; |
| 1431 | bool has_dynamic_depth_bounds = false; |
| 1432 | bool has_dynamic_stencil_compare = false; |
| 1433 | bool has_dynamic_stencil_write = false; |
| 1434 | bool has_dynamic_stencil_reference = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1435 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1436 | bool has_dynamic_discard_rectangle_ext = false; |
| 1437 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1438 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1439 | bool has_dynamic_shading_rate_palette_nv = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1440 | bool has_dynamic_viewport_course_sample_order_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1441 | bool has_dynamic_line_stipple = false; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1442 | bool has_dynamic_cull_mode = false; |
| 1443 | bool has_dynamic_front_face = false; |
| 1444 | bool has_dynamic_primitive_topology = false; |
| 1445 | bool has_dynamic_viewport_with_count = false; |
| 1446 | bool has_dynamic_scissor_with_count = false; |
| 1447 | bool has_dynamic_vertex_input_binding_stride = false; |
| 1448 | bool has_dynamic_depth_test_enable = false; |
| 1449 | bool has_dynamic_depth_write_enable = false; |
| 1450 | bool has_dynamic_depth_compare_op = false; |
| 1451 | bool has_dynamic_depth_bounds_test_enable = false; |
| 1452 | bool has_dynamic_stencil_test_enable = false; |
| 1453 | bool has_dynamic_stencil_op = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 1454 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 1455 | skip |= |
| 1456 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377", |
| 1457 | "vkCreateGraphicsPipelines: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR"); |
| 1458 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1459 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1460 | const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState; |
| 1461 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1462 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1463 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1464 | if (has_dynamic_viewport == true) { |
| 1465 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1466 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the " |
| 1467 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1468 | i); |
| 1469 | } |
| 1470 | has_dynamic_viewport = true; |
| 1471 | } |
| 1472 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) { |
| 1473 | if (has_dynamic_scissor == true) { |
| 1474 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1475 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the " |
| 1476 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1477 | i); |
| 1478 | } |
| 1479 | has_dynamic_scissor = true; |
| 1480 | } |
| 1481 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) { |
| 1482 | if (has_dynamic_line_width == true) { |
| 1483 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1484 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the " |
| 1485 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1486 | i); |
| 1487 | } |
| 1488 | has_dynamic_line_width = true; |
| 1489 | } |
| 1490 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) { |
| 1491 | if (has_dynamic_depth_bias == true) { |
| 1492 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1493 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the " |
| 1494 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1495 | i); |
| 1496 | } |
| 1497 | has_dynamic_depth_bias = true; |
| 1498 | } |
| 1499 | if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) { |
| 1500 | if (has_dynamic_blend_constant == true) { |
| 1501 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1502 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the " |
| 1503 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1504 | i); |
| 1505 | } |
| 1506 | has_dynamic_blend_constant = true; |
| 1507 | } |
| 1508 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) { |
| 1509 | if (has_dynamic_depth_bounds == true) { |
| 1510 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1511 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the " |
| 1512 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1513 | i); |
| 1514 | } |
| 1515 | has_dynamic_depth_bounds = true; |
| 1516 | } |
| 1517 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) { |
| 1518 | if (has_dynamic_stencil_compare == true) { |
| 1519 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1520 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in " |
| 1521 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1522 | i); |
| 1523 | } |
| 1524 | has_dynamic_stencil_compare = true; |
| 1525 | } |
| 1526 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) { |
| 1527 | if (has_dynamic_stencil_write == true) { |
| 1528 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1529 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in " |
| 1530 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1531 | i); |
| 1532 | } |
| 1533 | has_dynamic_stencil_write = true; |
| 1534 | } |
| 1535 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) { |
| 1536 | if (has_dynamic_stencil_reference == true) { |
| 1537 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1538 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in " |
| 1539 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1540 | i); |
| 1541 | } |
| 1542 | has_dynamic_stencil_reference = true; |
| 1543 | } |
| 1544 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) { |
| 1545 | if (has_dynamic_viewport_w_scaling_nv == true) { |
| 1546 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1547 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice " |
| 1548 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1549 | i); |
| 1550 | } |
| 1551 | has_dynamic_viewport_w_scaling_nv = true; |
| 1552 | } |
| 1553 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) { |
| 1554 | if (has_dynamic_discard_rectangle_ext == true) { |
| 1555 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1556 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice " |
| 1557 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1558 | i); |
| 1559 | } |
| 1560 | has_dynamic_discard_rectangle_ext = true; |
| 1561 | } |
| 1562 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) { |
| 1563 | if (has_dynamic_sample_locations_ext == true) { |
| 1564 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1565 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in " |
| 1566 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1567 | i); |
| 1568 | } |
| 1569 | has_dynamic_sample_locations_ext = true; |
| 1570 | } |
| 1571 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) { |
| 1572 | if (has_dynamic_exclusive_scissor_nv == true) { |
| 1573 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1574 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in " |
| 1575 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1576 | i); |
| 1577 | } |
| 1578 | has_dynamic_exclusive_scissor_nv = true; |
| 1579 | } |
| 1580 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) { |
| 1581 | if (has_dynamic_shading_rate_palette_nv == true) { |
| 1582 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1583 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was " |
| 1584 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1585 | i); |
| 1586 | } |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1587 | has_dynamic_shading_rate_palette_nv = true; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1588 | } |
| 1589 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) { |
| 1590 | if (has_dynamic_viewport_course_sample_order_nv == true) { |
| 1591 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1592 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was " |
| 1593 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1594 | i); |
| 1595 | } |
| 1596 | has_dynamic_viewport_course_sample_order_nv = true; |
| 1597 | } |
| 1598 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) { |
| 1599 | if (has_dynamic_line_stipple == true) { |
| 1600 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1601 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the " |
| 1602 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1603 | i); |
| 1604 | } |
| 1605 | has_dynamic_line_stipple = true; |
| 1606 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1607 | if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) { |
| 1608 | if (has_dynamic_cull_mode) { |
| 1609 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1610 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the " |
| 1611 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1612 | i); |
| 1613 | } |
| 1614 | has_dynamic_cull_mode = true; |
| 1615 | } |
| 1616 | if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) { |
| 1617 | if (has_dynamic_front_face) { |
| 1618 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1619 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the " |
| 1620 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1621 | i); |
| 1622 | } |
| 1623 | has_dynamic_front_face = true; |
| 1624 | } |
| 1625 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) { |
| 1626 | if (has_dynamic_primitive_topology) { |
| 1627 | skip |= LogError( |
| 1628 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1629 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the " |
| 1630 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1631 | i); |
| 1632 | } |
| 1633 | has_dynamic_primitive_topology = true; |
| 1634 | } |
| 1635 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) { |
| 1636 | if (has_dynamic_viewport_with_count) { |
| 1637 | skip |= LogError( |
| 1638 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1639 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the " |
| 1640 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1641 | i); |
| 1642 | } |
| 1643 | has_dynamic_viewport_with_count = true; |
| 1644 | } |
| 1645 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) { |
| 1646 | if (has_dynamic_scissor_with_count) { |
| 1647 | skip |= LogError( |
| 1648 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1649 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the " |
| 1650 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1651 | i); |
| 1652 | } |
| 1653 | has_dynamic_scissor_with_count = true; |
| 1654 | } |
| 1655 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) { |
| 1656 | if (has_dynamic_vertex_input_binding_stride) { |
| 1657 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1658 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was " |
| 1659 | "listed twice in the " |
| 1660 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1661 | i); |
| 1662 | } |
| 1663 | has_dynamic_vertex_input_binding_stride = true; |
| 1664 | } |
| 1665 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) { |
| 1666 | if (has_dynamic_depth_test_enable) { |
| 1667 | skip |= LogError( |
| 1668 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1669 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the " |
| 1670 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1671 | i); |
| 1672 | } |
| 1673 | has_dynamic_depth_test_enable = true; |
| 1674 | } |
| 1675 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) { |
| 1676 | if (has_dynamic_depth_write_enable) { |
| 1677 | skip |= LogError( |
| 1678 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1679 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the " |
| 1680 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1681 | i); |
| 1682 | } |
| 1683 | has_dynamic_depth_write_enable = true; |
| 1684 | } |
| 1685 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) { |
| 1686 | if (has_dynamic_depth_compare_op) { |
| 1687 | skip |= |
| 1688 | LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1689 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the " |
| 1690 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1691 | i); |
| 1692 | } |
| 1693 | has_dynamic_depth_compare_op = true; |
| 1694 | } |
| 1695 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) { |
| 1696 | if (has_dynamic_depth_bounds_test_enable) { |
| 1697 | skip |= LogError( |
| 1698 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1699 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the " |
| 1700 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1701 | i); |
| 1702 | } |
| 1703 | has_dynamic_depth_bounds_test_enable = true; |
| 1704 | } |
| 1705 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) { |
| 1706 | if (has_dynamic_stencil_test_enable) { |
| 1707 | skip |= LogError( |
| 1708 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1709 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the " |
| 1710 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1711 | i); |
| 1712 | } |
| 1713 | has_dynamic_stencil_test_enable = true; |
| 1714 | } |
| 1715 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) { |
| 1716 | if (has_dynamic_stencil_op) { |
| 1717 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1718 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the " |
| 1719 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1720 | i); |
| 1721 | } |
| 1722 | has_dynamic_stencil_op = true; |
| 1723 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1724 | } |
| 1725 | } |
| 1726 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 1727 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1728 | if ((feedback_struct != nullptr) && |
| 1729 | (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1730 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668", |
| 1731 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 1732 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 1733 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
| 1734 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1735 | } |
| 1736 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1737 | // 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] | 1738 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1739 | // Collect active stages and other information |
| 1740 | // Only want to loop through pStages once |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1741 | uint32_t active_shaders = 0; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1742 | bool has_eval = false; |
| 1743 | bool has_control = false; |
| 1744 | if (pCreateInfos[i].pStages != nullptr) { |
| 1745 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 1746 | active_shaders |= pCreateInfos[i].pStages[stage_index].stage; |
| 1747 | |
| 1748 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 1749 | has_control = true; |
| 1750 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 1751 | has_eval = true; |
| 1752 | } |
| 1753 | |
| 1754 | skip |= validate_string( |
| 1755 | "vkCreateGraphicsPipelines", |
| 1756 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}), |
| 1757 | "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName); |
| 1758 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1759 | } |
| 1760 | |
| 1761 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
| 1762 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) { |
| 1763 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 1764 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 1765 | pCreateInfos[i].pTessellationState, |
| 1766 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1767 | "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
| 1768 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1769 | const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1770 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 1771 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1772 | skip |= validate_struct_pnext( |
| 1773 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
| 1774 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, |
| 1775 | ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info), |
| 1776 | allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion, |
| 1777 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 1778 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1779 | |
| 1780 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
| 1781 | pCreateInfos[i].pTessellationState->flags, |
| 1782 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 1783 | } |
| 1784 | |
| 1785 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) { |
| 1786 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 1787 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
| 1788 | pCreateInfos[i].pInputAssemblyState, |
| 1789 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1790 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 1791 | |
| 1792 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
| 1793 | pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1794 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1795 | |
| 1796 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
| 1797 | pCreateInfos[i].pInputAssemblyState->flags, |
| 1798 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 1799 | |
| 1800 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 1801 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
| 1802 | pCreateInfos[i].pInputAssemblyState->topology, |
| 1803 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 1804 | |
| 1805 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
| 1806 | pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable); |
| 1807 | } |
| 1808 | |
| 1809 | 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] | 1810 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1811 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1812 | if (pCreateInfos[i].pVertexInputState->flags != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1813 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 1814 | "vkCreateGraphicsPipelines: pararameter " |
| 1815 | "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.", |
| 1816 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1817 | } |
| 1818 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1819 | const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1820 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
| 1821 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 1822 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", |
| 1823 | pCreateInfos[i].pVertexInputState->pNext, 1, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1824 | allowed_structs_vk_pipeline_vertex_input_state_create_info, |
| 1825 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1826 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1827 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 1828 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 1829 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1830 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 1831 | skip |= |
| 1832 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 1833 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
| 1834 | pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount, |
| 1835 | &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
| 1836 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 1837 | |
| 1838 | skip |= validate_array( |
| 1839 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 1840 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 1841 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 1842 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 1843 | |
| 1844 | if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1845 | for (uint32_t vertex_binding_description_index = 0; |
| 1846 | vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount; |
| 1847 | ++vertex_binding_description_index) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1848 | skip |= validate_ranged_enum( |
| 1849 | "vkCreateGraphicsPipelines", |
| 1850 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 1851 | AllVkVertexInputRateEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1852 | pCreateInfos[i] |
| 1853 | .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index] |
| 1854 | .inputRate, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1855 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 1856 | } |
| 1857 | } |
| 1858 | |
| 1859 | if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1860 | for (uint32_t vertex_attribute_description_index = 0; |
| 1861 | vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount; |
| 1862 | ++vertex_attribute_description_index) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1863 | skip |= validate_ranged_enum( |
| 1864 | "vkCreateGraphicsPipelines", |
| 1865 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 1866 | AllVkFormatEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1867 | pCreateInfos[i] |
| 1868 | .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index] |
| 1869 | .format, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1870 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
| 1871 | } |
| 1872 | } |
| 1873 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1874 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1875 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 1876 | "vkCreateGraphicsPipelines: pararameter " |
| 1877 | "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is " |
| 1878 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1879 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1880 | } |
| 1881 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1882 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1883 | skip |= |
| 1884 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 1885 | "vkCreateGraphicsPipelines: pararameter " |
| 1886 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is " |
| 1887 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1888 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1889 | } |
| 1890 | |
| 1891 | std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1892 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 1893 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1894 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 1895 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1896 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 1897 | "vkCreateGraphicsPipelines: parameter " |
| 1898 | "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding " |
| 1899 | "(%" PRIu32 ") is not distinct.", |
| 1900 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1901 | } |
| 1902 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 1903 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1904 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1905 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 1906 | "vkCreateGraphicsPipelines: parameter " |
| 1907 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
| 1908 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1909 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1910 | } |
| 1911 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1912 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1913 | skip |= |
| 1914 | LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 1915 | "vkCreateGraphicsPipelines: parameter " |
| 1916 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
| 1917 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).", |
| 1918 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1919 | } |
| 1920 | } |
| 1921 | |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1922 | std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1923 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 1924 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1925 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 1926 | if (location_it != attribute_locations.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1927 | skip |= LogError( |
| 1928 | device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1929 | "vkCreateGraphicsPipelines: parameter " |
| 1930 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.", |
| 1931 | i, d, vertex_attrib_desc.location); |
| 1932 | } |
| 1933 | attribute_locations.insert(vertex_attrib_desc.location); |
| 1934 | |
| 1935 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 1936 | if (binding_it == vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1937 | skip |= LogError( |
| 1938 | device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1939 | "vkCreateGraphicsPipelines: parameter " |
| 1940 | " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist " |
| 1941 | "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.", |
| 1942 | i, d, vertex_attrib_desc.binding, i); |
| 1943 | } |
| 1944 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1945 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1946 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 1947 | "vkCreateGraphicsPipelines: parameter " |
| 1948 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
| 1949 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1950 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1951 | } |
| 1952 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1953 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1954 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 1955 | "vkCreateGraphicsPipelines: parameter " |
| 1956 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
| 1957 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1958 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1959 | } |
| 1960 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1961 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1962 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 1963 | "vkCreateGraphicsPipelines: parameter " |
| 1964 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 1965 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).", |
| 1966 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1967 | } |
| 1968 | } |
| 1969 | } |
| 1970 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1971 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 1972 | if (has_control && has_eval) { |
| 1973 | if (pCreateInfos[i].pTessellationState == nullptr) { |
| 1974 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
| 1975 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 1976 | "shader stage and a tessellation evaluation shader stage, " |
| 1977 | "pCreateInfos[%d].pTessellationState must not be NULL.", |
| 1978 | i, i); |
| 1979 | } else { |
| 1980 | const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
| 1981 | skip |= validate_struct_pnext( |
| 1982 | "vkCreateGraphicsPipelines", |
| 1983 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
| 1984 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1, |
| 1985 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 1986 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1987 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1988 | skip |= validate_reserved_flags( |
| 1989 | "vkCreateGraphicsPipelines", |
| 1990 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
| 1991 | pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1992 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1993 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
| 1994 | pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
| 1995 | skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 1996 | "vkCreateGraphicsPipelines: invalid parameter " |
| 1997 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
| 1998 | "should be >0 and <=%u.", |
| 1999 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
| 2000 | device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2001 | } |
| 2002 | } |
| 2003 | } |
| 2004 | |
| 2005 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 2006 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 2007 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 2008 | if (pCreateInfos[i].pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2009 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 2010 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 2011 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 2012 | "].pViewportState (=NULL) is not a valid pointer.", |
| 2013 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2014 | } else { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2015 | const auto &viewport_state = *pCreateInfos[i].pViewportState; |
| 2016 | |
| 2017 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2018 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 2019 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2020 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 2021 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2022 | } |
| 2023 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2024 | const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2025 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2026 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 2027 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2028 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 2029 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2030 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2031 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2032 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2033 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2034 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 2035 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
| 2036 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2037 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info), |
| 2038 | allowed_structs_vk_pipeline_viewport_state_create_info, 65, |
| 2039 | "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2040 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2041 | |
| 2042 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2043 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2044 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2045 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2046 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2047 | auto exclusive_scissor_struct = |
| 2048 | LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
| 2049 | auto shading_rate_image_struct = |
| 2050 | LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
| 2051 | auto coarse_sample_order_struct = |
| 2052 | LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2053 | const auto vp_swizzle_struct = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2054 | LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2055 | const auto vp_w_scaling_struct = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2056 | LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2057 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2058 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2059 | if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2060 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 2061 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2062 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 2063 | ") is not 1.", |
| 2064 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2065 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2066 | |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2067 | if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2068 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 2069 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2070 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2071 | ") is not 1.", |
| 2072 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2073 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2074 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2075 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 2076 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2077 | skip |= LogError( |
| 2078 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 2079 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2080 | "disabled, but pCreateInfos[%" PRIu32 |
| 2081 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 2082 | ") is not 1.", |
| 2083 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2084 | } |
| 2085 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2086 | if (shading_rate_image_struct && |
| 2087 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2088 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 2089 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2090 | "disabled, but pCreateInfos[%" PRIu32 |
| 2091 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 2092 | ") is neither 0 nor 1.", |
| 2093 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2094 | } |
| 2095 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2096 | } else { // multiViewport enabled |
| 2097 | if (viewport_state.viewportCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2098 | if (!has_dynamic_viewport_with_count) { |
| 2099 | skip |= LogError( |
| 2100 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
| 2101 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
| 2102 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2103 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2104 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 2105 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2106 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2107 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2108 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2109 | } else if (has_dynamic_viewport_with_count) { |
| 2110 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379", |
| 2111 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2112 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2113 | ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.", |
| 2114 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2115 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2116 | |
| 2117 | if (viewport_state.scissorCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2118 | if (!has_dynamic_scissor_with_count) { |
| 2119 | skip |= LogError( |
| 2120 | device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength", |
| 2121 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
| 2122 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2123 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2124 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 2125 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2126 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2127 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2128 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2129 | } else if (has_dynamic_scissor_with_count) { |
| 2130 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380", |
| 2131 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2132 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2133 | ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.", |
| 2134 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2135 | } |
| 2136 | } |
| 2137 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2138 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2139 | skip |= |
| 2140 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 2141 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2142 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2143 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2144 | } |
| 2145 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2146 | 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] | 2147 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 2148 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2149 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2150 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2151 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2152 | } |
| 2153 | |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2154 | if (viewport_state.scissorCount != viewport_state.viewportCount && |
| 2155 | !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2156 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220", |
| 2157 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2158 | "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32 |
| 2159 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2160 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2161 | } |
| 2162 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2163 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2164 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2165 | skip |= |
| 2166 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 2167 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2168 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 2169 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2170 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2171 | } |
| 2172 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2173 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2174 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2175 | skip |= LogError( |
| 2176 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2177 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 2178 | "] " |
| 2179 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2180 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2181 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2182 | } |
| 2183 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2184 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2185 | skip |= LogError( |
| 2186 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2187 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 2188 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2189 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 2190 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2191 | } |
| 2192 | |
| 2193 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2194 | skip |= LogError( |
| 2195 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2196 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 2197 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2198 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 2199 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2200 | } |
| 2201 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2202 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2203 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 2204 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 2205 | skip |= |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2206 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2207 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 2208 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 2209 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 2210 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2211 | } |
| 2212 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2213 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2214 | shading_rate_image_struct->viewportCount > 0 && |
| 2215 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2216 | skip |= LogError( |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2217 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2218 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2219 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 2220 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2221 | i, i); |
| 2222 | } |
| 2223 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2224 | if (vp_swizzle_struct) { |
| 2225 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2226 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 2227 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 2228 | " does " |
| 2229 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 2230 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2231 | } |
| 2232 | } |
| 2233 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2234 | // validate the VkViewports |
| 2235 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 2236 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 2237 | 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] | 2238 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 2239 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 2240 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 2241 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2242 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2243 | } |
| 2244 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2245 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2246 | if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2247 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2248 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2249 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 2250 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 2251 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2252 | } |
| 2253 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2254 | if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2255 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2256 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2257 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 2258 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 2259 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2260 | } |
| 2261 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2262 | if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2263 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2264 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2265 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 2266 | "VK_EXT_sample_locations extension is not enabled.", |
| 2267 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2268 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2269 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2270 | if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2271 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2272 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2273 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 2274 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 2275 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2276 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2277 | |
| 2278 | if (coarse_sample_order_struct && |
| 2279 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 2280 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2281 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 2282 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2283 | "] " |
| 2284 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 2285 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 2286 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2287 | } |
| 2288 | |
| 2289 | if (coarse_sample_order_struct) { |
| 2290 | 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] | 2291 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2292 | } |
| 2293 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2294 | |
| 2295 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 2296 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2297 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 2298 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2299 | "] " |
| 2300 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 2301 | ") " |
| 2302 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 2303 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2304 | } |
| 2305 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2306 | skip |= LogError( |
| 2307 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2308 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2309 | "] " |
| 2310 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 2311 | i); |
| 2312 | } |
| 2313 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2314 | } |
| 2315 | |
| 2316 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2317 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
| 2318 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 2319 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.", |
| 2320 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2321 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2322 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 2323 | LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType, |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2324 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 2325 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 2326 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2327 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2328 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2329 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2330 | "vkCreateGraphicsPipelines", |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2331 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 2332 | valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2333 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 2334 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2335 | |
| 2336 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2337 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2338 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2339 | pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2340 | |
| 2341 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2342 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2343 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 2344 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 2345 | |
| 2346 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2347 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2348 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2349 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2350 | pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2351 | true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2352 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2353 | skip |= validate_flags( |
| 2354 | "vkCreateGraphicsPipelines", |
| 2355 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2356 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2357 | kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2358 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2359 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2360 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2361 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 2362 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 2363 | |
| 2364 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2365 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2366 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 2367 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 2368 | |
| 2369 | 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] | 2370 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2371 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 2372 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 2373 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2374 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2375 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2376 | if (!physical_device_features.sampleRateShading) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2377 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 2378 | "vkCreateGraphicsPipelines(): parameter " |
| 2379 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.", |
| 2380 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2381 | } |
| 2382 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 2383 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
| 2384 | if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2385 | skip |= LogError( |
| 2386 | device, |
| 2387 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2388 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2389 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2390 | } |
| 2391 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2392 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2393 | const auto *line_state = |
| 2394 | LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2395 | |
| 2396 | if (line_state) { |
| 2397 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 2398 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
| 2399 | if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) { |
| 2400 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2401 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2402 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2403 | "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
| 2404 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2405 | } |
| 2406 | if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) { |
| 2407 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2408 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2409 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2410 | "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
| 2411 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2412 | } |
| 2413 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) { |
| 2414 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2415 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2416 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2417 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
| 2418 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2419 | } |
| 2420 | } |
| 2421 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 2422 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 2423 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2424 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
| 2425 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the " |
| 2426 | "range [1,256].", |
| 2427 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2428 | } |
| 2429 | } |
| 2430 | const auto *line_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2431 | LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2432 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2433 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2434 | skip |= |
| 2435 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
| 2436 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2437 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 2438 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2439 | } |
| 2440 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2441 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2442 | skip |= |
| 2443 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
| 2444 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2445 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 2446 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2447 | } |
| 2448 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2449 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2450 | skip |= |
| 2451 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
| 2452 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2453 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 2454 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2455 | } |
| 2456 | if (line_state->stippledLineEnable) { |
| 2457 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2458 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2459 | skip |= |
| 2460 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
| 2461 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2462 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 2463 | "stippledRectangularLines feature.", |
| 2464 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2465 | } |
| 2466 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2467 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2468 | skip |= |
| 2469 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
| 2470 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2471 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 2472 | "stippledBresenhamLines feature.", |
| 2473 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2474 | } |
| 2475 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2476 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2477 | skip |= |
| 2478 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
| 2479 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2480 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 2481 | "stippledSmoothLines feature.", |
| 2482 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2483 | } |
| 2484 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
| 2485 | (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2486 | skip |= |
| 2487 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
| 2488 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2489 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 2490 | "stippledRectangularLines and strictLines features.", |
| 2491 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2492 | } |
| 2493 | } |
| 2494 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2495 | } |
| 2496 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2497 | bool uses_color_attachment = false; |
| 2498 | bool uses_depthstencil_attachment = false; |
| 2499 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2500 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2501 | const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass); |
| 2502 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2503 | const auto &subpasses_uses = subpasses_uses_it->second; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2504 | if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2505 | uses_color_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2506 | } |
| 2507 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2508 | uses_depthstencil_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2509 | } |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2510 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2511 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2512 | } |
| 2513 | |
| 2514 | if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2515 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2516 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2517 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2518 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2519 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2520 | |
| 2521 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2522 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2523 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2524 | pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2525 | |
| 2526 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2527 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2528 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 2529 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 2530 | |
| 2531 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2532 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2533 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 2534 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 2535 | |
| 2536 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2537 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2538 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 2539 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2540 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2541 | |
| 2542 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2543 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2544 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 2545 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 2546 | |
| 2547 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2548 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2549 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 2550 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 2551 | |
| 2552 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2553 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2554 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 2555 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2556 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2557 | |
| 2558 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2559 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2560 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 2561 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2562 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2563 | |
| 2564 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2565 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2566 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 2567 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2568 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2569 | |
| 2570 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2571 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2572 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 2573 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2574 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2575 | |
| 2576 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2577 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2578 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
| 2579 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2580 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2581 | |
| 2582 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2583 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2584 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
| 2585 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2586 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2587 | |
| 2588 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2589 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2590 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 2591 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2592 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2593 | |
| 2594 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2595 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2596 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 2597 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2598 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2599 | |
| 2600 | 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] | 2601 | skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2602 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 2603 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 2604 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2605 | } |
| 2606 | } |
| 2607 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2608 | const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = { |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2609 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT}; |
| 2610 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2611 | if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2612 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 2613 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 2614 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2615 | pCreateInfos[i].pColorBlendState, |
| 2616 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2617 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
| 2618 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2619 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2620 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2621 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
| 2622 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2623 | ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info), |
| 2624 | allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2625 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 2626 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2627 | |
| 2628 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2629 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2630 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2631 | pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2632 | |
| 2633 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2634 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2635 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 2636 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 2637 | |
| 2638 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2639 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2640 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 2641 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2642 | pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2643 | true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2644 | |
| 2645 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2646 | for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 2647 | ++attachment_index) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2648 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2649 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2650 | ParameterName::IndexVector{i, attachment_index}), |
| 2651 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2652 | |
| 2653 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2654 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2655 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2656 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2657 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2658 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2659 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2660 | |
| 2661 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2662 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2663 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2664 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2665 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2666 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2667 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2668 | |
| 2669 | skip |= validate_ranged_enum( |
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].pColorBlendState->pAttachments[%i].colorBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2672 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2673 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2674 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2675 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2676 | |
| 2677 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2678 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2679 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2680 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2681 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2682 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2683 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2684 | |
| 2685 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2686 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2687 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2688 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2689 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2690 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2691 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2692 | |
| 2693 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2694 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2695 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2696 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2697 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2698 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2699 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2700 | |
| 2701 | skip |= |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2702 | validate_flags("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2703 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2704 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2705 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2706 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2707 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2708 | } |
| 2709 | } |
| 2710 | |
| 2711 | 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] | 2712 | skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2713 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 2714 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2715 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2716 | } |
| 2717 | |
| 2718 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 2719 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 2720 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2721 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2722 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2723 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, |
| 2724 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2725 | } |
| 2726 | } |
| 2727 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2728 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2729 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 2730 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 2731 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2732 | skip |= |
| 2733 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2734 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2735 | "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] | 2736 | "and pCreateInfos->basePipelineIndex is not -1.", |
| 2737 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2738 | } |
| 2739 | } |
| 2740 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2741 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 2742 | if (pCreateInfos[i].basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2743 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2744 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2745 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2746 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 2747 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2748 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2749 | } else { |
Mike Schuchardt | e5c15cf | 2020-04-06 22:57:13 -0700 | [diff] [blame] | 2750 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2751 | skip |= |
| 2752 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
| 2753 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid" |
| 2754 | "index into the pCreateInfos array, of size %d.", |
| 2755 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2756 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2757 | } |
| 2758 | } |
| 2759 | |
sfricke-samsung | 898cf22 | 2020-05-15 23:10:19 -0700 | [diff] [blame] | 2760 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) { |
| 2761 | skip |= LogError( |
| 2762 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764", |
| 2763 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE", |
| 2764 | i); |
| 2765 | } |
| 2766 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2767 | if (pCreateInfos[i].pRasterizationState) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2768 | if (!device_extensions.vk_nv_fill_rectangle) { |
| 2769 | if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
| 2770 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2771 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 2772 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 2773 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 2774 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2775 | } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2776 | (physical_device_features.fillModeNonSolid == false)) { |
sfricke-samsung | a44586f | 2020-08-23 22:19:44 -0700 | [diff] [blame] | 2777 | skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2778 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2779 | "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
| 2780 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2781 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2782 | } |
| 2783 | } else { |
| 2784 | if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2785 | (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
| 2786 | (physical_device_features.fillModeNonSolid == false)) { |
| 2787 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2788 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 2789 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2790 | "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
| 2791 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2792 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2793 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2794 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2795 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2796 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2797 | (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2798 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 2799 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 2800 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 2801 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 2802 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
| 2803 | i, i, pCreateInfos[i].pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2804 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2805 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2806 | } |
| 2807 | } |
| 2808 | |
| 2809 | return skip; |
| 2810 | } |
| 2811 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2812 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 2813 | uint32_t createInfoCount, |
| 2814 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 2815 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2816 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2817 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2818 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2819 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2820 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 2821 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2822 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2823 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2824 | skip |= |
| 2825 | LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669", |
| 2826 | "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32 |
| 2827 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".", |
| 2828 | i, feedback_struct->pipelineStageCreationFeedbackCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2829 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2830 | |
| 2831 | // Make sure compute stage is selected |
| 2832 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2833 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
| 2834 | "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
| 2835 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2836 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2837 | |
| 2838 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 2839 | skip |= |
| 2840 | LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370", |
| 2841 | "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR"); |
| 2842 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2843 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2844 | return skip; |
| 2845 | } |
| 2846 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2847 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2848 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2849 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2850 | |
| 2851 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2852 | const auto &features = physical_device_features; |
| 2853 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2854 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2855 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 2856 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2857 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 2858 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 2859 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 2860 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2861 | } |
| 2862 | |
| 2863 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 2864 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2865 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 2866 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 2867 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2868 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2869 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2870 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2871 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 2872 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2873 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 2874 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2875 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2876 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2877 | } |
| 2878 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2879 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 2880 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2881 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 2882 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2883 | } |
| 2884 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2885 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 2886 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2887 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 2888 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2889 | } |
| 2890 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2891 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2892 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2893 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2894 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 2895 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2896 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 2897 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 2898 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 2899 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2900 | } |
| 2901 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2902 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 2903 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2904 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2905 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2906 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2907 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 2908 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2909 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2910 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2911 | } |
| 2912 | |
| 2913 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 2914 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2915 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 2916 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2917 | const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 2918 | if (sampler_reduction != nullptr) { |
| 2919 | if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
| 2920 | skip |= LogError( |
| 2921 | device, "VUID-VkSamplerCreateInfo-compareEnable-01423", |
| 2922 | "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE."); |
| 2923 | } |
| 2924 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2925 | } |
| 2926 | |
| 2927 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 2928 | // valid VkBorderColor value |
| 2929 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2930 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2931 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2932 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 2933 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2934 | } |
| 2935 | |
| 2936 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the |
| 2937 | // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2938 | if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2939 | ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2940 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2941 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2942 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2943 | LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079", |
| 2944 | "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE " |
| 2945 | "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2946 | } |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2947 | |
| 2948 | // Checks for the IMG cubic filtering extension |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2949 | if (device_extensions.vk_img_filter_cubic) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2950 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 2951 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2952 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 2953 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 2954 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2955 | } |
| 2956 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2957 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2958 | // Check for valid Lod range |
| 2959 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2960 | skip |= |
| 2961 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 2962 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2963 | } |
| 2964 | |
| 2965 | // Check mipLodBias to device limit |
| 2966 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2967 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 2968 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 2969 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2970 | } |
| 2971 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 2972 | const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2973 | if (sampler_conversion != nullptr) { |
| 2974 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2975 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2976 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2977 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2978 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2979 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2980 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 2981 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 2982 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 2983 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 2984 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 2985 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 2986 | } |
| 2987 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 2988 | |
| 2989 | if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) { |
| 2990 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
| 2991 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574", |
| 2992 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2993 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2994 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
| 2995 | } |
| 2996 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
| 2997 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575", |
| 2998 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2999 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 3000 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
| 3001 | } |
| 3002 | if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) { |
| 3003 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576", |
| 3004 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3005 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.", |
| 3006 | pCreateInfo->minLod, pCreateInfo->maxLod); |
| 3007 | } |
| 3008 | if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3009 | (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) || |
| 3010 | ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3011 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) { |
| 3012 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577", |
| 3013 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3014 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be " |
| 3015 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER", |
| 3016 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 3017 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
| 3018 | } |
| 3019 | if (pCreateInfo->anisotropyEnable) { |
| 3020 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578", |
| 3021 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3022 | "pCreateInfo->anisotropyEnable must be VK_FALSE"); |
| 3023 | } |
| 3024 | if (pCreateInfo->compareEnable) { |
| 3025 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579", |
| 3026 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3027 | "pCreateInfo->compareEnable must be VK_FALSE"); |
| 3028 | } |
| 3029 | if (pCreateInfo->unnormalizedCoordinates) { |
| 3030 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580", |
| 3031 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3032 | "pCreateInfo->unnormalizedCoordinates must be VK_FALSE"); |
| 3033 | } |
| 3034 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3035 | } |
| 3036 | |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3037 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 3038 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
| 3039 | if (!device_extensions.vk_ext_custom_border_color) { |
| 3040 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 3041 | "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n", |
| 3042 | string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 3043 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3044 | auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext); |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3045 | if (!custom_create_info) { |
| 3046 | skip |= |
| 3047 | LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011", |
| 3048 | "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT " |
| 3049 | "struct in pNext chain.\n", |
| 3050 | string_VkBorderColor(pCreateInfo->borderColor)); |
| 3051 | } else { |
| 3052 | if ((custom_create_info->format != VK_FORMAT_UNDEFINED) && |
| 3053 | ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) || |
| 3054 | (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT && |
| 3055 | !FormatIsSampledFloat(custom_create_info->format)))) { |
| 3056 | skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013", |
| 3057 | "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s " |
| 3058 | "whose type does not match\n", |
| 3059 | string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format)); |
| 3060 | ; |
| 3061 | } |
| 3062 | } |
| 3063 | } |
| 3064 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3065 | return skip; |
| 3066 | } |
| 3067 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3068 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 3069 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 3070 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3071 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3072 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3073 | |
| 3074 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3075 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 3076 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 3077 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3078 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3079 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 3080 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 3081 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 3082 | ++descriptor_index) { |
| 3083 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Spencer Fricke | b0e3082 | 2020-03-23 10:32:30 -0700 | [diff] [blame] | 3084 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3085 | "vkCreateDescriptorSetLayout: required parameter " |
| 3086 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE", |
| 3087 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3088 | } |
| 3089 | } |
| 3090 | } |
| 3091 | |
| 3092 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 3093 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3094 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3095 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
| 3096 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 3097 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits " |
| 3098 | "values.", |
| 3099 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3100 | } |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 3101 | |
| 3102 | if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) && |
| 3103 | (pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3104 | (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) { |
| 3105 | skip |= |
| 3106 | LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510", |
| 3107 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and " |
| 3108 | "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags " |
| 3109 | "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s", |
| 3110 | i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str()); |
| 3111 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3112 | } |
| 3113 | } |
| 3114 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3115 | return skip; |
| 3116 | } |
| 3117 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3118 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 3119 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3120 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3121 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3122 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3123 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3124 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 3125 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3126 | } |
| 3127 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3128 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 3129 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3130 | const bool validateDstSet) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3131 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3132 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3133 | if (pDescriptorWrites != NULL) { |
| 3134 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 3135 | // descriptorCount must be greater than 0 |
| 3136 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 3137 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3138 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 3139 | "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3140 | } |
| 3141 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3142 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
| 3143 | if (validateDstSet) { |
| 3144 | // dstSet must be a valid VkDescriptorSet handle |
| 3145 | skip |= validate_required_handle(vkCallingFunction, |
| 3146 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 3147 | pDescriptorWrites[i].dstSet); |
| 3148 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3149 | |
| 3150 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3151 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 3152 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 3153 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 3154 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 3155 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 3156 | // 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] | 3157 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures. |
| 3158 | // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3159 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3160 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322", |
| 3161 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3162 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 3163 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 3164 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.", |
| 3165 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3166 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 3167 | // 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] | 3168 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout |
| 3169 | // member of any given element of pImageInfo must be a valid VkImageLayout |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3170 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 3171 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3172 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3173 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 3174 | ParameterName::IndexVector{i, descriptor_index}), |
| 3175 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3176 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3177 | } |
| 3178 | } |
| 3179 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3180 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3181 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 3182 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 3183 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 3184 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 3185 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3186 | // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3187 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3188 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
| 3189 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3190 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 3191 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
| 3192 | "pDescriptorWrites[%d].pBufferInfo must not be NULL.", |
| 3193 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3194 | } else { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3195 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3196 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3197 | if (robustness2_features && robustness2_features->nullDescriptor) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3198 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 3199 | ++descriptor_index) { |
| 3200 | if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE && |
| 3201 | (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 || |
| 3202 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3203 | skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999", |
| 3204 | "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, " |
baldurk | 751594b | 2020-09-09 09:41:02 +0100 | [diff] [blame] | 3205 | "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] | 3206 | vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset, |
| 3207 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3208 | } |
| 3209 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3210 | } |
| 3211 | } |
| 3212 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 3213 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3214 | // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3215 | } |
| 3216 | |
| 3217 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3218 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3219 | VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3220 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3221 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3222 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3223 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3224 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
| 3225 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3226 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3227 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3228 | } |
| 3229 | } |
| 3230 | } |
| 3231 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3232 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3233 | VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3234 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3235 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3236 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3237 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3238 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
| 3239 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3240 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3241 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3242 | } |
| 3243 | } |
| 3244 | } |
| 3245 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3246 | // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR |
| 3247 | // or VkWriteDescriptorSetInlineUniformBlockEX |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3248 | if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3249 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3250 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 3251 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382", |
| 3252 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext" |
| 3253 | "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose " |
| 3254 | "accelerationStructureCount %d member equals descriptorCount %d.", |
| 3255 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 3256 | pDescriptorWrites[i].descriptorCount); |
| 3257 | } |
| 3258 | // further checks only if we have right structtype |
| 3259 | if (pnext_struct) { |
| 3260 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 3261 | skip |= LogError( |
| 3262 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236", |
| 3263 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 3264 | ".", |
| 3265 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3266 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3267 | if (pnext_struct->accelerationStructureCount == 0) { |
| 3268 | skip |= LogError(device, |
| 3269 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength", |
| 3270 | "%s(): accelerationStructureCount must be greater than 0 ."); |
| 3271 | } |
| 3272 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3273 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3274 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 3275 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 3276 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 3277 | skip |= LogError(device, |
| 3278 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580", |
| 3279 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
| 3280 | "pAccelerationStructures must not be VK_NULL_HANDLE."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3281 | } |
| 3282 | } |
| 3283 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3284 | } |
| 3285 | } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3286 | const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3287 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 3288 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817", |
| 3289 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext" |
| 3290 | "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose " |
| 3291 | "accelerationStructureCount %d member equals descriptorCount %d.", |
| 3292 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 3293 | pDescriptorWrites[i].descriptorCount); |
| 3294 | } |
| 3295 | // further checks only if we have right structtype |
| 3296 | if (pnext_struct) { |
| 3297 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 3298 | skip |= LogError( |
| 3299 | device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747", |
| 3300 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 3301 | ".", |
| 3302 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3303 | } |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3304 | if (pnext_struct->accelerationStructureCount == 0) { |
| 3305 | skip |= LogError(device, |
| 3306 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength", |
| 3307 | "%s(): accelerationStructureCount must be greater than 0 ."); |
| 3308 | } |
| 3309 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3310 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
sourav parmar | bcee751 | 2020-12-28 14:34:49 -0800 | [diff] [blame] | 3311 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 3312 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 3313 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 3314 | skip |= LogError(device, |
| 3315 | "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749", |
| 3316 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
| 3317 | "pAccelerationStructures must not be VK_NULL_HANDLE."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3318 | } |
| 3319 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3320 | } |
| 3321 | } |
| 3322 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3323 | } |
| 3324 | } |
| 3325 | return skip; |
| 3326 | } |
| 3327 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3328 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 3329 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3330 | uint32_t descriptorCopyCount, |
| 3331 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
| 3332 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites); |
| 3333 | } |
| 3334 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3335 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3336 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3337 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3338 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 3339 | } |
| 3340 | |
sfricke-samsung | 681ab7b | 2020-10-29 01:53:35 -0700 | [diff] [blame] | 3341 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
| 3342 | const VkAllocationCallbacks *pAllocator, |
| 3343 | VkRenderPass *pRenderPass) const { |
| 3344 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 3345 | } |
| 3346 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3347 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3348 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3349 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3350 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 3351 | } |
| 3352 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3353 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 3354 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3355 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3356 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3357 | |
| 3358 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3359 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3360 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3361 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 3362 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3363 | return skip; |
| 3364 | } |
| 3365 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3366 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3367 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3368 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3369 | |
| 3370 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 3371 | const char *cmd_name = "vkBeginCommandBuffer"; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3372 | bool cb_is_secondary; |
| 3373 | { |
| 3374 | auto lock = cb_read_lock(); |
| 3375 | cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end()); |
| 3376 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3377 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3378 | if (cb_is_secondary) { |
| 3379 | // Implicit VUs |
| 3380 | // validate only sType here; pointer has to be validated in core_validation |
| 3381 | const bool k_not_required = false; |
| 3382 | const char *k_no_vuid = nullptr; |
| 3383 | const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo; |
| 3384 | 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^] | 3385 | info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid, |
| 3386 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3387 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3388 | if (info) { |
| 3389 | const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3390 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT}; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3391 | skip |= validate_struct_pnext( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3392 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", |
| 3393 | info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info), |
| 3394 | allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion, |
| 3395 | "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3396 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3397 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3398 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3399 | // Explicit VUs |
| 3400 | if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3401 | skip |= LogError( |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3402 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
| 3403 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 3404 | cmd_name); |
| 3405 | } |
| 3406 | |
| 3407 | if (physical_device_features.inheritedQueries) { |
| 3408 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3409 | AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags, |
| 3410 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
| 3411 | } else { // !inheritedQueries |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3412 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3413 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3414 | } |
| 3415 | |
| 3416 | if (physical_device_features.pipelineStatisticsQuery) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3417 | skip |= |
| 3418 | validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
| 3419 | AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags, |
| 3420 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
| 3421 | } else { // !pipelineStatisticsQuery |
| 3422 | skip |= |
| 3423 | validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics, |
| 3424 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3425 | } |
| 3426 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3427 | const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3428 | if (conditional_rendering) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3429 | const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3430 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 3431 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
| 3432 | skip |= LogError( |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3433 | commandBuffer, |
| 3434 | "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 3435 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 3436 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 3437 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 3438 | } |
| 3439 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3440 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3441 | return skip; |
| 3442 | } |
| 3443 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3444 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3445 | uint32_t viewportCount, const VkViewport *pViewports) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3446 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3447 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3448 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3449 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3450 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 3451 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 3452 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3453 | } |
| 3454 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3455 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 3456 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 3457 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3458 | } |
| 3459 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 3460 | 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] | 3461 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3462 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 3463 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3464 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3465 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3466 | } |
| 3467 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3468 | |
| 3469 | if (pViewports) { |
| 3470 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 3471 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 3472 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3473 | skip |= manual_PreCallValidateViewport( |
| 3474 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3475 | } |
| 3476 | } |
| 3477 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3478 | return skip; |
| 3479 | } |
| 3480 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3481 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3482 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3483 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3484 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3485 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3486 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3487 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 3488 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 3489 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3490 | } |
| 3491 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3492 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 3493 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 3494 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3495 | } |
| 3496 | } else { // multiViewport enabled |
| 3497 | 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] | 3498 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3499 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 3500 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3501 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3502 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3503 | } |
| 3504 | } |
| 3505 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3506 | if (pScissors) { |
| 3507 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 3508 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3509 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3510 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3511 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3512 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 3513 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3514 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3515 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3516 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3517 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3518 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 3519 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3520 | } |
| 3521 | |
| 3522 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 3523 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3524 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 3525 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3526 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3527 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3528 | } |
| 3529 | |
| 3530 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 3531 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3532 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 3533 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3534 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3535 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3536 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3537 | } |
| 3538 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3539 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3540 | return skip; |
| 3541 | } |
| 3542 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3543 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3544 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3545 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3546 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3547 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 3548 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3549 | } |
| 3550 | |
| 3551 | return skip; |
| 3552 | } |
| 3553 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3554 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3555 | uint32_t drawCount, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3556 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3557 | |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3558 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 41ce65b | 2020-10-30 12:17:06 -0600 | [diff] [blame] | 3559 | skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718", |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3560 | "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount); |
| 3561 | } |
| 3562 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 3563 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3564 | "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount, |
| 3565 | device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3566 | } |
| 3567 | return skip; |
| 3568 | } |
| 3569 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3570 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3571 | VkDeviceSize offset, uint32_t drawCount, |
| 3572 | uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3573 | bool skip = false; |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3574 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3575 | skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718", |
| 3576 | "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", |
| 3577 | drawCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3578 | } |
| 3579 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 3580 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3581 | "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", |
| 3582 | drawCount, device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3583 | } |
| 3584 | return skip; |
| 3585 | } |
| 3586 | |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3587 | bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3588 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3589 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3590 | const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3591 | if (offset & 3) { |
| 3592 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3593 | "%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] | 3594 | } |
| 3595 | |
| 3596 | if (countBufferOffset & 3) { |
| 3597 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3598 | "%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] | 3599 | countBufferOffset); |
| 3600 | } |
| 3601 | return skip; |
| 3602 | } |
| 3603 | |
| 3604 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3605 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3606 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3607 | uint32_t stride) const { |
| 3608 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3609 | } |
| 3610 | |
| 3611 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3612 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3613 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3614 | uint32_t stride) const { |
| 3615 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3616 | } |
| 3617 | |
| 3618 | bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3619 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3620 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3621 | const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3622 | if (offset & 3) { |
| 3623 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3624 | "%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] | 3625 | } |
| 3626 | |
| 3627 | if (countBufferOffset & 3) { |
| 3628 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3629 | "%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] | 3630 | countBufferOffset); |
| 3631 | } |
| 3632 | return skip; |
| 3633 | } |
| 3634 | |
| 3635 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3636 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3637 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3638 | uint32_t stride) const { |
| 3639 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3640 | } |
| 3641 | |
| 3642 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3643 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3644 | VkDeviceSize countBufferOffset, |
| 3645 | uint32_t maxDrawCount, uint32_t stride) const { |
| 3646 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3647 | } |
| 3648 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3649 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 3650 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3651 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3652 | bool skip = false; |
| 3653 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 3654 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3655 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
| 3656 | "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3657 | } |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 3658 | if (pRects[rect].rect.extent.width == 0) { |
| 3659 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682", |
| 3660 | "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect); |
| 3661 | } |
| 3662 | if (pRects[rect].rect.extent.height == 0) { |
| 3663 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683", |
| 3664 | "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect); |
| 3665 | } |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3666 | } |
| 3667 | return skip; |
| 3668 | } |
| 3669 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3670 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 3671 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3672 | VkImageFormatProperties2 *pImageFormatProperties, |
| 3673 | const char *apiName) const { |
| 3674 | bool skip = false; |
| 3675 | |
| 3676 | if (pImageFormatInfo != nullptr) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3677 | const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3678 | if (image_stencil_struct != nullptr) { |
| 3679 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 3680 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 3681 | // No flags other than the legal attachment bits may be set |
| 3682 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 3683 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3684 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 3685 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 3686 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 3687 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 3688 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3689 | } |
| 3690 | } |
| 3691 | } |
| 3692 | } |
| 3693 | |
| 3694 | return skip; |
| 3695 | } |
| 3696 | |
| 3697 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 3698 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3699 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3700 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3701 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 3702 | } |
| 3703 | |
| 3704 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 3705 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3706 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3707 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3708 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 3709 | } |
| 3710 | |
Lionel Landwerlin | 5fe5275 | 2020-07-22 08:18:14 +0300 | [diff] [blame] | 3711 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties( |
| 3712 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, |
| 3713 | VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const { |
| 3714 | bool skip = false; |
| 3715 | |
| 3716 | if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 3717 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248", |
| 3718 | "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT."); |
| 3719 | } |
| 3720 | |
| 3721 | return skip; |
| 3722 | } |
| 3723 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3724 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 3725 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 3726 | bool skip = false; |
| 3727 | |
| 3728 | if (pRegions != nullptr) { |
| 3729 | for (uint32_t i = 0; i < regionCount; i++) { |
| 3730 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3731 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
| 3732 | "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3733 | } |
| 3734 | } |
| 3735 | } |
| 3736 | return skip; |
| 3737 | } |
| 3738 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 3739 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, |
| 3740 | const VkCopyBufferInfo2KHR *pCopyBufferInfo) const { |
| 3741 | bool skip = false; |
| 3742 | |
| 3743 | if (pCopyBufferInfo->pRegions != nullptr) { |
| 3744 | for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) { |
| 3745 | if (pCopyBufferInfo->pRegions[i].size == 0) { |
| 3746 | skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988", |
| 3747 | "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i); |
| 3748 | } |
| 3749 | } |
| 3750 | } |
| 3751 | return skip; |
| 3752 | } |
| 3753 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3754 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3755 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 3756 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3757 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3758 | |
| 3759 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3760 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 3761 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3762 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3763 | } |
| 3764 | |
| 3765 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3766 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 3767 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 3768 | "), must be greater than zero and less than or equal to 65536.", |
| 3769 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3770 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3771 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 3772 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3773 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3774 | } |
| 3775 | return skip; |
| 3776 | } |
| 3777 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3778 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3779 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3780 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3781 | |
| 3782 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3783 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 3784 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3785 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3786 | } |
| 3787 | |
| 3788 | if (size != VK_WHOLE_SIZE) { |
| 3789 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3790 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3791 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 3792 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3793 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3794 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 3795 | "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] | 3796 | } |
| 3797 | } |
| 3798 | return skip; |
| 3799 | } |
| 3800 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3801 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3802 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3803 | VkSwapchainKHR *pSwapchain) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3804 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3805 | |
| 3806 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3807 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3808 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 3809 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 3810 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3811 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
| 3812 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3813 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3814 | } |
| 3815 | |
| 3816 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 3817 | // queueFamilyIndexCount uint32_t values |
| 3818 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3819 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
| 3820 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3821 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 3822 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3823 | } |
| 3824 | } |
| 3825 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3826 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3827 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3828 | } |
| 3829 | |
| 3830 | return skip; |
| 3831 | } |
| 3832 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3833 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3834 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3835 | |
| 3836 | if (pPresentInfo && pPresentInfo->pNext) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 3837 | const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3838 | if (present_regions) { |
| 3839 | // 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] | 3840 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3841 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 3842 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
sfricke-samsung | a4cc4ff | 2020-08-23 22:05:49 -0700 | [diff] [blame] | 3843 | skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3844 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 3845 | "extension swapchainCount is %i. These values must be equal.", |
| 3846 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3847 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3848 | 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] | 3849 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 3850 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3851 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 3852 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 3853 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3854 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3855 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3856 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3857 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3858 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3859 | } |
| 3860 | } |
| 3861 | |
| 3862 | return skip; |
| 3863 | } |
| 3864 | |
sfricke-samsung | 5c1b739 | 2020-12-13 22:17:15 -0800 | [diff] [blame] | 3865 | bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 3866 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 3867 | const VkAllocationCallbacks *pAllocator, |
| 3868 | VkDisplayModeKHR *pMode) const { |
| 3869 | bool skip = false; |
| 3870 | |
| 3871 | const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters; |
| 3872 | if (display_mode_parameters.visibleRegion.width == 0) { |
| 3873 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990", |
| 3874 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0."); |
| 3875 | } |
| 3876 | if (display_mode_parameters.visibleRegion.height == 0) { |
| 3877 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991", |
| 3878 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0."); |
| 3879 | } |
| 3880 | if (display_mode_parameters.refreshRate == 0) { |
| 3881 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992", |
| 3882 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0."); |
| 3883 | } |
| 3884 | |
| 3885 | return skip; |
| 3886 | } |
| 3887 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3888 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3889 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 3890 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 3891 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3892 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3893 | bool skip = false; |
| 3894 | |
| 3895 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3896 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 3897 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3898 | } |
| 3899 | |
| 3900 | return skip; |
| 3901 | } |
| 3902 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 3903 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3904 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3905 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3906 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3907 | bool skip = false; |
| 3908 | |
| 3909 | if (pCreateInfo) { |
| 3910 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3911 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 3912 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3913 | } |
| 3914 | |
| 3915 | if (pCreateInfo->pPoolSizes) { |
| 3916 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 3917 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3918 | skip |= LogError( |
| 3919 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3920 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3921 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3922 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 3923 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3924 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 3925 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 3926 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 3927 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 3928 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3929 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3930 | } |
| 3931 | } |
| 3932 | } |
| 3933 | |
| 3934 | return skip; |
| 3935 | } |
| 3936 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3937 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3938 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3939 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3940 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3941 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3942 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3943 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 3944 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3945 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3946 | } |
| 3947 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3948 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3949 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3950 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 3951 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3952 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3953 | } |
| 3954 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3955 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3956 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3957 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 3958 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3959 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3960 | } |
| 3961 | |
| 3962 | return skip; |
| 3963 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3964 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3965 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3966 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3967 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3968 | |
| 3969 | if ((offset % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3970 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
| 3971 | "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3972 | } |
| 3973 | return skip; |
| 3974 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3975 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3976 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 3977 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3978 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3979 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3980 | |
| 3981 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3982 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3983 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3984 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 3985 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 3986 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3987 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3988 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3989 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 3990 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 3991 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3992 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3993 | } |
| 3994 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3995 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3996 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3997 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 3998 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 3999 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 4000 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4001 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4002 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 4003 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 4004 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 4005 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4006 | } |
| 4007 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4008 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4009 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4010 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 4011 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 4012 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 4013 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4014 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4015 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 4016 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 4017 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 4018 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4019 | } |
| 4020 | |
| 4021 | return skip; |
| 4022 | } |
| 4023 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4024 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 4025 | VkPipelineBindPoint pipelineBindPoint, |
| 4026 | VkPipelineLayout layout, uint32_t set, |
| 4027 | uint32_t descriptorWriteCount, |
| 4028 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
| 4029 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false); |
| 4030 | } |
| 4031 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4032 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 4033 | uint32_t firstExclusiveScissor, |
| 4034 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4035 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4036 | bool skip = false; |
| 4037 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4038 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4039 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4040 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4041 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 4042 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 4043 | ") is not 0.", |
| 4044 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4045 | } |
| 4046 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4047 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4048 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 4049 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 4050 | ") is not 1.", |
| 4051 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4052 | } |
| 4053 | } else { // multiViewport enabled |
| 4054 | 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] | 4055 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4056 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 4057 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 4058 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4059 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4060 | } |
| 4061 | } |
| 4062 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4063 | if (pExclusiveScissors) { |
| 4064 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 4065 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 4066 | |
| 4067 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4068 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4069 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 4070 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4071 | } |
| 4072 | |
| 4073 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4074 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4075 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 4076 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4077 | } |
| 4078 | |
| 4079 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 4080 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4081 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 4082 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4083 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4084 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 4088 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4089 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 4090 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4091 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4092 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4093 | } |
| 4094 | } |
| 4095 | } |
| 4096 | |
| 4097 | return skip; |
| 4098 | } |
| 4099 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4100 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 4101 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4102 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4103 | bool skip = false; |
Shannon McPherson | 169d0c7 | 2020-11-13 18:48:19 -0700 | [diff] [blame] | 4104 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 4105 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
| 4106 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 4107 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4108 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 4109 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4110 | } |
| 4111 | |
| 4112 | return skip; |
| 4113 | } |
| 4114 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4115 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 4116 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4117 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4118 | bool skip = false; |
| 4119 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4120 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4121 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4122 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4123 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 4124 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 4125 | ") is not 0.", |
| 4126 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4127 | } |
| 4128 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4129 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4130 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 4131 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 4132 | ") is not 1.", |
| 4133 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4134 | } |
| 4135 | } |
| 4136 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4137 | 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] | 4138 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4139 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 4140 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 4141 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4142 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4143 | } |
| 4144 | |
| 4145 | return skip; |
| 4146 | } |
| 4147 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4148 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 4149 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 4150 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4151 | bool skip = false; |
| 4152 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4153 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4154 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 4155 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 4156 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4157 | } |
| 4158 | |
| 4159 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4160 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4161 | } |
| 4162 | |
| 4163 | return skip; |
| 4164 | } |
| 4165 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4166 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4167 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4168 | bool skip = false; |
| 4169 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4170 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4171 | skip |= LogError( |
| 4172 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4173 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 4174 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4175 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4176 | } |
| 4177 | |
| 4178 | return skip; |
| 4179 | } |
| 4180 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4181 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4182 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4183 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4184 | bool skip = false; |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4185 | static const int condition_multiples = 0b0011; |
| 4186 | if (offset & condition_multiples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4187 | skip |= LogError( |
| 4188 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4189 | "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] | 4190 | } |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4191 | if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4192 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 4193 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 4194 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 4195 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4196 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4197 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4198 | skip |= LogError( |
| 4199 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
| 4200 | "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] | 4201 | } |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4202 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 4203 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719", |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4204 | "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).", |
| 4205 | drawCount, device_limits.maxDrawIndirectCount); |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4206 | } |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4207 | return skip; |
| 4208 | } |
| 4209 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4210 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4211 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4212 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4213 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4214 | bool skip = false; |
| 4215 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4216 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4217 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 4218 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 4219 | "), is not a multiple of 4.", |
| 4220 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4221 | } |
| 4222 | |
| 4223 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4224 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 4225 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 4226 | "), is not a multiple of 4.", |
| 4227 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4228 | } |
| 4229 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4230 | return skip; |
| 4231 | } |
| 4232 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4233 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4234 | const VkAllocationCallbacks *pAllocator, |
| 4235 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4236 | bool skip = false; |
| 4237 | |
| 4238 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4239 | if (pCreateInfo != nullptr) { |
| 4240 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 4241 | // VkQueryPipelineStatisticFlagBits values |
| 4242 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 4243 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4244 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 4245 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 4246 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 4247 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4248 | } |
sfricke-samsung | 7d69d0d | 2020-04-25 10:27:27 -0700 | [diff] [blame] | 4249 | if (pCreateInfo->queryCount == 0) { |
| 4250 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763", |
| 4251 | "vkCreateQueryPool(): queryCount must be greater than zero."); |
| 4252 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 4253 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4254 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4255 | } |
| 4256 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4257 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 4258 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4259 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4260 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 4261 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4262 | } |
| 4263 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4264 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4265 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4266 | VkResult result) { |
| 4267 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4268 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4269 | } |
| 4270 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4271 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4272 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4273 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4274 | // 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] | 4275 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4276 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4277 | } |
| 4278 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4279 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 4280 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4281 | // 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] | 4282 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4283 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4284 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4285 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4286 | void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4287 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4288 | if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) { |
| 4289 | auto lock = cb_write_lock(); |
| 4290 | for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4291 | secondary_cb_map.insert({pCommandBuffers[cb_index], pAllocateInfo->commandPool}); |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4292 | } |
| 4293 | } |
| 4294 | } |
| 4295 | |
| 4296 | void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4297 | const VkCommandBuffer *pCommandBuffers) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4298 | auto lock = cb_write_lock(); |
| 4299 | for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) { |
| 4300 | secondary_cb_map.erase(pCommandBuffers[cb_index]); |
| 4301 | } |
| 4302 | } |
| 4303 | |
| 4304 | void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4305 | const VkAllocationCallbacks *pAllocator) { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4306 | auto lock = cb_write_lock(); |
| 4307 | for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) { |
| 4308 | if (item->second == commandPool) { |
| 4309 | item = secondary_cb_map.erase(item); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4310 | } else { |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame] | 4311 | ++item; |
| 4312 | } |
| 4313 | } |
| 4314 | } |
| 4315 | |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4316 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4317 | const VkAllocationCallbacks *pAllocator, |
| 4318 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4319 | bool skip = false; |
| 4320 | |
| 4321 | if (pAllocateInfo) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4322 | auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4323 | 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] | 4324 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 4325 | "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] | 4326 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4327 | |
| 4328 | VkMemoryAllocateFlags flags = 0; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4329 | auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4330 | if (flags_info) { |
| 4331 | flags = flags_info->flags; |
| 4332 | } |
| 4333 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4334 | auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4335 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4336 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4337 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 4338 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4339 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4340 | } |
| 4341 | |
| 4342 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4343 | auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4344 | #endif |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4345 | auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 4346 | auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4347 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4348 | auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4349 | #endif |
| 4350 | |
| 4351 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4352 | skip |= LogError( |
| 4353 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4354 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 4355 | } |
| 4356 | if ( |
| 4357 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4358 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 4359 | #endif |
| 4360 | (import_memory_fd && import_memory_fd->handleType) || |
| 4361 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 4362 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 4363 | #endif |
| 4364 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4365 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 4366 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4367 | } |
| 4368 | } |
| 4369 | |
| 4370 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 4371 | VkBool32 capture_replay = false; |
| 4372 | VkBool32 buffer_device_address = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4373 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 4374 | if (vulkan_12_features) { |
| 4375 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 4376 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 4377 | } else { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4378 | const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 4379 | if (bda_features) { |
| 4380 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 4381 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 4382 | } |
| 4383 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4384 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4385 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4386 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4387 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4388 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4389 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4390 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4391 | "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] | 4392 | } |
| 4393 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4394 | } |
| 4395 | return skip; |
| 4396 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4397 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4398 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4399 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4400 | bool skip = false; |
| 4401 | |
| 4402 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 4403 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 4404 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4405 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4406 | } else { |
| 4407 | uint32_t vertex_component_size = 0; |
| 4408 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 4409 | vertex_component_size = 4; |
| 4410 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 4411 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 4412 | vertex_component_size = 2; |
| 4413 | } |
| 4414 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4415 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4416 | } |
| 4417 | } |
| 4418 | |
| 4419 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 4420 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4421 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4422 | } else { |
| 4423 | uint32_t index_element_size = 0; |
| 4424 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 4425 | index_element_size = 4; |
| 4426 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 4427 | index_element_size = 2; |
| 4428 | } |
| 4429 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4430 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4431 | } |
| 4432 | } |
| 4433 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 4434 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4435 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4436 | } |
| 4437 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4438 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4439 | } |
| 4440 | } |
| 4441 | |
| 4442 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4443 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4444 | } |
| 4445 | |
| 4446 | return skip; |
| 4447 | } |
| 4448 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4449 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 4450 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4451 | bool skip = false; |
| 4452 | |
| 4453 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4454 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4455 | } |
| 4456 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4457 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4458 | } |
| 4459 | |
| 4460 | return skip; |
| 4461 | } |
| 4462 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4463 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 4464 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4465 | bool skip = false; |
| 4466 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4467 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4468 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4469 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4470 | } |
| 4471 | return skip; |
| 4472 | } |
| 4473 | |
| 4474 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4475 | VkAccelerationStructureNV object_handle, const char *func_name, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 4476 | bool is_cmd) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4477 | bool skip = false; |
| 4478 | 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] | 4479 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 4480 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 4481 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4482 | } |
| 4483 | 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] | 4484 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 4485 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 4486 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4487 | } |
| 4488 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 4489 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4490 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 4491 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 4492 | "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] | 4493 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4494 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4495 | skip |= LogError(object_handle, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 4496 | is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241" |
| 4497 | : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4498 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 4499 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4500 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4501 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4502 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 4503 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 4504 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4505 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4506 | 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] | 4507 | uint64_t total_triangle_count = 0; |
| 4508 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 4509 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4510 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4511 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4512 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4513 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 4514 | continue; |
| 4515 | } |
| 4516 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 4517 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4518 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4519 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 4520 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 4521 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4522 | } |
| 4523 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4524 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 4525 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 4526 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 4527 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 4528 | if (geometry.geometryType != first_geometry_type) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4529 | skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4530 | "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match " |
| 4531 | "info.pGeometries[0].geometryType.", |
| 4532 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4533 | } |
| 4534 | } |
| 4535 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4536 | for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) { |
| 4537 | if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV || |
| 4538 | info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) { |
| 4539 | skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503", |
| 4540 | "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV" |
| 4541 | "or VK_GEOMETRY_TYPE_AABBS_NV."); |
| 4542 | } |
| 4543 | } |
| 4544 | skip |= |
| 4545 | validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV, |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 4546 | info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4547 | return skip; |
| 4548 | } |
| 4549 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4550 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 4551 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4552 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4553 | bool skip = false; |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4554 | if (pCreateInfo) { |
| 4555 | if ((pCreateInfo->compactedSize != 0) && |
| 4556 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4557 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 4558 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 4559 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 4560 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4561 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4562 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4563 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4564 | "vkCreateAccelerationStructureNV()", false); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4565 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4566 | return skip; |
| 4567 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4568 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4569 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 4570 | const VkAccelerationStructureInfoNV *pInfo, |
| 4571 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 4572 | VkBool32 update, VkAccelerationStructureNV dst, |
| 4573 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 4574 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4575 | bool skip = false; |
| 4576 | |
| 4577 | if (pInfo != nullptr) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4578 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4579 | } |
| 4580 | |
| 4581 | return skip; |
| 4582 | } |
| 4583 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4584 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR( |
| 4585 | VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 4586 | VkAccelerationStructureKHR *pAccelerationStructure) const { |
| 4587 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4588 | const auto *acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4589 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4590 | if (!acceleration_structure_features || |
| 4591 | (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) { |
| 4592 | skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611", |
| 4593 | "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled"); |
| 4594 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4595 | if (pCreateInfo) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4596 | if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR && |
| 4597 | (!acceleration_structure_features || |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4598 | (acceleration_structure_features && |
| 4599 | acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4600 | skip |= |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4601 | LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613", |
| 4602 | "vkCreateAccelerationStructureKHR(): If createFlags includes " |
| 4603 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, " |
| 4604 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4605 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4606 | if (pCreateInfo->deviceAddress && |
| 4607 | !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
| 4608 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612", |
| 4609 | "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include " |
| 4610 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR"); |
| 4611 | } |
| 4612 | if (SafeModulo(pCreateInfo->offset, 256) != 0) { |
| 4613 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734", |
| 4614 | "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset); |
| 4615 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4616 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4617 | return skip; |
| 4618 | } |
| 4619 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4620 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 4621 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4622 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4623 | bool skip = false; |
| 4624 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4625 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 4626 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4627 | } |
| 4628 | return skip; |
| 4629 | } |
| 4630 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4631 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV( |
| 4632 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures, |
| 4633 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 4634 | bool skip = false; |
| 4635 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 4636 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 4637 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432", |
| 4638 | "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be " |
| 4639 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 4640 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 4641 | } |
| 4642 | return skip; |
| 4643 | } |
| 4644 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4645 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 4646 | uint32_t createInfoCount, |
| 4647 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 4648 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4649 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4650 | bool skip = false; |
| 4651 | |
| 4652 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4653 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4654 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4655 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4656 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 4657 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 4658 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 4659 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4660 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4661 | |
| 4662 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4663 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4664 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4665 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4666 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4667 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905", |
| 4668 | "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled," |
| 4669 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4670 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4671 | } |
| 4672 | } |
| 4673 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4674 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 4675 | skip |= |
| 4676 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904", |
| 4677 | "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 4678 | } |
| 4679 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) && |
| 4680 | (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) { |
| 4681 | skip |= |
| 4682 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957", |
| 4683 | "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and" |
| 4684 | "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time."); |
| 4685 | } |
| 4686 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4687 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4688 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4689 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423", |
| 4690 | "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be " |
| 4691 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4692 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4693 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4694 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4695 | skip |= |
| 4696 | LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415", |
| 4697 | "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the" |
| 4698 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element" |
| 4699 | "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to " |
| 4700 | "that element."); |
| 4701 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4702 | } |
| 4703 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 4704 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4705 | skip |= |
| 4706 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422", |
| 4707 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4708 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling" |
| 4709 | "commands pCreateInfos parameter."); |
| 4710 | } |
| 4711 | } else { |
| 4712 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4713 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424", |
| 4714 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4715 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4716 | } |
| 4717 | } |
| 4718 | } |
| 4719 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 4720 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456", |
| 4721 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR."); |
| 4722 | } |
| 4723 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) { |
| 4724 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458", |
| 4725 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4726 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR."); |
| 4727 | } |
| 4728 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) { |
| 4729 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459", |
| 4730 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4731 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR."); |
| 4732 | } |
| 4733 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) { |
| 4734 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460", |
| 4735 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4736 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR."); |
| 4737 | } |
| 4738 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) { |
| 4739 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461", |
| 4740 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4741 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR."); |
| 4742 | } |
| 4743 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4744 | skip |= LogError( |
| 4745 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462", |
| 4746 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4747 | } |
| 4748 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4749 | skip |= LogError( |
| 4750 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463", |
| 4751 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 4752 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4753 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) { |
| 4754 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588", |
| 4755 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4756 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 4757 | } |
| 4758 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 4759 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816", |
| 4760 | "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
| 4761 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4762 | } |
| 4763 | |
| 4764 | return skip; |
| 4765 | } |
| 4766 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4767 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR( |
| 4768 | VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 4769 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4770 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4771 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4772 | if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) { |
| 4773 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586", |
| 4774 | "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4775 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4776 | for (uint32_t i = 0; i < createInfoCount; i++) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4777 | if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) { |
| 4778 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4779 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596", |
| 4780 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 4781 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4782 | } |
| 4783 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4784 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597", |
| 4785 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 4786 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR."); |
| 4787 | } |
| 4788 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4789 | auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4790 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
| 4791 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4792 | "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32 |
| 4793 | "], When chained to VkRayTracingPipelineCreateInfoKHR, " |
| 4794 | "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4795 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").", |
| 4796 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
| 4797 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4798 | const auto *pipeline_cache_contol_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4799 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4800 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4801 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4802 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4803 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4804 | "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled," |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4805 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4806 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4807 | } |
| 4808 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4809 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4810 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904", |
| 4811 | "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4812 | } |
| 4813 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4814 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4815 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4816 | "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, " |
| 4817 | "pLibraryInterface must not be NULL."); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4818 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4819 | } |
| 4820 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 4821 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816", |
| 4822 | "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4823 | } |
| 4824 | for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) { |
| 4825 | if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) || |
| 4826 | (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) { |
| 4827 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) && |
| 4828 | (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4829 | skip |= LogError( |
| 4830 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4831 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 4832 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4833 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4834 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element " |
| 4835 | "must not be VK_SHADER_UNUSED_KHR"); |
| 4836 | } |
| 4837 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) && |
| 4838 | (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4839 | skip |= LogError( |
| 4840 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4841 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 4842 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4843 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4844 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that " |
| 4845 | "element must not be VK_SHADER_UNUSED_KHR"); |
| 4846 | } |
| 4847 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4848 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE && |
| 4849 | pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) { |
| 4850 | if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) { |
| 4851 | skip |= LogError( |
| 4852 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599", |
| 4853 | "vkCreateRayTracingPipelinesKHR: If " |
| 4854 | "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is " |
| 4855 | "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must " |
| 4856 | "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 4857 | } |
| 4858 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4859 | } |
| 4860 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4861 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4862 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4863 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4864 | "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be " |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4865 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4866 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4867 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4868 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4869 | skip |= |
| 4870 | LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415", |
| 4871 | "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the" |
| 4872 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is" |
| 4873 | "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that " |
| 4874 | "element."); |
| 4875 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4876 | } |
| 4877 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 4878 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4879 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4880 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4881 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling" |
| 4882 | "commands pCreateInfos parameter %d.", |
| 4883 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 4884 | } |
| 4885 | } else { |
| 4886 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4887 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4888 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4889 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4890 | } |
| 4891 | } |
| 4892 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4893 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR && |
| 4894 | (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) { |
| 4895 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598", |
| 4896 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 4897 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, " |
| 4898 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled."); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4899 | } |
| 4900 | bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library); |
| 4901 | if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) { |
| 4902 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595", |
| 4903 | "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, " |
| 4904 | "pLibraryInfo and pLibraryInterface must be NULL."); |
| 4905 | } |
| 4906 | if (pCreateInfos[i].pLibraryInfo) { |
| 4907 | if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) { |
| 4908 | if (pCreateInfos[i].stageCount == 0) { |
| 4909 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600", |
| 4910 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 4911 | "stageCount must not be 0."); |
| 4912 | } |
| 4913 | if (pCreateInfos[i].groupCount == 0) { |
| 4914 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601", |
| 4915 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 4916 | "groupCount must not be 0."); |
| 4917 | } |
| 4918 | } else { |
| 4919 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
| 4920 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590", |
| 4921 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member " |
| 4922 | "is greater than 0, its " |
| 4923 | "pLibraryInterface member must not be NULL."); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4924 | } |
| 4925 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 4926 | } |
| 4927 | if (pCreateInfos[i].pLibraryInterface) { |
| 4928 | if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize > |
| 4929 | phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) { |
| 4930 | skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605", |
| 4931 | "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to " |
| 4932 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize."); |
| 4933 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4934 | } |
| 4935 | if (deferredOperation != VK_NULL_HANDLE) { |
| 4936 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) { |
| 4937 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587", |
| 4938 | "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of " |
| 4939 | "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] | 4940 | } |
| 4941 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4942 | } |
| 4943 | |
| 4944 | return skip; |
| 4945 | } |
| 4946 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4947 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4948 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 4949 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4950 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4951 | bool skip = false; |
| 4952 | if (!device_extensions.vk_khr_swapchain) |
| 4953 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 4954 | if (!device_extensions.vk_khr_get_surface_capabilities_2) |
| 4955 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
| 4956 | if (!device_extensions.vk_khr_surface) |
| 4957 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
| 4958 | if (!device_extensions.vk_khr_get_physical_device_properties_2) |
| 4959 | skip |= |
| 4960 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 4961 | if (!device_extensions.vk_ext_full_screen_exclusive) |
| 4962 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 4963 | skip |= validate_struct_type( |
| 4964 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 4965 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 4966 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 4967 | if (pSurfaceInfo != NULL) { |
| 4968 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 4969 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 4970 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 4971 | |
| 4972 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 4973 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 4974 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 4975 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 4976 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 4977 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4978 | |
| 4979 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 4980 | } |
| 4981 | return skip; |
| 4982 | } |
| 4983 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4984 | |
| 4985 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 4986 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4987 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4988 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4989 | bool skip = false; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4990 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4991 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 4992 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 4993 | } |
| 4994 | return skip; |
| 4995 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4996 | |
| 4997 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4998 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4999 | bool skip = false; |
| 5000 | |
| 5001 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5002 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
| 5003 | "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 5004 | } |
| 5005 | |
| 5006 | return skip; |
| 5007 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5008 | |
| 5009 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5010 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5011 | bool skip = false; |
| 5012 | |
| 5013 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5014 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 5015 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5016 | } |
| 5017 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5018 | const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext); |
Mark Lobodzinski | 804fde8 | 2020-05-08 07:49:25 -0600 | [diff] [blame] | 5019 | 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] | 5020 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 5021 | "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] | 5022 | } |
| 5023 | |
| 5024 | return skip; |
| 5025 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5026 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 5027 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 5028 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 5029 | const VkDeviceSize *pOffsets) const { |
| 5030 | bool skip = false; |
| 5031 | if (firstBinding > device_limits.maxVertexInputBindings) { |
| 5032 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 5033 | "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding, |
| 5034 | device_limits.maxVertexInputBindings); |
| 5035 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 5036 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
| 5037 | "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 5038 | "maxVertexInputBindings (%u)", |
| 5039 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 5040 | } |
| 5041 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 5042 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5043 | if (pBuffers[i] == VK_NULL_HANDLE) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5044 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 5045 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 5046 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001", |
| 5047 | "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 5048 | } else { |
| 5049 | if (pOffsets[i] != 0) { |
| 5050 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002", |
| 5051 | "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 5052 | } |
| 5053 | } |
| 5054 | } |
| 5055 | } |
| 5056 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 5057 | return skip; |
| 5058 | } |
| 5059 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5060 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5061 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5062 | bool skip = false; |
| 5063 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5064 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 5065 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5066 | } |
| 5067 | return skip; |
| 5068 | } |
| 5069 | |
| 5070 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5071 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5072 | bool skip = false; |
| 5073 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5074 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 5075 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5076 | } |
| 5077 | return skip; |
| 5078 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5079 | |
| 5080 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 5081 | VkSemaphore semaphore, VkFence fence, |
| 5082 | uint32_t *pImageIndex) const { |
| 5083 | bool skip = false; |
| 5084 | |
| 5085 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5086 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 5087 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5088 | } |
| 5089 | |
| 5090 | return skip; |
| 5091 | } |
| 5092 | |
| 5093 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 5094 | uint32_t *pImageIndex) const { |
| 5095 | bool skip = false; |
| 5096 | |
| 5097 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5098 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 5099 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5100 | } |
| 5101 | |
| 5102 | return skip; |
| 5103 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5104 | |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 5105 | bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, |
| 5106 | uint32_t firstBinding, uint32_t bindingCount, |
| 5107 | const VkBuffer *pBuffers, |
| 5108 | const VkDeviceSize *pOffsets, |
| 5109 | const VkDeviceSize *pSizes) const { |
| 5110 | bool skip = false; |
| 5111 | |
| 5112 | char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT"; |
| 5113 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5114 | if (pOffsets[i] & 3) { |
| 5115 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359", |
| 5116 | "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]); |
| 5117 | } |
| 5118 | } |
| 5119 | |
| 5120 | if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5121 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356", |
| 5122 | "%s: The firstBinding(%" PRIu32 |
| 5123 | ") index is greater than or equal to " |
| 5124 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5125 | cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5126 | } |
| 5127 | |
| 5128 | if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5129 | skip |= |
| 5130 | LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357", |
| 5131 | "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32 |
| 5132 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5133 | cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5134 | } |
| 5135 | |
| 5136 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5137 | // pSizes is optional and may be nullptr. |
| 5138 | if (pSizes != nullptr) { |
| 5139 | if (pSizes[i] != VK_WHOLE_SIZE && |
| 5140 | pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) { |
| 5141 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361", |
| 5142 | "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64 |
| 5143 | ") is not VK_WHOLE_SIZE and is greater than " |
| 5144 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.", |
| 5145 | cmd_name, i, pSizes[i]); |
| 5146 | } |
| 5147 | } |
| 5148 | } |
| 5149 | |
| 5150 | return skip; |
| 5151 | } |
| 5152 | |
| 5153 | bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5154 | uint32_t firstCounterBuffer, |
| 5155 | uint32_t counterBufferCount, |
| 5156 | const VkBuffer *pCounterBuffers, |
| 5157 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5158 | bool skip = false; |
| 5159 | |
| 5160 | char const *const cmd_name = "CmdBeginTransformFeedbackEXT"; |
| 5161 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5162 | skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368", |
| 5163 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5164 | ") index is greater than or equal to " |
| 5165 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5166 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5167 | } |
| 5168 | |
| 5169 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5170 | skip |= |
| 5171 | LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369", |
| 5172 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5173 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5174 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5175 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5176 | } |
| 5177 | |
| 5178 | return skip; |
| 5179 | } |
| 5180 | |
| 5181 | bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5182 | uint32_t firstCounterBuffer, uint32_t counterBufferCount, |
| 5183 | const VkBuffer *pCounterBuffers, |
| 5184 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5185 | bool skip = false; |
| 5186 | |
| 5187 | char const *const cmd_name = "CmdEndTransformFeedbackEXT"; |
| 5188 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5189 | skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376", |
| 5190 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5191 | ") index is greater than or equal to " |
| 5192 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5193 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5194 | } |
| 5195 | |
| 5196 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5197 | skip |= |
| 5198 | LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377", |
| 5199 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5200 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5201 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5202 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5203 | } |
| 5204 | |
| 5205 | return skip; |
| 5206 | } |
| 5207 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5208 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 5209 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 5210 | VkDeviceSize counterBufferOffset, |
| 5211 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 5212 | bool skip = false; |
| 5213 | |
| 5214 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5215 | skip |= LogError( |
| 5216 | counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5217 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).", |
| 5218 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
| 5219 | } |
| 5220 | |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5221 | if ((counterOffset % 4) != 0) { |
| 5222 | // TODO - Update when header are updated |
| 5223 | skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset", |
| 5224 | "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset); |
| 5225 | } |
| 5226 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5227 | return skip; |
| 5228 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5229 | |
| 5230 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 5231 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 5232 | const VkAllocationCallbacks *pAllocator, |
| 5233 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 5234 | const char *apiName) const { |
| 5235 | bool skip = false; |
| 5236 | |
| 5237 | // Check samplerYcbcrConversion feature is set |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5238 | const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5239 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5240 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5241 | if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) { |
| 5242 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5243 | "%s: samplerYcbcrConversion must be enabled.", apiName); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5244 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5245 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5246 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5247 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5248 | const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5249 | 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] | 5250 | #else |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5251 | const bool is_external_format = false; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5252 | #endif |
| 5253 | |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5254 | const VkFormat format = pCreateInfo->format; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5255 | |
| 5256 | // 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] | 5257 | if (!is_external_format) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5258 | const VkComponentMapping components = pCreateInfo->components; |
| 5259 | // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec |
| 5260 | if (FormatIsXChromaSubsampled(format) == true) { |
| 5261 | if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) { |
| 5262 | skip |= |
| 5263 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5264 | "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G " |
| 5265 | "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5266 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5267 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5268 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5269 | if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5270 | (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) { |
| 5271 | skip |= LogError( |
| 5272 | device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582", |
| 5273 | "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or " |
| 5274 | "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.", |
| 5275 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a)); |
| 5276 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5277 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5278 | if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5279 | (components.r != VK_COMPONENT_SWIZZLE_B)) { |
| 5280 | skip |= |
| 5281 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5282 | "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R " |
| 5283 | "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] | 5284 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5285 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5286 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5287 | if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5288 | (components.b != VK_COMPONENT_SWIZZLE_R)) { |
| 5289 | skip |= |
| 5290 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5291 | "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B " |
| 5292 | "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] | 5293 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5294 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5295 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5296 | // If one is identity, both need to be |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5297 | const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 5298 | const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 5299 | if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5300 | skip |= |
| 5301 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5302 | "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) " |
| 5303 | "are an identity swizzle, then both need to be an identity swizzle.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5304 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r), |
| 5305 | string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5306 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5307 | } |
| 5308 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5309 | if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) { |
| 5310 | // Checks same VU multiple ways in order to give a more useful error message |
| 5311 | const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655"; |
| 5312 | if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) || |
| 5313 | (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) || |
| 5314 | (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) { |
| 5315 | skip |= LogError( |
| 5316 | device, vuid, |
| 5317 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5318 | "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.", |
| 5319 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5320 | string_VkComponentSwizzle(components.b)); |
| 5321 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5322 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5323 | // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA" |
| 5324 | // 4 channel format = no issue |
| 5325 | // 3 = no [a] |
| 5326 | // 2 = no [b,a] |
| 5327 | // 1 = no [g,b,a] |
| 5328 | // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it) |
| 5329 | const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format); |
| 5330 | |
| 5331 | if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) || |
| 5332 | (components.b == VK_COMPONENT_SWIZZLE_A))) { |
| 5333 | skip |= LogError(device, vuid, |
| 5334 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5335 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.", |
| 5336 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5337 | string_VkComponentSwizzle(components.b)); |
| 5338 | } else if ((channels < 3) && |
| 5339 | ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) || |
| 5340 | (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) { |
| 5341 | skip |= LogError(device, vuid, |
| 5342 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5343 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B " |
| 5344 | "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 5345 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5346 | string_VkComponentSwizzle(components.b)); |
| 5347 | } else if ((channels < 2) && |
| 5348 | ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) || |
| 5349 | (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) { |
| 5350 | skip |= LogError(device, vuid, |
| 5351 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5352 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G " |
| 5353 | "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 5354 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5355 | string_VkComponentSwizzle(components.b)); |
| 5356 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5357 | } |
| 5358 | } |
| 5359 | |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5360 | return skip; |
| 5361 | } |
| 5362 | |
| 5363 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 5364 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 5365 | const VkAllocationCallbacks *pAllocator, |
| 5366 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 5367 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 5368 | "vkCreateSamplerYcbcrConversion"); |
| 5369 | } |
| 5370 | |
| 5371 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 5372 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 5373 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 5374 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 5375 | "vkCreateSamplerYcbcrConversionKHR"); |
| 5376 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 5377 | |
| 5378 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR( |
| 5379 | VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const { |
| 5380 | bool skip = false; |
| 5381 | VkExternalSemaphoreHandleTypeFlags supported_handle_types = |
| 5382 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 5383 | |
| 5384 | if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5385 | skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", |
| 5386 | "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).", |
| 5387 | report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(), |
| 5388 | string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType), |
| 5389 | string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 5390 | } |
| 5391 | return skip; |
| 5392 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5393 | |
| 5394 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5395 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5396 | bool skip = false; |
| 5397 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 5398 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 5399 | "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 5400 | } |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5401 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5402 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 5403 | skip |= LogError( |
| 5404 | device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584", |
| 5405 | "vkCopyAccelerationStructureToMemoryKHR: The " |
| 5406 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 5407 | } |
| 5408 | skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress, |
| 5409 | "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732"); |
| 5410 | if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) { |
| 5411 | skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751", |
| 5412 | "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes."); |
| 5413 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5414 | return skip; |
| 5415 | } |
| 5416 | |
| 5417 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR( |
| 5418 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 5419 | bool skip = false; |
| 5420 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 5421 | skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update |
| 5422 | LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 5423 | "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 5424 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5425 | if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) { |
| 5426 | skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740", |
| 5427 | "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.", |
| 5428 | pInfo->dst.deviceAddress); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5429 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5430 | return skip; |
| 5431 | } |
| 5432 | |
| 5433 | bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 5434 | const char *api_name) const { |
| 5435 | bool skip = false; |
| 5436 | if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR || |
| 5437 | pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) { |
| 5438 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410", |
| 5439 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR" |
| 5440 | "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.", |
| 5441 | api_name); |
| 5442 | } |
| 5443 | return skip; |
| 5444 | } |
| 5445 | |
| 5446 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5447 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5448 | bool skip = false; |
| 5449 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()"); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5450 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5451 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5452 | skip |= LogError( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5453 | device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582", |
| 5454 | "vkCopyAccelerationStructureKHR: The " |
| 5455 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5456 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5457 | return skip; |
| 5458 | } |
| 5459 | |
| 5460 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR( |
| 5461 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 5462 | bool skip = false; |
| 5463 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()"); |
| 5464 | return skip; |
| 5465 | } |
| 5466 | |
| 5467 | bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 5468 | const char *api_name, bool is_cmd) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5469 | bool skip = false; |
| 5470 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5471 | skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413", |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5472 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name); |
| 5473 | } |
| 5474 | return skip; |
| 5475 | } |
| 5476 | |
| 5477 | bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5478 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5479 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5480 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5481 | const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5482 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 5483 | skip |= LogError( |
| 5484 | device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583", |
| 5485 | "vkCopyMemoryToAccelerationStructureKHR: The " |
| 5486 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5487 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5488 | skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress, |
| 5489 | "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5490 | return skip; |
| 5491 | } |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 5492 | |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5493 | bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR( |
| 5494 | VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 5495 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5496 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5497 | if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) { |
| 5498 | skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743", |
| 5499 | "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.", |
| 5500 | pInfo->src.deviceAddress); |
| 5501 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5502 | return skip; |
| 5503 | } |
| 5504 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR( |
| 5505 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 5506 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 5507 | bool skip = false; |
| 5508 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 5509 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 5510 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 5511 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 5512 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 5513 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 5514 | } |
| 5515 | return skip; |
| 5516 | } |
| 5517 | bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR( |
| 5518 | VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 5519 | VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const { |
| 5520 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5521 | const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5522 | if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 5523 | skip |= LogError( |
| 5524 | device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585", |
| 5525 | "vkCmdWriteAccelerationStructuresPropertiesKHR: The " |
| 5526 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 5527 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5528 | if (dataSize < accelerationStructureCount * stride) { |
| 5529 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452", |
| 5530 | "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to " |
| 5531 | "accelerationStructureCount (%d) *stride(%zu).", |
| 5532 | dataSize, accelerationStructureCount, stride); |
| 5533 | } |
| 5534 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 5535 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 5536 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 5537 | "vkWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 5538 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 5539 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 5540 | } |
| 5541 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) { |
| 5542 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 5543 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448", |
| 5544 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 5545 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR," |
| 5546 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 5547 | stride); |
| 5548 | } |
| 5549 | } |
| 5550 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) { |
| 5551 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 5552 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450", |
| 5553 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 5554 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR," |
| 5555 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 5556 | stride); |
| 5557 | } |
| 5558 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5559 | return skip; |
| 5560 | } |
| 5561 | bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR( |
| 5562 | VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const { |
| 5563 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5564 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5565 | if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) { |
| 5566 | skip |= LogError( |
| 5567 | device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606", |
| 5568 | "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::" |
| 5569 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5570 | } |
| 5571 | return skip; |
| 5572 | } |
| 5573 | |
| 5574 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5575 | const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 5576 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, |
| 5577 | const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 5578 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5579 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 5580 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5581 | // RayGen |
| 5582 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 5583 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023", |
| 5584 | "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] | 5585 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5586 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5587 | 0) { |
| 5588 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682", |
| 5589 | "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 5590 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5591 | } |
| 5592 | // Callable |
| 5593 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5594 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694", |
| 5595 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 5596 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5597 | } |
| 5598 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5599 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041", |
| 5600 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5601 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5602 | } |
| 5603 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5604 | 0) { |
| 5605 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693", |
| 5606 | "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 5607 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5608 | } |
| 5609 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5610 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5611 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690", |
| 5612 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 5613 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5614 | } |
| 5615 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5616 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5617 | "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to " |
| 5618 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5619 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5620 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5621 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689", |
| 5622 | "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 5623 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5624 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5625 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5626 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5627 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686", |
| 5628 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of " |
| 5629 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5630 | } |
| 5631 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5632 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029", |
| 5633 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5634 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5635 | } |
| 5636 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5637 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685", |
| 5638 | "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 5639 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5640 | } |
| 5641 | if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) { |
| 5642 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629", |
| 5643 | "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to " |
| 5644 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount"); |
| 5645 | } |
| 5646 | if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) { |
| 5647 | skip |= |
| 5648 | LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626", |
| 5649 | "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] " |
| 5650 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5651 | } |
| 5652 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5653 | if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) { |
| 5654 | skip |= |
| 5655 | LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627", |
| 5656 | "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] " |
| 5657 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]"); |
| 5658 | } |
| 5659 | |
| 5660 | if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) { |
| 5661 | skip |= |
| 5662 | LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628", |
| 5663 | "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] " |
| 5664 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5665 | } |
| 5666 | return skip; |
| 5667 | } |
| 5668 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5669 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR( |
| 5670 | VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 5671 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 5672 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5673 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5674 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5675 | if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) { |
| 5676 | skip |= LogError( |
| 5677 | device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637", |
| 5678 | "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect " |
| 5679 | "feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5680 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5681 | // RayGen |
| 5682 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 5683 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023", |
| 5684 | "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] | 5685 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5686 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5687 | 0) { |
| 5688 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682", |
| 5689 | "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 5690 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5691 | } |
| 5692 | // Callabe |
| 5693 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5694 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694", |
| 5695 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 5696 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5697 | } |
| 5698 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5699 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5700 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal " |
| 5701 | "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5702 | } |
| 5703 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5704 | 0) { |
| 5705 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693", |
| 5706 | "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 5707 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5708 | } |
| 5709 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5710 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5711 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690", |
| 5712 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 5713 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5714 | } |
| 5715 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5716 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5717 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to " |
| 5718 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5719 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5720 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5721 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689", |
| 5722 | "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 5723 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5724 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5725 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5726 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5727 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686", |
| 5728 | "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of " |
| 5729 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5730 | } |
| 5731 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5732 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5733 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to " |
| 5734 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5735 | } |
| 5736 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5737 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685", |
| 5738 | "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 5739 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5740 | } |
| 5741 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5742 | if (SafeModulo(indirectDeviceAddress, 4) != 0) { |
| 5743 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634", |
| 5744 | "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5745 | } |
| 5746 | return skip; |
| 5747 | } |
| 5748 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV( |
| 5749 | VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, |
| 5750 | VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 5751 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, |
| 5752 | VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 5753 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 5754 | bool skip = false; |
| 5755 | if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5756 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462", |
| 5757 | "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of " |
| 5758 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5759 | } |
| 5760 | if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5761 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465", |
| 5762 | "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of " |
| 5763 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5764 | } |
| 5765 | if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5766 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468", |
| 5767 | "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to " |
| 5768 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. "); |
| 5769 | } |
| 5770 | |
| 5771 | // hitShader |
| 5772 | if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5773 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460", |
| 5774 | "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of " |
| 5775 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5776 | } |
| 5777 | if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5778 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464", |
| 5779 | "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of " |
| 5780 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5781 | } |
| 5782 | if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5783 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467", |
| 5784 | "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to " |
| 5785 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5786 | } |
| 5787 | |
| 5788 | // missShader |
| 5789 | if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5790 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458", |
| 5791 | "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of " |
| 5792 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5793 | } |
| 5794 | if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5795 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463", |
| 5796 | "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of " |
| 5797 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5798 | } |
| 5799 | if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5800 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466", |
| 5801 | "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to " |
| 5802 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5803 | } |
| 5804 | |
| 5805 | // raygenShader |
| 5806 | if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5807 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456", |
| 5808 | "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of " |
sourav parmar | d152180 | 2020-06-07 21:49:02 -0700 | [diff] [blame] | 5809 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5810 | } |
| 5811 | if (width > device_limits.maxComputeWorkGroupCount[0]) { |
| 5812 | skip |= |
| 5813 | LogError(device, "VUID-vkCmdTraceRaysNV-width-02469", |
| 5814 | "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o]."); |
| 5815 | } |
| 5816 | if (height > device_limits.maxComputeWorkGroupCount[1]) { |
| 5817 | skip |= |
| 5818 | LogError(device, "VUID-vkCmdTraceRaysNV-height-02470", |
| 5819 | "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1]."); |
| 5820 | } |
| 5821 | if (depth > device_limits.maxComputeWorkGroupCount[2]) { |
| 5822 | skip |= |
| 5823 | LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471", |
| 5824 | "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2]."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5825 | } |
| 5826 | return skip; |
| 5827 | } |
| 5828 | |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5829 | bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5830 | VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo, |
| 5831 | VkAccelerationStructureCompatibilityKHR *pCompatibility) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5832 | bool skip = false; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5833 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
| 5834 | const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5835 | if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) || |
| 5836 | (raytracing_features && !raytracing_features->rayTracingPipeline))) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5837 | skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661", |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5838 | "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled."); |
| 5839 | } |
| 5840 | return skip; |
| 5841 | } |
| 5842 | |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 5843 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 5844 | const VkViewport *pViewports) const { |
| 5845 | bool skip = false; |
| 5846 | |
| 5847 | if (!physical_device_features.multiViewport) { |
| 5848 | if (viewportCount != 1) { |
| 5849 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395", |
| 5850 | "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 5851 | ") is not 1.", |
| 5852 | viewportCount); |
| 5853 | } |
| 5854 | } else { // multiViewport enabled |
| 5855 | if (viewportCount < 1 || viewportCount > device_limits.maxViewports) { |
| 5856 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394", |
| 5857 | "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32 |
| 5858 | ") must " |
| 5859 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5860 | viewportCount, device_limits.maxViewports); |
| 5861 | } |
| 5862 | } |
| 5863 | |
| 5864 | if (pViewports) { |
| 5865 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 5866 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
| 5867 | const char *fn_name = "vkCmdSetViewportWithCountEXT"; |
| 5868 | skip |= manual_PreCallValidateViewport( |
| 5869 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
| 5870 | } |
| 5871 | } |
| 5872 | |
| 5873 | return skip; |
| 5874 | } |
| 5875 | |
| 5876 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 5877 | const VkRect2D *pScissors) const { |
| 5878 | bool skip = false; |
| 5879 | |
| 5880 | if (!physical_device_features.multiViewport) { |
| 5881 | if (scissorCount != 1) { |
| 5882 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398", |
| 5883 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5884 | ") must " |
| 5885 | "be 1 when the multiViewport feature is disabled.", |
| 5886 | scissorCount); |
| 5887 | } |
| 5888 | } else { // multiViewport enabled |
| 5889 | if (scissorCount == 0) { |
| 5890 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 5891 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5892 | ") must " |
| 5893 | "be great than zero.", |
| 5894 | scissorCount); |
| 5895 | } else if (scissorCount > device_limits.maxViewports) { |
| 5896 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 5897 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5898 | ") must " |
| 5899 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5900 | scissorCount, device_limits.maxViewports); |
| 5901 | } |
| 5902 | } |
| 5903 | |
| 5904 | if (pScissors) { |
| 5905 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 5906 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
| 5907 | |
| 5908 | if (scissor.offset.x < 0) { |
| 5909 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 5910 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 5911 | scissor.offset.x); |
| 5912 | } |
| 5913 | |
| 5914 | if (scissor.offset.y < 0) { |
| 5915 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 5916 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 5917 | scissor.offset.y); |
| 5918 | } |
| 5919 | |
| 5920 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 5921 | if (x_sum > INT32_MAX) { |
| 5922 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400", |
| 5923 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5924 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5925 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
| 5926 | } |
| 5927 | |
| 5928 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 5929 | if (y_sum > INT32_MAX) { |
| 5930 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401", |
| 5931 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5932 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5933 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
| 5934 | } |
| 5935 | } |
| 5936 | } |
| 5937 | |
| 5938 | return skip; |
| 5939 | } |
| 5940 | |
| 5941 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 5942 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 5943 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 5944 | const VkDeviceSize *pStrides) const { |
| 5945 | bool skip = false; |
| 5946 | if (firstBinding >= device_limits.maxVertexInputBindings) { |
| 5947 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355", |
| 5948 | "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)", |
| 5949 | firstBinding, device_limits.maxVertexInputBindings); |
| 5950 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 5951 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356", |
| 5952 | "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 5953 | "maxVertexInputBindings (%u)", |
| 5954 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 5955 | } |
| 5956 | |
| 5957 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5958 | if (pBuffers[i] == VK_NULL_HANDLE) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 5959 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 5960 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 5961 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111", |
| 5962 | "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 5963 | } else { |
| 5964 | if (pOffsets[i] != 0) { |
| 5965 | skip |= |
| 5966 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112", |
| 5967 | "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 5968 | } |
| 5969 | } |
| 5970 | } |
| 5971 | if (pStrides) { |
| 5972 | if (pStrides[i] > device_limits.maxVertexInputBindingStride) { |
| 5973 | skip |= |
| 5974 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362", |
| 5975 | "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i, |
| 5976 | pStrides[i], device_limits.maxVertexInputBindingStride); |
| 5977 | } |
| 5978 | } |
| 5979 | } |
| 5980 | |
| 5981 | return skip; |
| 5982 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5983 | |
| 5984 | bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR( |
| 5985 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const { |
| 5986 | bool skip = false; |
| 5987 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 5988 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 5989 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654", |
| 5990 | "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name); |
| 5991 | } |
| 5992 | if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR && |
| 5993 | pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) { |
| 5994 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796", |
| 5995 | "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set," |
| 5996 | "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.", |
| 5997 | api_name); |
| 5998 | } |
| 5999 | if (pInfos[i].pGeometries && pInfos[i].ppGeometries) { |
| 6000 | skip |= |
| 6001 | LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788", |
| 6002 | "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name); |
| 6003 | } |
| 6004 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) { |
| 6005 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790", |
| 6006 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name); |
| 6007 | } |
| 6008 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && |
| 6009 | pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) { |
| 6010 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793", |
| 6011 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be" |
| 6012 | " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount", |
| 6013 | api_name); |
| 6014 | } |
| 6015 | if (pInfos[i].pGeometries) { |
| 6016 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6017 | skip |= validate_ranged_enum( |
| 6018 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}), |
| 6019 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType, |
| 6020 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 6021 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6022 | if (pInfos[i].pGeometries[j].geometry.triangles.maxVertex <= 0) { |
| 6023 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655", |
| 6024 | "(%s): maxVertex must be greater than 0", api_name); |
| 6025 | } |
| 6026 | skip |= validate_struct_type( |
| 6027 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}), |
| 6028 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6029 | &(pInfos[i].pGeometries[j].geometry.triangles), |
| 6030 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 6031 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 6032 | skip |= validate_struct_pnext( |
| 6033 | api_name, |
| 6034 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 6035 | NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6036 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6037 | skip |= |
| 6038 | validate_ranged_enum(api_name, |
| 6039 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat", |
| 6040 | ParameterName::IndexVector{i, j}), |
| 6041 | "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat, |
| 6042 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 6043 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 6044 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6045 | &pInfos[i].pGeometries[j].geometry.triangles, |
| 6046 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 6047 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 6048 | skip |= validate_ranged_enum( |
| 6049 | api_name, |
| 6050 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}), |
| 6051 | "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType, |
| 6052 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 6053 | |
| 6054 | if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) { |
| 6055 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 6056 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 6057 | } |
| 6058 | if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 6059 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 6060 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 6061 | skip |= |
| 6062 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 6063 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 6064 | api_name); |
| 6065 | } |
| 6066 | } |
| 6067 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6068 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 6069 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6070 | &pInfos[i].pGeometries[j].geometry.instances, |
| 6071 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 6072 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 6073 | skip |= validate_struct_type( |
| 6074 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}), |
| 6075 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6076 | &(pInfos[i].pGeometries[j].geometry.instances), |
| 6077 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 6078 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 6079 | skip |= validate_struct_pnext( |
| 6080 | api_name, |
| 6081 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 6082 | NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6083 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6084 | |
| 6085 | skip |= validate_bool32(api_name, |
| 6086 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers", |
| 6087 | ParameterName::IndexVector{i, j}), |
| 6088 | pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers); |
| 6089 | } |
| 6090 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6091 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 6092 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6093 | &pInfos[i].pGeometries[j].geometry.aabbs, |
| 6094 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 6095 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 6096 | skip |= validate_struct_type( |
| 6097 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 6098 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6099 | &(pInfos[i].pGeometries[j].geometry.aabbs), |
| 6100 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 6101 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 6102 | skip |= validate_struct_pnext( |
| 6103 | api_name, |
| 6104 | ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 6105 | pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6106 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 6107 | if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) { |
| 6108 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 6109 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 6110 | } |
| 6111 | } |
| 6112 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 6113 | pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6114 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 6115 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 6116 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6117 | api_name); |
| 6118 | } |
| 6119 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 6120 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6121 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 6122 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 6123 | "of elements of" |
| 6124 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6125 | api_name); |
| 6126 | } |
| 6127 | if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) { |
| 6128 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 6129 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 6130 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 6131 | api_name); |
| 6132 | } |
| 6133 | } |
| 6134 | } |
| 6135 | } |
| 6136 | if (pInfos[i].ppGeometries != NULL) { |
| 6137 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6138 | skip |= validate_ranged_enum( |
| 6139 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}), |
| 6140 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType, |
| 6141 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 6142 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6143 | if (pInfos[i].ppGeometries[j]->geometry.triangles.maxVertex <= 0) { |
| 6144 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655", |
| 6145 | "(%s): maxVertex must be greater than 0", api_name); |
| 6146 | } |
| 6147 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 6148 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6149 | &pInfos[i].ppGeometries[j]->geometry.triangles, |
| 6150 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 6151 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 6152 | skip |= validate_struct_type( |
| 6153 | api_name, |
| 6154 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}), |
| 6155 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6156 | &(pInfos[i].ppGeometries[j]->geometry.triangles), |
| 6157 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 6158 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 6159 | skip |= validate_struct_pnext( |
| 6160 | api_name, |
| 6161 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 6162 | NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6163 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6164 | skip |= validate_ranged_enum(api_name, |
| 6165 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat", |
| 6166 | ParameterName::IndexVector{i, j}), |
| 6167 | "VkFormat", AllVkFormatEnums, |
| 6168 | pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat, |
| 6169 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 6170 | skip |= validate_ranged_enum(api_name, |
| 6171 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType", |
| 6172 | ParameterName::IndexVector{i, j}), |
| 6173 | "VkIndexType", AllVkIndexTypeEnums, |
| 6174 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType, |
| 6175 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 6176 | if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) { |
| 6177 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 6178 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 6179 | } |
| 6180 | if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 6181 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 6182 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 6183 | skip |= |
| 6184 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 6185 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 6186 | api_name); |
| 6187 | } |
| 6188 | } |
| 6189 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6190 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 6191 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6192 | &pInfos[i].ppGeometries[j]->geometry.instances, |
| 6193 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 6194 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 6195 | skip |= validate_struct_type( |
| 6196 | api_name, |
| 6197 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}), |
| 6198 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6199 | &(pInfos[i].ppGeometries[j]->geometry.instances), |
| 6200 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 6201 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 6202 | skip |= validate_struct_pnext( |
| 6203 | api_name, |
| 6204 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 6205 | NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6206 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6207 | skip |= validate_bool32(api_name, |
| 6208 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers", |
| 6209 | ParameterName::IndexVector{i, j}), |
| 6210 | pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers); |
| 6211 | } |
| 6212 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6213 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 6214 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6215 | &pInfos[i].ppGeometries[j]->geometry.aabbs, |
| 6216 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 6217 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 6218 | skip |= validate_struct_type( |
| 6219 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 6220 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6221 | &(pInfos[i].ppGeometries[j]->geometry.aabbs), |
| 6222 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 6223 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 6224 | skip |= validate_struct_pnext( |
| 6225 | api_name, |
| 6226 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 6227 | pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6228 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 6229 | if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) { |
| 6230 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 6231 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 6232 | } |
| 6233 | } |
| 6234 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 6235 | pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6236 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 6237 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 6238 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6239 | api_name); |
| 6240 | } |
| 6241 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 6242 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6243 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 6244 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 6245 | "of elements of" |
| 6246 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6247 | api_name); |
| 6248 | } |
| 6249 | if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) { |
| 6250 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 6251 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 6252 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 6253 | api_name); |
| 6254 | } |
| 6255 | } |
| 6256 | } |
| 6257 | } |
| 6258 | } |
| 6259 | return skip; |
| 6260 | } |
| 6261 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR( |
| 6262 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 6263 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 6264 | bool skip = false; |
| 6265 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR"); |
| 6266 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6267 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 6268 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 6269 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710", |
| 6270 | "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its " |
| 6271 | "scratchData.deviceAddress member must be a multiple of " |
| 6272 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 6273 | } |
| 6274 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 6275 | if (i == k) continue; |
| 6276 | bool found = false; |
| 6277 | if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 6278 | skip |= LogError( |
| 6279 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 6280 | "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must " |
| 6281 | "not be " |
| 6282 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6283 | i, k); |
| 6284 | found = true; |
| 6285 | } |
| 6286 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 6287 | skip |= LogError( |
| 6288 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403", |
| 6289 | "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must " |
| 6290 | "not be " |
| 6291 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6292 | i, k); |
| 6293 | found = true; |
| 6294 | } |
| 6295 | if (found) break; |
| 6296 | } |
| 6297 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6298 | if (pInfos[i].pGeometries) { |
| 6299 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6300 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6301 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6302 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 6303 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6304 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6305 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6306 | } |
| 6307 | } else { |
| 6308 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 6309 | skip |= |
| 6310 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 6311 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6312 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6313 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6314 | } |
| 6315 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6316 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6317 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6318 | skip |= LogError( |
| 6319 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 6320 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6321 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6322 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6323 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6324 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6325 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 6326 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 6327 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6328 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6329 | } |
| 6330 | } |
| 6331 | } else if (pInfos[i].ppGeometries) { |
| 6332 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6333 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6334 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6335 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 6336 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6337 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6338 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6339 | } |
| 6340 | } else { |
| 6341 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 6342 | skip |= |
| 6343 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 6344 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6345 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6346 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6347 | } |
| 6348 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6349 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6350 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6351 | skip |= LogError( |
| 6352 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 6353 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6354 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6355 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6356 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6357 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6358 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 6359 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 6360 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6361 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6362 | } |
| 6363 | } |
| 6364 | } |
| 6365 | } |
| 6366 | } |
| 6367 | return skip; |
| 6368 | } |
| 6369 | |
| 6370 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR( |
| 6371 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 6372 | const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides, |
| 6373 | const uint32_t *const *ppMaxPrimitiveCounts) const { |
| 6374 | bool skip = false; |
| 6375 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR"); |
| 6376 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 6377 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6378 | if (!ray_tracing_acceleration_structure_features || |
| 6379 | ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) { |
| 6380 | skip |= LogError( |
| 6381 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650", |
| 6382 | "vkCmdBuildAccelerationStructuresIndirectKHR: The " |
| 6383 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled."); |
| 6384 | } |
| 6385 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6386 | if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) { |
| 6387 | if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) { |
| 6388 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666", |
| 6389 | "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is " |
| 6390 | "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be " |
| 6391 | "VK_NULL_HANDLE."); |
| 6392 | } |
| 6393 | } |
| 6394 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 6395 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 6396 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710", |
| 6397 | "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its " |
| 6398 | "scratchData.deviceAddress member must be a multiple of " |
| 6399 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 6400 | } |
| 6401 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 6402 | if (i == k) continue; |
| 6403 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 6404 | skip |= |
| 6405 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403", |
| 6406 | "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) " |
| 6407 | "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of " |
| 6408 | "any other element [%d) of pInfos.", |
| 6409 | i, k); |
| 6410 | break; |
| 6411 | } |
| 6412 | } |
| 6413 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6414 | if (pInfos[i].pGeometries) { |
| 6415 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6416 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6417 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6418 | skip |= LogError( |
| 6419 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 6420 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6421 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6422 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6423 | } |
| 6424 | } else { |
| 6425 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 6426 | skip |= LogError( |
| 6427 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 6428 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6429 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6430 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6431 | } |
| 6432 | } |
| 6433 | } |
| 6434 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6435 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6436 | skip |= LogError( |
| 6437 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 6438 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6439 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6440 | } |
| 6441 | } |
| 6442 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6443 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 6444 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 6445 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 6446 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6447 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6448 | } |
| 6449 | } |
| 6450 | } else if (pInfos[i].ppGeometries) { |
| 6451 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6452 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6453 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6454 | skip |= LogError( |
| 6455 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 6456 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6457 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6458 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6459 | } |
| 6460 | } else { |
| 6461 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 6462 | skip |= LogError( |
| 6463 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 6464 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6465 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6466 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6467 | } |
| 6468 | } |
| 6469 | } |
| 6470 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6471 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6472 | skip |= LogError( |
| 6473 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 6474 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6475 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6476 | } |
| 6477 | } |
| 6478 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6479 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 6480 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 6481 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 6482 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6483 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6484 | } |
| 6485 | } |
| 6486 | } |
| 6487 | } |
| 6488 | } |
| 6489 | return skip; |
| 6490 | } |
| 6491 | |
| 6492 | bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR( |
| 6493 | VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, |
| 6494 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 6495 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 6496 | bool skip = false; |
| 6497 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR"); |
| 6498 | const auto *ray_tracing_acceleration_structure_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 6499 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6500 | if (!ray_tracing_acceleration_structure_features || |
| 6501 | ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 6502 | skip |= |
| 6503 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581", |
| 6504 | "vkBuildAccelerationStructuresKHR: The " |
| 6505 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled"); |
| 6506 | } |
| 6507 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6508 | for (uint32_t j = 0; j < infoCount; ++j) { |
| 6509 | if (i == j) continue; |
| 6510 | bool found = false; |
| 6511 | if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
| 6512 | skip |= LogError( |
| 6513 | device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 6514 | "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must " |
| 6515 | "not be " |
| 6516 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6517 | i, j); |
| 6518 | found = true; |
| 6519 | } |
| 6520 | if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
| 6521 | skip |= LogError( |
| 6522 | device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403", |
| 6523 | "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must " |
| 6524 | "not be " |
| 6525 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6526 | i, j); |
| 6527 | found = true; |
| 6528 | } |
| 6529 | if (found) break; |
| 6530 | } |
| 6531 | } |
| 6532 | return skip; |
| 6533 | } |
| 6534 | |
| 6535 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR( |
| 6536 | VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo, |
| 6537 | const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const { |
| 6538 | bool skip = false; |
| 6539 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR"); |
| 6540 | const auto *ray_tracing_pipeline_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame^] | 6541 | LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 6542 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6543 | if (!(ray_tracing_pipeline_features || ray_query_features) || |
| 6544 | ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) || |
| 6545 | (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) { |
| 6546 | skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617", |
| 6547 | "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled"); |
| 6548 | } |
| 6549 | return skip; |
| 6550 | } |