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 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 28 | static const int MaxParamCheckerStringLength = 256; |
| 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 | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 36 | 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] | 37 | const char *validateString) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 38 | bool skip = false; |
| 39 | |
| 40 | VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString); |
| 41 | |
| 42 | if (result == VK_STRING_ERROR_NONE) { |
| 43 | return skip; |
| 44 | } else if (result & VK_STRING_ERROR_LENGTH) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 45 | skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), |
| 46 | MaxParamCheckerStringLength); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 47 | } else if (result & VK_STRING_ERROR_BAD_DATA) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 48 | skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName, |
| 49 | stringName.get_name().c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 50 | } |
| 51 | return skip; |
| 52 | } |
| 53 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 54 | 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] | 55 | bool skip = false; |
| 56 | uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0); |
| 57 | if (api_version_nopatch != effective_api_version) { |
| 58 | if (api_version_nopatch < VK_API_VERSION_1_0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 59 | skip |= LogError(instance, kVUIDUndefined, |
| 60 | "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 61 | "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 62 | 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] | 63 | } else { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 64 | skip |= LogWarning(instance, kVUIDUndefined, |
| 65 | "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 66 | "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 67 | 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] | 68 | } |
| 69 | } |
| 70 | return skip; |
| 71 | } |
| 72 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 73 | bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const { |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 74 | bool skip = false; |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 75 | // Create and use a local instance extension object, as an actual instance has not been created yet |
| 76 | uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0); |
| 77 | InstanceExtensions local_instance_extensions; |
| 78 | local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo); |
| 79 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 80 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 81 | skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388", |
| 82 | "instance", pCreateInfo->ppEnabledExtensionNames[i]); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | return skip; |
| 86 | } |
| 87 | |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 88 | bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo, |
| 89 | const VkValidationFeaturesEXT *validation_features) const { |
| 90 | bool skip = false; |
| 91 | bool debug_printf = false; |
| 92 | bool gpu_assisted = false; |
| 93 | bool reserve_slot = false; |
| 94 | for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) { |
| 95 | switch (validation_features->pEnabledValidationFeatures[i]) { |
| 96 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT: |
| 97 | gpu_assisted = true; |
| 98 | break; |
| 99 | |
| 100 | case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT: |
| 101 | debug_printf = true; |
| 102 | break; |
| 103 | |
| 104 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT: |
| 105 | reserve_slot = true; |
| 106 | break; |
| 107 | |
| 108 | default: |
| 109 | break; |
| 110 | } |
| 111 | } |
| 112 | if (reserve_slot && !gpu_assisted) { |
| 113 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967", |
| 114 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, " |
| 115 | "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures."); |
| 116 | } |
| 117 | if (gpu_assisted && debug_printf) { |
| 118 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968", |
| 119 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, " |
| 120 | "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures."); |
| 121 | } |
| 122 | |
| 123 | return skip; |
| 124 | } |
| 125 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 126 | template <typename ExtensionState> |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 127 | ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) { |
| 128 | if (!extension_name) return kNotEnabled; // null strings specify nothing |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 129 | auto info = ExtensionState::get_info(extension_name); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 130 | ExtEnabled state = |
| 131 | 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] | 132 | return state; |
| 133 | } |
| 134 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 135 | bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 136 | const VkAllocationCallbacks *pAllocator, |
| 137 | VkInstance *pInstance) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 138 | bool skip = false; |
| 139 | // Note: From the spec-- |
| 140 | // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing |
| 141 | // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0) |
| 142 | uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion) |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 143 | ? pCreateInfo->pApplicationInfo->apiVersion |
| 144 | : VK_API_VERSION_1_0; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 145 | skip |= validate_api_version(local_api_version, api_version); |
| 146 | skip |= validate_instance_extensions(pCreateInfo); |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 147 | const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext); |
| 148 | if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features); |
| 149 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 150 | return skip; |
| 151 | } |
| 152 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 153 | void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 154 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, |
| 155 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 156 | auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 157 | // Copy extension data into local object |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 158 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 159 | this->instance_extensions = instance_data->instance_extensions; |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame^] | 160 | |
| 161 | uint32_t pdev_count = 0; |
| 162 | DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, nullptr); |
| 163 | std::vector<VkPhysicalDevice> physical_devices; |
| 164 | physical_devices.resize(pdev_count); |
| 165 | DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, physical_devices.data()); |
| 166 | |
| 167 | // Need to get instance and do a getlayerdata call... |
| 168 | for (uint32_t i = 0; i < physical_devices.size(); i++) { |
| 169 | auto phys_dev_props = new VkPhysicalDeviceProperties; |
| 170 | DispatchGetPhysicalDeviceProperties(physical_devices[i], phys_dev_props); |
| 171 | physical_device_properties_map[physical_devices[i]] = phys_dev_props; |
| 172 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame^] | 175 | void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 176 | for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) { |
| 177 | delete (it->second); |
| 178 | it = physical_device_properties_map.erase(it); |
| 179 | } |
| 180 | }; |
| 181 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 182 | void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 183 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 184 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 185 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 186 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); |
| 187 | StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 188 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 189 | // Parmeter validation also uses extension data |
| 190 | stateless_validation->device_extensions = this->device_extensions; |
| 191 | |
| 192 | VkPhysicalDeviceProperties device_properties = {}; |
| 193 | // Need to get instance and do a getlayerdata call... |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 194 | DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 195 | memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 196 | |
| 197 | if (device_extensions.vk_nv_shading_rate_image) { |
| 198 | // Get the needed shading rate image limits |
| 199 | auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); |
| 200 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 201 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 202 | phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; |
| 203 | } |
| 204 | |
| 205 | if (device_extensions.vk_nv_mesh_shader) { |
| 206 | // Get the needed mesh shader limits |
| 207 | auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>(); |
| 208 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 209 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 210 | phys_dev_ext_props.mesh_shader_props = mesh_shader_props; |
| 211 | } |
| 212 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 213 | if (device_extensions.vk_nv_ray_tracing) { |
| 214 | // Get the needed ray tracing limits |
| 215 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>(); |
| 216 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props); |
| 217 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 218 | phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props; |
| 219 | } |
| 220 | |
| 221 | if (device_extensions.vk_khr_ray_tracing) { |
| 222 | // Get the needed ray tracing limits |
| 223 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>(); |
| 224 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props); |
| 225 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 226 | phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props; |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 229 | if (device_extensions.vk_ext_transform_feedback) { |
| 230 | // Get the needed transform feedback limits |
| 231 | auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
| 232 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props); |
| 233 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 234 | phys_dev_ext_props.transform_feedback_props = transform_feedback_props; |
| 235 | } |
| 236 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 237 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 238 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 239 | // Save app-enabled features in this device's validation object |
| 240 | // The enabled features can come from either pEnabledFeatures, or from the pNext chain |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 241 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
| 242 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 243 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 244 | if (features2) { |
| 245 | tmp_features2_state.features = features2->features; |
| 246 | } else if (pCreateInfo->pEnabledFeatures) { |
| 247 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 248 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 249 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 250 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 251 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 252 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 253 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 256 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 257 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 258 | bool skip = false; |
| 259 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 260 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 261 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 262 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 263 | } |
| 264 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 265 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 266 | skip |= |
| 267 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 268 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 269 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 270 | pCreateInfo->ppEnabledExtensionNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 271 | } |
| 272 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 273 | { |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 274 | bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME)); |
| 275 | bool negative_viewport = |
| 276 | 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] | 277 | if (maint1 && negative_viewport) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 278 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 279 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
| 280 | "VK_AMD_negative_viewport_height."); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 281 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 282 | } |
| 283 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 284 | { |
| 285 | bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 286 | bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 287 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 288 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 289 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 290 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 294 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 295 | // Check for get_physical_device_properties2 struct |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 296 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext); |
| 297 | if (features2) { |
| 298 | // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 299 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 300 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when " |
| 301 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 305 | auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
| 306 | if (features2) { |
| 307 | if (!instance_extensions.vk_khr_get_physical_device_properties_2) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 308 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 309 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, " |
| 310 | "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance."); |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 314 | const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; |
| 315 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
| 316 | if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { |
| 317 | skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", |
| 318 | "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); |
| 319 | } |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 320 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext); |
| 321 | if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed && |
| 322 | !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) { |
| 323 | skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348", |
| 324 | "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay " |
| 325 | "must also be VK_TRUE."); |
| 326 | } |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 327 | auto vertex_attribute_divisor_features = |
| 328 | lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
| 329 | if (vertex_attribute_divisor_features) { |
| 330 | bool extension_found = false; |
| 331 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) { |
| 332 | if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME, |
| 333 | VK_MAX_EXTENSION_NAME_SIZE)) { |
| 334 | extension_found = true; |
| 335 | break; |
| 336 | } |
| 337 | } |
| 338 | if (!extension_found) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 339 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 340 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 341 | "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] | 342 | } |
| 343 | } |
| 344 | |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 345 | const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
| 346 | if (vulkan_11_features) { |
| 347 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 348 | while (current) { |
| 349 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 350 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 351 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 352 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 353 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 354 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 355 | skip |= LogError( |
| 356 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 357 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 358 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 359 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 360 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 361 | break; |
| 362 | } |
| 363 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
| 368 | if (vulkan_12_features) { |
| 369 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 370 | while (current) { |
| 371 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 372 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 373 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 374 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 375 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 376 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 377 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 378 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 379 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 380 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 381 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 382 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 383 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 384 | skip |= LogError( |
| 385 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 386 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 387 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 388 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 389 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 390 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 391 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 392 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 393 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 394 | break; |
| 395 | } |
| 396 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 397 | } |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 398 | // Check features are enabled if matching extension is passed in as well |
| 399 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 400 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 401 | if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 402 | (vulkan_12_features->drawIndirectCount == VK_FALSE)) { |
| 403 | skip |= LogError( |
| 404 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831", |
| 405 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", |
| 406 | VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 407 | } |
| 408 | if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 409 | (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { |
| 410 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832", |
| 411 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " |
| 412 | "is not VK_TRUE.", |
| 413 | VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); |
| 414 | } |
| 415 | if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 416 | (vulkan_12_features->descriptorIndexing == VK_FALSE)) { |
| 417 | skip |= LogError( |
| 418 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833", |
| 419 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", |
| 420 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 421 | } |
| 422 | if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 423 | (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { |
| 424 | skip |= LogError( |
| 425 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834", |
| 426 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", |
| 427 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 428 | } |
| 429 | if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 430 | ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || |
| 431 | (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { |
| 432 | skip |= |
| 433 | LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835", |
| 434 | "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " |
| 435 | "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", |
| 436 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); |
| 437 | } |
| 438 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 439 | } |
| 440 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 441 | // Validate pCreateInfo->pQueueCreateInfos |
| 442 | if (pCreateInfo->pQueueCreateInfos) { |
| 443 | std::unordered_set<uint32_t> set; |
| 444 | |
| 445 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 446 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
| 447 | const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 448 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 449 | skip |= |
| 450 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 451 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 452 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 453 | "index value.", |
| 454 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 455 | } else if (set.count(requested_queue_family)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 456 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372", |
| 457 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 |
| 458 | ") is not unique within pCreateInfo->pQueueCreateInfos array.", |
| 459 | i, requested_queue_family); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 460 | } else { |
| 461 | set.insert(requested_queue_family); |
| 462 | } |
| 463 | |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 464 | if (queue_create_info.pQueuePriorities != nullptr) { |
| 465 | for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { |
| 466 | const float queue_priority = queue_create_info.pQueuePriorities[j]; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 467 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 468 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 469 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 470 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 471 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 472 | } |
| 473 | } |
| 474 | } |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 475 | |
| 476 | // Need to know if protectedMemory feature is passed in preCall to creating the device |
| 477 | VkBool32 protectedMemory = VK_FALSE; |
| 478 | const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = |
| 479 | lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
| 480 | if (protected_features) { |
| 481 | protectedMemory = protected_features->protectedMemory; |
| 482 | } else if (vulkan_11_features) { |
| 483 | protectedMemory = vulkan_11_features->protectedMemory; |
| 484 | } |
| 485 | if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) { |
| 486 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", |
| 487 | "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " |
| 488 | "protectedMemory feature being set as well."); |
| 489 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 493 | // feature dependencies for VK_KHR_variable_pointers |
| 494 | const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); |
| 495 | VkBool32 variablePointers = VK_FALSE; |
| 496 | VkBool32 variablePointersStorageBuffer = VK_FALSE; |
| 497 | if (vulkan_11_features) { |
| 498 | variablePointers = vulkan_11_features->variablePointers; |
| 499 | variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer; |
| 500 | } else if (variable_pointers_features) { |
| 501 | variablePointers = variable_pointers_features->variablePointers; |
| 502 | variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer; |
| 503 | } |
| 504 | if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) { |
| 505 | skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431", |
| 506 | "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE"); |
| 507 | } |
| 508 | |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 509 | // feature dependencies for VK_KHR_multiview |
| 510 | const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
| 511 | VkBool32 multiview = VK_FALSE; |
| 512 | VkBool32 multiviewGeometryShader = VK_FALSE; |
| 513 | VkBool32 multiviewTessellationShader = VK_FALSE; |
| 514 | if (vulkan_11_features) { |
| 515 | multiview = vulkan_11_features->multiview; |
| 516 | multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader; |
| 517 | multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader; |
| 518 | } else if (multiview_features) { |
| 519 | multiview = multiview_features->multiview; |
| 520 | multiviewGeometryShader = multiview_features->multiviewGeometryShader; |
| 521 | multiviewTessellationShader = multiview_features->multiviewTessellationShader; |
| 522 | } |
| 523 | if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) { |
| 524 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580", |
| 525 | "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 526 | } |
| 527 | if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) { |
| 528 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581", |
| 529 | "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 530 | } |
| 531 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 532 | return skip; |
| 533 | } |
| 534 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 535 | 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] | 536 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 537 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 538 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 539 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 540 | } |
| 541 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 542 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 543 | } |
| 544 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 545 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 546 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 547 | bool skip = false; |
| 548 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 549 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 550 | skip |= |
| 551 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 552 | |
| 553 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 554 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 555 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 556 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 557 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 558 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 559 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 563 | // queueFamilyIndexCount uint32_t values |
| 564 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 565 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 566 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 567 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 568 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 569 | } |
| 570 | } |
| 571 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 572 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
| 573 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915", |
| 574 | "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the " |
| 575 | "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set."); |
| 576 | } |
| 577 | |
| 578 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) { |
| 579 | skip |= |
| 580 | LogError(device, "VUID-VkBufferCreateInfo-flags-00916", |
| 581 | "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with " |
| 582 | "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set."); |
| 583 | } |
| 584 | |
| 585 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 586 | skip |= |
| 587 | LogError(device, "VUID-VkBufferCreateInfo-flags-00917", |
| 588 | "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with " |
| 589 | "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set."); |
| 590 | } |
| 591 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 592 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 593 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 594 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 595 | ((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] | 596 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 597 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 598 | "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] | 599 | } |
| 600 | } |
| 601 | |
| 602 | return skip; |
| 603 | } |
| 604 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 605 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 606 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 607 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 608 | |
| 609 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 610 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 611 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 612 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 613 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 614 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942", |
| 615 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 616 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 620 | // queueFamilyIndexCount uint32_t values |
| 621 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 622 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941", |
| 623 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 624 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 625 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 626 | } |
| 627 | } |
| 628 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 629 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 630 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 631 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 632 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 633 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 634 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 635 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 636 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 637 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 638 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 639 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 640 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 641 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 642 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 643 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 644 | skip |= LogError( |
| 645 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 646 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 647 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 648 | } |
| 649 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 650 | // 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] | 651 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 652 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 653 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 654 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 655 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 659 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 660 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 661 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 662 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 663 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 664 | ") are not equal.", |
| 665 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 669 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 670 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 671 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 672 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 673 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 677 | skip |= LogError( |
| 678 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 679 | "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] | 680 | } |
| 681 | } |
| 682 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 683 | // 3D image may have only 1 layer |
| 684 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 685 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 686 | "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] | 687 | } |
| 688 | |
| 689 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 690 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
| 691 | ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || |
Shannon McPherson | a886c2a | 2018-10-12 14:38:20 -0600 | [diff] [blame] | 692 | (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 693 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 694 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 698 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 699 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 700 | // At least one of the legal attachment bits must be set |
| 701 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 702 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 703 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 704 | } |
| 705 | // No flags other than the legal attachment bits may be set |
| 706 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 707 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 708 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 709 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 710 | } |
| 711 | } |
| 712 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 713 | // mipLevels must be less than or equal to the number of levels in the complete mipmap chain |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 714 | uint32_t maxDim = 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] | 715 | // Max mip levels is different for corner-sampled images vs normal images. |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 716 | uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim))) |
| 717 | : (uint32_t)(floor(log2(maxDim)) + 1); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 718 | if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 719 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 720 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 721 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 722 | "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] | 723 | } |
| 724 | |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 725 | 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] | 726 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 727 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 728 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 729 | } |
| 730 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 731 | 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] | 732 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 733 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 734 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 735 | } |
| 736 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 737 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 738 | skip |= LogError( |
| 739 | device, "VUID-VkImageCreateInfo-flags-01924", |
| 740 | "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the " |
| 741 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set."); |
| 742 | } |
| 743 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 744 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 745 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
| 746 | if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 747 | ((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] | 748 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 749 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 750 | "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] | 751 | } |
| 752 | |
| 753 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
| 754 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
| 755 | // Linear tiling is unsupported |
| 756 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 757 | skip |= LogError(device, kVUID_PVError_InvalidUsage, |
| 758 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 759 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | // Sparse 1D image isn't valid |
| 763 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 764 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 765 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 769 | 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] | 770 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 771 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 772 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 776 | 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] | 777 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 778 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 779 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | // Multi-sample 2D image when device doesn't support it |
| 783 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 784 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 785 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 786 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 787 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 788 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 789 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 790 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 791 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 792 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 793 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 794 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 795 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 796 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 797 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 798 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 799 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 800 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 801 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 802 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 803 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 804 | } |
| 805 | } |
| 806 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 807 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 808 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 809 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 810 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 811 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 812 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 813 | } |
| 814 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 815 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 816 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 817 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 818 | } |
| 819 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 820 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 821 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 822 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 823 | } |
| 824 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 825 | |
| 826 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 827 | 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] | 828 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 829 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 830 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 831 | } |
| 832 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 833 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 834 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 835 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 836 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must " |
| 837 | "not be a depth/stencil format."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 838 | } |
| 839 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 840 | 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] | 841 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 842 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 843 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 844 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 845 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 846 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 847 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 848 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 849 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 850 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 851 | } |
| 852 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 853 | |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 854 | if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) && |
| 855 | (FormatHasDepth(pCreateInfo->format) == false)) { |
| 856 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533", |
| 857 | "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the " |
| 858 | "format must be a depth or depth/stencil format."); |
| 859 | } |
| 860 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 861 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext); |
| 862 | if (image_stencil_struct != nullptr) { |
| 863 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 864 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 865 | // No flags other than the legal attachment bits may be set |
| 866 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 867 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 868 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 869 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 870 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 871 | "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] | 872 | } |
| 873 | } |
| 874 | |
| 875 | if (FormatIsDepthOrStencil(pCreateInfo->format)) { |
| 876 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 877 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
| 878 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 879 | LogError(device, "VUID-VkImageCreateInfo-Format-02536", |
| 880 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 881 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device " |
| 882 | "maxFramebufferWidth"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
| 886 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 887 | LogError(device, "VUID-VkImageCreateInfo-format-02537", |
| 888 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 889 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device " |
| 890 | "maxFramebufferHeight"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 891 | } |
| 892 | } |
| 893 | |
| 894 | if (!physical_device_features.shaderStorageImageMultisample && |
| 895 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 896 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 897 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 898 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 899 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 900 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 901 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 902 | } |
| 903 | |
| 904 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 905 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 906 | skip |= LogError( |
| 907 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 908 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 909 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 910 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 911 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 912 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 913 | skip |= LogError( |
| 914 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 915 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 916 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 917 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 918 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 919 | } |
| 920 | |
| 921 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 922 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 923 | skip |= LogError( |
| 924 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 925 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 926 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 927 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 928 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 929 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 930 | skip |= LogError( |
| 931 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 932 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 933 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 934 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 935 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 936 | } |
| 937 | } |
| 938 | } |
Spencer Fricke | ca52b5c | 2020-03-16 17:34:00 -0700 | [diff] [blame] | 939 | |
| 940 | if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 941 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 942 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968", |
| 943 | "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images " |
| 944 | "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
| 945 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 946 | |
| 947 | if (device_extensions.vk_ext_image_drm_format_modifier) { |
| 948 | const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext); |
| 949 | const auto drm_format_mod_explict = |
| 950 | lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext); |
| 951 | if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 952 | if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) || |
| 953 | ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) { |
| 954 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261", |
| 955 | "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have " |
| 956 | "either VkImageDrmFormatModifierListCreateInfoEXT or " |
| 957 | "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain"); |
| 958 | } |
| 959 | } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) { |
| 960 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262", |
| 961 | "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a " |
| 962 | "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT " |
| 963 | "in the pNext chain"); |
| 964 | } |
| 965 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 966 | |
| 967 | if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) { |
| 968 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 969 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557", |
| 970 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 971 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 972 | } |
| 973 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 974 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558", |
| 975 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 976 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
| 977 | } |
| 978 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 979 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 980 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 981 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 982 | } |
| 983 | } |
| 984 | if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) { |
| 985 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 986 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565", |
| 987 | "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 988 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 989 | } |
| 990 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 991 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566", |
| 992 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 993 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 994 | } |
| 995 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 996 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567", |
| 997 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 998 | "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT."); |
| 999 | } |
| 1000 | if (pCreateInfo->mipLevels != 1) { |
| 1001 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568", |
| 1002 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.", |
| 1003 | pCreateInfo->mipLevels); |
| 1004 | } |
| 1005 | } |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1006 | |
| 1007 | const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext); |
| 1008 | if (swapchain_create_info != nullptr) { |
| 1009 | if (swapchain_create_info->swapchain != VK_NULL_HANDLE) { |
| 1010 | // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the |
| 1011 | // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information |
| 1012 | // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation |
| 1013 | const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995"; |
| 1014 | const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image"; |
| 1015 | |
| 1016 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1017 | // also implicitly forces the check above that extent.depth is 1 |
| 1018 | skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message, |
| 1019 | string_VkImageType(pCreateInfo->imageType)); |
| 1020 | } |
| 1021 | if (pCreateInfo->mipLevels != 1) { |
| 1022 | skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message, |
| 1023 | pCreateInfo->mipLevels); |
| 1024 | } |
| 1025 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1026 | skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.", |
| 1027 | base_message, string_VkSampleCountFlagBits(pCreateInfo->samples)); |
| 1028 | } |
| 1029 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1030 | skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.", |
| 1031 | base_message, string_VkImageTiling(pCreateInfo->tiling)); |
| 1032 | } |
| 1033 | if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) { |
| 1034 | skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.", |
| 1035 | base_message, string_VkImageLayout(pCreateInfo->initialLayout)); |
| 1036 | } |
| 1037 | const VkImageCreateFlags valid_flags = |
| 1038 | (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT | |
| 1039 | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR); |
| 1040 | if ((pCreateInfo->flags & ~valid_flags) != 0) { |
| 1041 | skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message, |
| 1042 | pCreateInfo->flags); |
| 1043 | } |
| 1044 | } |
| 1045 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1046 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1047 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1048 | return skip; |
| 1049 | } |
| 1050 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1051 | bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 1052 | const VkAllocationCallbacks *pAllocator, VkImageView *pView) const { |
| 1053 | bool skip = false; |
| 1054 | |
| 1055 | if (pCreateInfo != nullptr) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1056 | // Validate feature set if using CUBE_ARRAY |
| 1057 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) { |
| 1058 | skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004", |
| 1059 | "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without " |
| 1060 | "enabling the imageCubeArray feature."); |
| 1061 | } |
| 1062 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1063 | if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 1064 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) { |
| 1065 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960", |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1066 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.", |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1067 | pCreateInfo->subresourceRange.layerCount); |
| 1068 | } |
| 1069 | 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] | 1070 | skip |= LogError( |
| 1071 | device, "VUID-VkImageViewCreateInfo-viewType-02961", |
| 1072 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.", |
| 1073 | pCreateInfo->subresourceRange.layerCount); |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1074 | } |
| 1075 | } |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1076 | |
| 1077 | auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext); |
| 1078 | if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) { |
| 1079 | if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) && |
| 1080 | (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) && |
| 1081 | (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) { |
| 1082 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230", |
| 1083 | "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be " |
| 1084 | "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32."); |
| 1085 | } |
| 1086 | if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) { |
| 1087 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084", |
| 1088 | "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and " |
| 1089 | "not an ASTC format.", |
| 1090 | string_VkFormat(pCreateInfo->format)); |
| 1091 | } |
| 1092 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1093 | |
| 1094 | auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
| 1095 | if (ycbcr_conversion != nullptr) { |
| 1096 | if (ycbcr_conversion->conversion != VK_NULL_HANDLE) { |
| 1097 | if (IsIdentitySwizzle(pCreateInfo->components) == false) { |
| 1098 | skip |= LogError( |
| 1099 | device, "VUID-VkImageViewCreateInfo-pNext-01970", |
| 1100 | "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must " |
| 1101 | "be created with the identity swizzle. Here are the actual swizzle values:\n" |
| 1102 | "r swizzle = %s\n" |
| 1103 | "g swizzle = %s\n" |
| 1104 | "b swizzle = %s\n" |
| 1105 | "a swizzle = %s\n", |
| 1106 | string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g), |
| 1107 | string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a)); |
| 1108 | } |
| 1109 | } |
| 1110 | } |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1111 | } |
| 1112 | return skip; |
| 1113 | } |
| 1114 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1115 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1116 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1117 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1118 | |
| 1119 | // Note: for numerical correctness |
| 1120 | // - float comparisons should expect NaN (comparison always false). |
| 1121 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 1122 | |
| 1123 | 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] | 1124 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1125 | if (v1_f <= 0.0f) return true; |
| 1126 | |
| 1127 | float intpart; |
| 1128 | const float fract = modff(v1_f, &intpart); |
| 1129 | |
| 1130 | assert(std::numeric_limits<float>::radix == 2); |
| 1131 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 1132 | if (intpart >= u32_max_plus1) return false; |
| 1133 | |
| 1134 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
| 1135 | if (v1_u32 < v2_u32) |
| 1136 | return true; |
| 1137 | else if (v1_u32 == v2_u32 && fract == 0.0f) |
| 1138 | return true; |
| 1139 | else |
| 1140 | return false; |
| 1141 | }; |
| 1142 | |
| 1143 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 1144 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 1145 | return (v1_f <= v2_f); |
| 1146 | }; |
| 1147 | |
| 1148 | // width |
| 1149 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1150 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1151 | |
| 1152 | if (!(viewport.width > 0.0f)) { |
| 1153 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1154 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 1155 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1156 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 1157 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1158 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 1159 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 1160 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1161 | } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1162 | skip |= LogWarning(object, kVUID_PVError_NONE, |
| 1163 | "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 |
| 1164 | "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.", |
| 1165 | fn_name, parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | // height |
| 1169 | bool height_healthy = true; |
Mark Lobodzinski | a09ab94 | 2020-02-20 11:01:59 -0700 | [diff] [blame] | 1170 | 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] | 1171 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1172 | |
| 1173 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1174 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1175 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 1176 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1177 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1178 | height_healthy = false; |
| 1179 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1180 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 1181 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 1182 | ").", |
| 1183 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1184 | } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) { |
| 1185 | height_healthy = false; |
| 1186 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1187 | skip |= LogWarning( |
| 1188 | object, kVUID_PVError_NONE, |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1189 | "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1190 | "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.", |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1191 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1192 | } |
| 1193 | |
| 1194 | // x |
| 1195 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1196 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1197 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1198 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 1199 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1200 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | // x + width |
| 1204 | if (x_healthy && width_healthy) { |
| 1205 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1206 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1207 | skip |= LogError( |
| 1208 | object, "VUID-VkViewport-x-01232", |
| 1209 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1210 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 1211 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1212 | } |
| 1213 | } |
| 1214 | |
| 1215 | // y |
| 1216 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1217 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1218 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1219 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 1220 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1221 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1222 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1223 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1224 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 1225 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1226 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | // y + height |
| 1230 | if (y_healthy && height_healthy) { |
| 1231 | const float boundary = viewport.y + viewport.height; |
| 1232 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1233 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1234 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 1235 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1236 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 1237 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1238 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1239 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1240 | LogError(object, "VUID-VkViewport-y-01777", |
| 1241 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 1242 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 1243 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1244 | } |
| 1245 | } |
| 1246 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1247 | if (!device_extensions.vk_ext_depth_range_unrestricted) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1248 | // minDepth |
| 1249 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1250 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1251 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1252 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 1253 | "[0.0, 1.0] range.", |
| 1254 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1255 | } |
| 1256 | |
| 1257 | // maxDepth |
| 1258 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1259 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1260 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1261 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 1262 | "[0.0, 1.0] range.", |
| 1263 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | return skip; |
| 1268 | } |
| 1269 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1270 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1271 | VkShadingRatePaletteEntryNV shadingRate; |
| 1272 | uint32_t width; |
| 1273 | uint32_t height; |
| 1274 | }; |
| 1275 | |
| 1276 | // All palette entries with more than one pixel per fragment |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1277 | static SampleOrderInfo sampleOrderInfos[] = { |
| 1278 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 1279 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 1280 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 1281 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 1282 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 1283 | {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] | 1284 | }; |
| 1285 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 1286 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1287 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1288 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 1289 | SampleOrderInfo *sampleOrderInfo; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1290 | uint32_t infoIdx = 0; |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 1291 | for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1292 | if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) { |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1293 | sampleOrderInfo = &sampleOrderInfos[infoIdx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1294 | break; |
| 1295 | } |
| 1296 | } |
| 1297 | |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1298 | if (sampleOrderInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1299 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 1300 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 1301 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1302 | return skip; |
| 1303 | } |
| 1304 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1305 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1306 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1307 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 1308 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 1309 | ") must " |
| 1310 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 1311 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 1312 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1313 | } |
| 1314 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1315 | if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1316 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 1317 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1318 | ") must " |
| 1319 | "be equal to the product of sampleCount (=%" PRIu32 |
| 1320 | "), the fragment width for shadingRate " |
| 1321 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
| 1322 | order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1323 | } |
| 1324 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1325 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1326 | skip |= LogError( |
| 1327 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1328 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1329 | ") must " |
| 1330 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1331 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1332 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1333 | |
| 1334 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1335 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 1336 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 1337 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1338 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1339 | uint64_t sampleLocationsMask = 0; |
| 1340 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
| 1341 | const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i]; |
| 1342 | if (sampleLoc->pixelX >= sampleOrderInfo->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1343 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 1344 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1345 | } |
| 1346 | if (sampleLoc->pixelY >= sampleOrderInfo->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1347 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 1348 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1349 | } |
| 1350 | if (sampleLoc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1351 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 1352 | "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] | 1353 | } |
| 1354 | uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY); |
| 1355 | sampleLocationsMask |= 1ULL << idx; |
| 1356 | } |
| 1357 | |
| 1358 | uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 1359 | if (sampleLocationsMask != expectedMask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1360 | skip |= LogError( |
| 1361 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1362 | "The array pSampleLocations must contain exactly one entry for " |
| 1363 | "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] | 1364 | } |
| 1365 | |
| 1366 | return skip; |
| 1367 | } |
| 1368 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1369 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 1370 | uint32_t createInfoCount, |
| 1371 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1372 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1373 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1374 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1375 | |
| 1376 | if (pCreateInfos != nullptr) { |
| 1377 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1378 | bool has_dynamic_viewport = false; |
| 1379 | bool has_dynamic_scissor = false; |
| 1380 | bool has_dynamic_line_width = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1381 | bool has_dynamic_depth_bias = false; |
| 1382 | bool has_dynamic_blend_constant = false; |
| 1383 | bool has_dynamic_depth_bounds = false; |
| 1384 | bool has_dynamic_stencil_compare = false; |
| 1385 | bool has_dynamic_stencil_write = false; |
| 1386 | bool has_dynamic_stencil_reference = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1387 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1388 | bool has_dynamic_discard_rectangle_ext = false; |
| 1389 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1390 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1391 | bool has_dynamic_shading_rate_palette_nv = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1392 | bool has_dynamic_viewport_course_sample_order_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1393 | bool has_dynamic_line_stipple = false; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1394 | bool has_dynamic_cull_mode = false; |
| 1395 | bool has_dynamic_front_face = false; |
| 1396 | bool has_dynamic_primitive_topology = false; |
| 1397 | bool has_dynamic_viewport_with_count = false; |
| 1398 | bool has_dynamic_scissor_with_count = false; |
| 1399 | bool has_dynamic_vertex_input_binding_stride = false; |
| 1400 | bool has_dynamic_depth_test_enable = false; |
| 1401 | bool has_dynamic_depth_write_enable = false; |
| 1402 | bool has_dynamic_depth_compare_op = false; |
| 1403 | bool has_dynamic_depth_bounds_test_enable = false; |
| 1404 | bool has_dynamic_stencil_test_enable = false; |
| 1405 | bool has_dynamic_stencil_op = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1406 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1407 | const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState; |
| 1408 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1409 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1410 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1411 | if (has_dynamic_viewport == true) { |
| 1412 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1413 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the " |
| 1414 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1415 | i); |
| 1416 | } |
| 1417 | has_dynamic_viewport = true; |
| 1418 | } |
| 1419 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) { |
| 1420 | if (has_dynamic_scissor == true) { |
| 1421 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1422 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the " |
| 1423 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1424 | i); |
| 1425 | } |
| 1426 | has_dynamic_scissor = true; |
| 1427 | } |
| 1428 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) { |
| 1429 | if (has_dynamic_line_width == true) { |
| 1430 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1431 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the " |
| 1432 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1433 | i); |
| 1434 | } |
| 1435 | has_dynamic_line_width = true; |
| 1436 | } |
| 1437 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) { |
| 1438 | if (has_dynamic_depth_bias == true) { |
| 1439 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1440 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the " |
| 1441 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1442 | i); |
| 1443 | } |
| 1444 | has_dynamic_depth_bias = true; |
| 1445 | } |
| 1446 | if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) { |
| 1447 | if (has_dynamic_blend_constant == true) { |
| 1448 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1449 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the " |
| 1450 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1451 | i); |
| 1452 | } |
| 1453 | has_dynamic_blend_constant = true; |
| 1454 | } |
| 1455 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) { |
| 1456 | if (has_dynamic_depth_bounds == true) { |
| 1457 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1458 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the " |
| 1459 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1460 | i); |
| 1461 | } |
| 1462 | has_dynamic_depth_bounds = true; |
| 1463 | } |
| 1464 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) { |
| 1465 | if (has_dynamic_stencil_compare == true) { |
| 1466 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1467 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in " |
| 1468 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1469 | i); |
| 1470 | } |
| 1471 | has_dynamic_stencil_compare = true; |
| 1472 | } |
| 1473 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) { |
| 1474 | if (has_dynamic_stencil_write == true) { |
| 1475 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1476 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in " |
| 1477 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1478 | i); |
| 1479 | } |
| 1480 | has_dynamic_stencil_write = true; |
| 1481 | } |
| 1482 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) { |
| 1483 | if (has_dynamic_stencil_reference == true) { |
| 1484 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1485 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in " |
| 1486 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1487 | i); |
| 1488 | } |
| 1489 | has_dynamic_stencil_reference = true; |
| 1490 | } |
| 1491 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) { |
| 1492 | if (has_dynamic_viewport_w_scaling_nv == true) { |
| 1493 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1494 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice " |
| 1495 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1496 | i); |
| 1497 | } |
| 1498 | has_dynamic_viewport_w_scaling_nv = true; |
| 1499 | } |
| 1500 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) { |
| 1501 | if (has_dynamic_discard_rectangle_ext == true) { |
| 1502 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1503 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice " |
| 1504 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1505 | i); |
| 1506 | } |
| 1507 | has_dynamic_discard_rectangle_ext = true; |
| 1508 | } |
| 1509 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) { |
| 1510 | if (has_dynamic_sample_locations_ext == true) { |
| 1511 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1512 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in " |
| 1513 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1514 | i); |
| 1515 | } |
| 1516 | has_dynamic_sample_locations_ext = true; |
| 1517 | } |
| 1518 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) { |
| 1519 | if (has_dynamic_exclusive_scissor_nv == true) { |
| 1520 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1521 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in " |
| 1522 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1523 | i); |
| 1524 | } |
| 1525 | has_dynamic_exclusive_scissor_nv = true; |
| 1526 | } |
| 1527 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) { |
| 1528 | if (has_dynamic_shading_rate_palette_nv == true) { |
| 1529 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1530 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was " |
| 1531 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1532 | i); |
| 1533 | } |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1534 | has_dynamic_shading_rate_palette_nv = true; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1535 | } |
| 1536 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) { |
| 1537 | if (has_dynamic_viewport_course_sample_order_nv == true) { |
| 1538 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1539 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was " |
| 1540 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1541 | i); |
| 1542 | } |
| 1543 | has_dynamic_viewport_course_sample_order_nv = true; |
| 1544 | } |
| 1545 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) { |
| 1546 | if (has_dynamic_line_stipple == true) { |
| 1547 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1548 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the " |
| 1549 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1550 | i); |
| 1551 | } |
| 1552 | has_dynamic_line_stipple = true; |
| 1553 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1554 | if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) { |
| 1555 | if (has_dynamic_cull_mode) { |
| 1556 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1557 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the " |
| 1558 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1559 | i); |
| 1560 | } |
| 1561 | has_dynamic_cull_mode = true; |
| 1562 | } |
| 1563 | if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) { |
| 1564 | if (has_dynamic_front_face) { |
| 1565 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1566 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the " |
| 1567 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1568 | i); |
| 1569 | } |
| 1570 | has_dynamic_front_face = true; |
| 1571 | } |
| 1572 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) { |
| 1573 | if (has_dynamic_primitive_topology) { |
| 1574 | skip |= LogError( |
| 1575 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1576 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the " |
| 1577 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1578 | i); |
| 1579 | } |
| 1580 | has_dynamic_primitive_topology = true; |
| 1581 | } |
| 1582 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) { |
| 1583 | if (has_dynamic_viewport_with_count) { |
| 1584 | skip |= LogError( |
| 1585 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1586 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the " |
| 1587 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1588 | i); |
| 1589 | } |
| 1590 | has_dynamic_viewport_with_count = true; |
| 1591 | } |
| 1592 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) { |
| 1593 | if (has_dynamic_scissor_with_count) { |
| 1594 | skip |= LogError( |
| 1595 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1596 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the " |
| 1597 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1598 | i); |
| 1599 | } |
| 1600 | has_dynamic_scissor_with_count = true; |
| 1601 | } |
| 1602 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) { |
| 1603 | if (has_dynamic_vertex_input_binding_stride) { |
| 1604 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1605 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was " |
| 1606 | "listed twice in the " |
| 1607 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1608 | i); |
| 1609 | } |
| 1610 | has_dynamic_vertex_input_binding_stride = true; |
| 1611 | } |
| 1612 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) { |
| 1613 | if (has_dynamic_depth_test_enable) { |
| 1614 | skip |= LogError( |
| 1615 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1616 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the " |
| 1617 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1618 | i); |
| 1619 | } |
| 1620 | has_dynamic_depth_test_enable = true; |
| 1621 | } |
| 1622 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) { |
| 1623 | if (has_dynamic_depth_write_enable) { |
| 1624 | skip |= LogError( |
| 1625 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1626 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the " |
| 1627 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1628 | i); |
| 1629 | } |
| 1630 | has_dynamic_depth_write_enable = true; |
| 1631 | } |
| 1632 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) { |
| 1633 | if (has_dynamic_depth_compare_op) { |
| 1634 | skip |= |
| 1635 | LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1636 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the " |
| 1637 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1638 | i); |
| 1639 | } |
| 1640 | has_dynamic_depth_compare_op = true; |
| 1641 | } |
| 1642 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) { |
| 1643 | if (has_dynamic_depth_bounds_test_enable) { |
| 1644 | skip |= LogError( |
| 1645 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1646 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the " |
| 1647 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1648 | i); |
| 1649 | } |
| 1650 | has_dynamic_depth_bounds_test_enable = true; |
| 1651 | } |
| 1652 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) { |
| 1653 | if (has_dynamic_stencil_test_enable) { |
| 1654 | skip |= LogError( |
| 1655 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1656 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the " |
| 1657 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1658 | i); |
| 1659 | } |
| 1660 | has_dynamic_stencil_test_enable = true; |
| 1661 | } |
| 1662 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) { |
| 1663 | if (has_dynamic_stencil_op) { |
| 1664 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1665 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the " |
| 1666 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1667 | i); |
| 1668 | } |
| 1669 | has_dynamic_stencil_op = true; |
| 1670 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1671 | } |
| 1672 | } |
| 1673 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1674 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 1675 | if ((feedback_struct != nullptr) && |
| 1676 | (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1677 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668", |
| 1678 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 1679 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 1680 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
| 1681 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1682 | } |
| 1683 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1684 | // 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] | 1685 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1686 | // Collect active stages and other information |
| 1687 | // Only want to loop through pStages once |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1688 | uint32_t active_shaders = 0; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1689 | bool has_eval = false; |
| 1690 | bool has_control = false; |
| 1691 | if (pCreateInfos[i].pStages != nullptr) { |
| 1692 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 1693 | active_shaders |= pCreateInfos[i].pStages[stage_index].stage; |
| 1694 | |
| 1695 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 1696 | has_control = true; |
| 1697 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 1698 | has_eval = true; |
| 1699 | } |
| 1700 | |
| 1701 | skip |= validate_string( |
| 1702 | "vkCreateGraphicsPipelines", |
| 1703 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}), |
| 1704 | "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName); |
| 1705 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1706 | } |
| 1707 | |
| 1708 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
| 1709 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) { |
| 1710 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 1711 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 1712 | pCreateInfos[i].pTessellationState, |
| 1713 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1714 | "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
| 1715 | |
| 1716 | const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = { |
| 1717 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 1718 | |
| 1719 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
| 1720 | "VkPipelineTessellationDomainOriginStateCreateInfo", |
| 1721 | pCreateInfos[i].pTessellationState->pNext, |
| 1722 | ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo), |
| 1723 | allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1724 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 1725 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1726 | |
| 1727 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
| 1728 | pCreateInfos[i].pTessellationState->flags, |
| 1729 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 1730 | } |
| 1731 | |
| 1732 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) { |
| 1733 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 1734 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
| 1735 | pCreateInfos[i].pInputAssemblyState, |
| 1736 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1737 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 1738 | |
| 1739 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
| 1740 | pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1741 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1742 | |
| 1743 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
| 1744 | pCreateInfos[i].pInputAssemblyState->flags, |
| 1745 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 1746 | |
| 1747 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 1748 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
| 1749 | pCreateInfos[i].pInputAssemblyState->topology, |
| 1750 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 1751 | |
| 1752 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
| 1753 | pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable); |
| 1754 | } |
| 1755 | |
| 1756 | 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] | 1757 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1758 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1759 | if (pCreateInfos[i].pVertexInputState->flags != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1760 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 1761 | "vkCreateGraphicsPipelines: pararameter " |
| 1762 | "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.", |
| 1763 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1764 | } |
| 1765 | |
| 1766 | const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = { |
| 1767 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
| 1768 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 1769 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", |
| 1770 | pCreateInfos[i].pVertexInputState->pNext, 1, |
| 1771 | allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1772 | "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
| 1773 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1774 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 1775 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 1776 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1777 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 1778 | skip |= |
| 1779 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 1780 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
| 1781 | pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount, |
| 1782 | &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
| 1783 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 1784 | |
| 1785 | skip |= validate_array( |
| 1786 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 1787 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 1788 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 1789 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 1790 | |
| 1791 | if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) { |
| 1792 | for (uint32_t vertexBindingDescriptionIndex = 0; |
| 1793 | vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount; |
| 1794 | ++vertexBindingDescriptionIndex) { |
| 1795 | skip |= validate_ranged_enum( |
| 1796 | "vkCreateGraphicsPipelines", |
| 1797 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 1798 | AllVkVertexInputRateEnums, |
| 1799 | pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate, |
| 1800 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 1801 | } |
| 1802 | } |
| 1803 | |
| 1804 | if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) { |
| 1805 | for (uint32_t vertexAttributeDescriptionIndex = 0; |
| 1806 | vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount; |
| 1807 | ++vertexAttributeDescriptionIndex) { |
| 1808 | skip |= validate_ranged_enum( |
| 1809 | "vkCreateGraphicsPipelines", |
| 1810 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 1811 | AllVkFormatEnums, |
| 1812 | pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format, |
| 1813 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
| 1814 | } |
| 1815 | } |
| 1816 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1817 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1818 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 1819 | "vkCreateGraphicsPipelines: pararameter " |
| 1820 | "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is " |
| 1821 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1822 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1823 | } |
| 1824 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1825 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1826 | skip |= |
| 1827 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 1828 | "vkCreateGraphicsPipelines: pararameter " |
| 1829 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is " |
| 1830 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1831 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1832 | } |
| 1833 | |
| 1834 | std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1835 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 1836 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1837 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 1838 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1839 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 1840 | "vkCreateGraphicsPipelines: parameter " |
| 1841 | "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding " |
| 1842 | "(%" PRIu32 ") is not distinct.", |
| 1843 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1844 | } |
| 1845 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 1846 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1847 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1848 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 1849 | "vkCreateGraphicsPipelines: parameter " |
| 1850 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
| 1851 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1852 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1853 | } |
| 1854 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1855 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1856 | skip |= |
| 1857 | LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 1858 | "vkCreateGraphicsPipelines: parameter " |
| 1859 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
| 1860 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).", |
| 1861 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1862 | } |
| 1863 | } |
| 1864 | |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1865 | std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1866 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 1867 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1868 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 1869 | if (location_it != attribute_locations.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1870 | skip |= LogError( |
| 1871 | device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1872 | "vkCreateGraphicsPipelines: parameter " |
| 1873 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.", |
| 1874 | i, d, vertex_attrib_desc.location); |
| 1875 | } |
| 1876 | attribute_locations.insert(vertex_attrib_desc.location); |
| 1877 | |
| 1878 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 1879 | if (binding_it == vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1880 | skip |= LogError( |
| 1881 | device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1882 | "vkCreateGraphicsPipelines: parameter " |
| 1883 | " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist " |
| 1884 | "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.", |
| 1885 | i, d, vertex_attrib_desc.binding, i); |
| 1886 | } |
| 1887 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1888 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1889 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 1890 | "vkCreateGraphicsPipelines: parameter " |
| 1891 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
| 1892 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1893 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1894 | } |
| 1895 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1896 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1897 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 1898 | "vkCreateGraphicsPipelines: parameter " |
| 1899 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
| 1900 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1901 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1902 | } |
| 1903 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1904 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1905 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 1906 | "vkCreateGraphicsPipelines: parameter " |
| 1907 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 1908 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).", |
| 1909 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1910 | } |
| 1911 | } |
| 1912 | } |
| 1913 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1914 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 1915 | if (has_control && has_eval) { |
| 1916 | if (pCreateInfos[i].pTessellationState == nullptr) { |
| 1917 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
| 1918 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 1919 | "shader stage and a tessellation evaluation shader stage, " |
| 1920 | "pCreateInfos[%d].pTessellationState must not be NULL.", |
| 1921 | i, i); |
| 1922 | } else { |
| 1923 | const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
| 1924 | skip |= validate_struct_pnext( |
| 1925 | "vkCreateGraphicsPipelines", |
| 1926 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
| 1927 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1, |
| 1928 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 1929 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1930 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1931 | skip |= validate_reserved_flags( |
| 1932 | "vkCreateGraphicsPipelines", |
| 1933 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
| 1934 | pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1935 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1936 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
| 1937 | pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
| 1938 | skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 1939 | "vkCreateGraphicsPipelines: invalid parameter " |
| 1940 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
| 1941 | "should be >0 and <=%u.", |
| 1942 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
| 1943 | device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1944 | } |
| 1945 | } |
| 1946 | } |
| 1947 | |
| 1948 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 1949 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 1950 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 1951 | if (pCreateInfos[i].pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1952 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 1953 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 1954 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 1955 | "].pViewportState (=NULL) is not a valid pointer.", |
| 1956 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1957 | } else { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1958 | const auto &viewport_state = *pCreateInfos[i].pViewportState; |
| 1959 | |
| 1960 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1961 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 1962 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1963 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 1964 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1965 | } |
| 1966 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1967 | const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = { |
| 1968 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1969 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 1970 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1971 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 1972 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1973 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1974 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1975 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1976 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1977 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1978 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
| 1979 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1980 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo), |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1981 | allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
| 1982 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1983 | |
| 1984 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1985 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1986 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1987 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1988 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1989 | auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>( |
| 1990 | pCreateInfos[i].pViewportState->pNext); |
| 1991 | auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>( |
| 1992 | pCreateInfos[i].pViewportState->pNext); |
| 1993 | auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>( |
| 1994 | pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 1995 | const auto vp_swizzle_struct = |
| 1996 | lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1997 | const auto vp_w_scaling_struct = |
| 1998 | lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1999 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2000 | if (!physical_device_features.multiViewport) { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2001 | if (viewport_state.viewportCount != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2002 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 2003 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2004 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 2005 | ") is not 1.", |
| 2006 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2007 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2008 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2009 | if (viewport_state.scissorCount != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2010 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 2011 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2012 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2013 | ") is not 1.", |
| 2014 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2015 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2016 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2017 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 2018 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2019 | skip |= LogError( |
| 2020 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 2021 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2022 | "disabled, but pCreateInfos[%" PRIu32 |
| 2023 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 2024 | ") is not 1.", |
| 2025 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2026 | } |
| 2027 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2028 | if (shading_rate_image_struct && |
| 2029 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2030 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 2031 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2032 | "disabled, but pCreateInfos[%" PRIu32 |
| 2033 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 2034 | ") is neither 0 nor 1.", |
| 2035 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2036 | } |
| 2037 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2038 | } else { // multiViewport enabled |
| 2039 | if (viewport_state.viewportCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2040 | if (!has_dynamic_viewport_with_count) { |
| 2041 | skip |= LogError( |
| 2042 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
| 2043 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
| 2044 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2045 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2046 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 2047 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2048 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2049 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2050 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2051 | } else if (has_dynamic_viewport_with_count) { |
| 2052 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379", |
| 2053 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2054 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2055 | ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.", |
| 2056 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2057 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2058 | |
| 2059 | if (viewport_state.scissorCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2060 | if (!has_dynamic_scissor_with_count) { |
| 2061 | skip |= LogError( |
| 2062 | device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength", |
| 2063 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
| 2064 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2065 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2066 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 2067 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2068 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2069 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2070 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2071 | } else if (has_dynamic_scissor_with_count) { |
| 2072 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380", |
| 2073 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2074 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2075 | ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.", |
| 2076 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2077 | } |
| 2078 | } |
| 2079 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2080 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2081 | skip |= |
| 2082 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 2083 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2084 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2085 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2086 | } |
| 2087 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2088 | 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] | 2089 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 2090 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2091 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2092 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2093 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2094 | } |
| 2095 | |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2096 | if (viewport_state.scissorCount != viewport_state.viewportCount && |
| 2097 | !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2098 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220", |
| 2099 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2100 | "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32 |
| 2101 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2102 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2103 | } |
| 2104 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2105 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2106 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2107 | skip |= |
| 2108 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 2109 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2110 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 2111 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2112 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2113 | } |
| 2114 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2115 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2116 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2117 | skip |= LogError( |
| 2118 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2119 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 2120 | "] " |
| 2121 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2122 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2123 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2124 | } |
| 2125 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2126 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2127 | skip |= LogError( |
| 2128 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2129 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 2130 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2131 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 2132 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2133 | } |
| 2134 | |
| 2135 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2136 | skip |= LogError( |
| 2137 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2138 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 2139 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2140 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 2141 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2142 | } |
| 2143 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2144 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2145 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 2146 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 2147 | skip |= |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2148 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2149 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 2150 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 2151 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 2152 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2153 | } |
| 2154 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2155 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2156 | shading_rate_image_struct->viewportCount > 0 && |
| 2157 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2158 | skip |= LogError( |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2159 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2160 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2161 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 2162 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2163 | i, i); |
| 2164 | } |
| 2165 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2166 | if (vp_swizzle_struct) { |
| 2167 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2168 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 2169 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 2170 | " does " |
| 2171 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 2172 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2173 | } |
| 2174 | } |
| 2175 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2176 | // validate the VkViewports |
| 2177 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 2178 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 2179 | 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] | 2180 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 2181 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 2182 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 2183 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2184 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2185 | } |
| 2186 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2187 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2188 | 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] | 2189 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2190 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2191 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 2192 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 2193 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2194 | } |
| 2195 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2196 | if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2197 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2198 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2199 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 2200 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 2201 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2202 | } |
| 2203 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2204 | if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2205 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2206 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2207 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 2208 | "VK_EXT_sample_locations extension is not enabled.", |
| 2209 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2210 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2211 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2212 | if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2213 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2214 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2215 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 2216 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 2217 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2218 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2219 | |
| 2220 | if (coarse_sample_order_struct && |
| 2221 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 2222 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2223 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 2224 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2225 | "] " |
| 2226 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 2227 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 2228 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2229 | } |
| 2230 | |
| 2231 | if (coarse_sample_order_struct) { |
| 2232 | 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] | 2233 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2234 | } |
| 2235 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2236 | |
| 2237 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 2238 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2239 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 2240 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2241 | "] " |
| 2242 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 2243 | ") " |
| 2244 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 2245 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2246 | } |
| 2247 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2248 | skip |= LogError( |
| 2249 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2250 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2251 | "] " |
| 2252 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 2253 | i); |
| 2254 | } |
| 2255 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2256 | } |
| 2257 | |
| 2258 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2259 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
| 2260 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 2261 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.", |
| 2262 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2263 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2264 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
| 2265 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 2266 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 2267 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2268 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2269 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2270 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2271 | "vkCreateGraphicsPipelines", |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2272 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2273 | valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2274 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 2275 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2276 | |
| 2277 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2278 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2279 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2280 | pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2281 | |
| 2282 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2283 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2284 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 2285 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 2286 | |
| 2287 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2288 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2289 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2290 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2291 | pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2292 | true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2293 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2294 | skip |= validate_flags( |
| 2295 | "vkCreateGraphicsPipelines", |
| 2296 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2297 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2298 | kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2299 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2300 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2301 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2302 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 2303 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 2304 | |
| 2305 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2306 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2307 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 2308 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 2309 | |
| 2310 | if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2311 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 2312 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 2313 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 2314 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2315 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2316 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2317 | if (!physical_device_features.sampleRateShading) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2318 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 2319 | "vkCreateGraphicsPipelines(): parameter " |
| 2320 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.", |
| 2321 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2322 | } |
| 2323 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 2324 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
| 2325 | if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2326 | skip |= LogError( |
| 2327 | device, |
| 2328 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2329 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2330 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2331 | } |
| 2332 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2333 | |
| 2334 | const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>( |
| 2335 | pCreateInfos[i].pRasterizationState->pNext); |
| 2336 | |
| 2337 | if (line_state) { |
| 2338 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 2339 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
| 2340 | if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) { |
| 2341 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2342 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2343 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2344 | "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
| 2345 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2346 | } |
| 2347 | if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) { |
| 2348 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2349 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2350 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2351 | "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
| 2352 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2353 | } |
| 2354 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) { |
| 2355 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2356 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2357 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2358 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
| 2359 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2360 | } |
| 2361 | } |
| 2362 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 2363 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 2364 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2365 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
| 2366 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the " |
| 2367 | "range [1,256].", |
| 2368 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2369 | } |
| 2370 | } |
| 2371 | const auto *line_features = |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 2372 | lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2373 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2374 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2375 | skip |= |
| 2376 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
| 2377 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2378 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 2379 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2380 | } |
| 2381 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2382 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2383 | skip |= |
| 2384 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
| 2385 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2386 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 2387 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2388 | } |
| 2389 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2390 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2391 | skip |= |
| 2392 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
| 2393 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2394 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 2395 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2396 | } |
| 2397 | if (line_state->stippledLineEnable) { |
| 2398 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2399 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2400 | skip |= |
| 2401 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
| 2402 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2403 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 2404 | "stippledRectangularLines feature.", |
| 2405 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2406 | } |
| 2407 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2408 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2409 | skip |= |
| 2410 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
| 2411 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2412 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 2413 | "stippledBresenhamLines feature.", |
| 2414 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2415 | } |
| 2416 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2417 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2418 | skip |= |
| 2419 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
| 2420 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2421 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 2422 | "stippledSmoothLines feature.", |
| 2423 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2424 | } |
| 2425 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
| 2426 | (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2427 | skip |= |
| 2428 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
| 2429 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2430 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 2431 | "stippledRectangularLines and strictLines features.", |
| 2432 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2433 | } |
| 2434 | } |
| 2435 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2436 | } |
| 2437 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2438 | bool uses_color_attachment = false; |
| 2439 | bool uses_depthstencil_attachment = false; |
| 2440 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2441 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2442 | const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass); |
| 2443 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2444 | const auto &subpasses_uses = subpasses_uses_it->second; |
| 2445 | if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) |
| 2446 | uses_color_attachment = true; |
| 2447 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) |
| 2448 | uses_depthstencil_attachment = true; |
| 2449 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2450 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2451 | } |
| 2452 | |
| 2453 | if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2454 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2455 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2456 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2457 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2458 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2459 | |
| 2460 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2461 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2462 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2463 | pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2464 | |
| 2465 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2466 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2467 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 2468 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 2469 | |
| 2470 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2471 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2472 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 2473 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 2474 | |
| 2475 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2476 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2477 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 2478 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2479 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2480 | |
| 2481 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2482 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2483 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 2484 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 2485 | |
| 2486 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2487 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2488 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 2489 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 2490 | |
| 2491 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2492 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2493 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 2494 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2495 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2496 | |
| 2497 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2498 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2499 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 2500 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2501 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2502 | |
| 2503 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2504 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2505 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 2506 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2507 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2508 | |
| 2509 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2510 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2511 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 2512 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2513 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2514 | |
| 2515 | skip |= validate_ranged_enum( |
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->back.failOp", ParameterName::IndexVector{i}), |
| 2518 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2519 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2520 | |
| 2521 | skip |= validate_ranged_enum( |
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->back.passOp", ParameterName::IndexVector{i}), |
| 2524 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2525 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2526 | |
| 2527 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2528 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2529 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 2530 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2531 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2532 | |
| 2533 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2534 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2535 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 2536 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2537 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2538 | |
| 2539 | if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2540 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 2541 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 2542 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 2543 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2544 | } |
| 2545 | } |
| 2546 | |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2547 | const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = { |
| 2548 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT}; |
| 2549 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2550 | if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2551 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 2552 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 2553 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2554 | pCreateInfos[i].pColorBlendState, |
| 2555 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2556 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
| 2557 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2558 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2559 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2560 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
| 2561 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext, |
| 2562 | ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo), |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2563 | allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2564 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 2565 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2566 | |
| 2567 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2568 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2569 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2570 | pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2571 | |
| 2572 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2573 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2574 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 2575 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 2576 | |
| 2577 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2578 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2579 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 2580 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2581 | pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2582 | true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2583 | |
| 2584 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
| 2585 | for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 2586 | ++attachmentIndex) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2587 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2588 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
| 2589 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2590 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable); |
| 2591 | |
| 2592 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2593 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2594 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
| 2595 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2596 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2597 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2598 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2599 | |
| 2600 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2601 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2602 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
| 2603 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2604 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2605 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2606 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2607 | |
| 2608 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2609 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2610 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
| 2611 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2612 | "VkBlendOp", AllVkBlendOpEnums, |
| 2613 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2614 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2615 | |
| 2616 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2617 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2618 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
| 2619 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2620 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2621 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2622 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2623 | |
| 2624 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2625 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2626 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
| 2627 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2628 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2629 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2630 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2631 | |
| 2632 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2633 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2634 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
| 2635 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2636 | "VkBlendOp", AllVkBlendOpEnums, |
| 2637 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2638 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2639 | |
| 2640 | skip |= |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2641 | validate_flags("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2642 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
| 2643 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2644 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
| 2645 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2646 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2647 | } |
| 2648 | } |
| 2649 | |
| 2650 | if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2651 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 2652 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 2653 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2654 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2655 | } |
| 2656 | |
| 2657 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 2658 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 2659 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2660 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2661 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2662 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, |
| 2663 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2664 | } |
| 2665 | } |
| 2666 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2667 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2668 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 2669 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 2670 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2671 | skip |= |
| 2672 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2673 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2674 | "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] | 2675 | "and pCreateInfos->basePipelineIndex is not -1.", |
| 2676 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2677 | } |
| 2678 | } |
| 2679 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2680 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 2681 | if (pCreateInfos[i].basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2682 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2683 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2684 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2685 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 2686 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2687 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2688 | } else { |
Mike Schuchardt | e5c15cf | 2020-04-06 22:57:13 -0700 | [diff] [blame] | 2689 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2690 | skip |= |
| 2691 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
| 2692 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid" |
| 2693 | "index into the pCreateInfos array, of size %d.", |
| 2694 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2695 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2696 | } |
| 2697 | } |
| 2698 | |
sfricke-samsung | 898cf22 | 2020-05-15 23:10:19 -0700 | [diff] [blame] | 2699 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) { |
| 2700 | skip |= LogError( |
| 2701 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764", |
| 2702 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE", |
| 2703 | i); |
| 2704 | } |
| 2705 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2706 | if (pCreateInfos[i].pRasterizationState) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2707 | if (!device_extensions.vk_nv_fill_rectangle) { |
| 2708 | if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
| 2709 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2710 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 2711 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 2712 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 2713 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2714 | } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2715 | (physical_device_features.fillModeNonSolid == false)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2716 | skip |= LogError(device, kVUID_PVError_DeviceFeature, |
| 2717 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2718 | "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
| 2719 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2720 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2721 | } |
| 2722 | } else { |
| 2723 | if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2724 | (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
| 2725 | (physical_device_features.fillModeNonSolid == false)) { |
| 2726 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2727 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 2728 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2729 | "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
| 2730 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2731 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2732 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2733 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2734 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2735 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2736 | (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2737 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 2738 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 2739 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 2740 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 2741 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
| 2742 | i, i, pCreateInfos[i].pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2743 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2744 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2745 | } |
| 2746 | } |
| 2747 | |
| 2748 | return skip; |
| 2749 | } |
| 2750 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2751 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 2752 | uint32_t createInfoCount, |
| 2753 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 2754 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2755 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2756 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2757 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2758 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2759 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 2760 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2761 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 2762 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2763 | skip |= |
| 2764 | LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669", |
| 2765 | "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32 |
| 2766 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".", |
| 2767 | i, feedback_struct->pipelineStageCreationFeedbackCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2768 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2769 | |
| 2770 | // Make sure compute stage is selected |
| 2771 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2772 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
| 2773 | "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
| 2774 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2775 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2776 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2777 | return skip; |
| 2778 | } |
| 2779 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2780 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2781 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2782 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2783 | |
| 2784 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2785 | const auto &features = physical_device_features; |
| 2786 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2787 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2788 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 2789 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2790 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 2791 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 2792 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 2793 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2794 | } |
| 2795 | |
| 2796 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 2797 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2798 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 2799 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 2800 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2801 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2802 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2803 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2804 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 2805 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2806 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 2807 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2808 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2809 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2810 | } |
| 2811 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2812 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 2813 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2814 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 2815 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2816 | } |
| 2817 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2818 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 2819 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2820 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 2821 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2822 | } |
| 2823 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2824 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2825 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2826 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2827 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 2828 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2829 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 2830 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 2831 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 2832 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2833 | } |
| 2834 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2835 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 2836 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2837 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2838 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2839 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2840 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 2841 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2842 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2843 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2844 | } |
| 2845 | |
| 2846 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 2847 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2848 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 2849 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 2850 | const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext); |
| 2851 | if (sampler_reduction != nullptr) { |
| 2852 | if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
| 2853 | skip |= LogError( |
| 2854 | device, "VUID-VkSamplerCreateInfo-compareEnable-01423", |
| 2855 | "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE."); |
| 2856 | } |
| 2857 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2858 | } |
| 2859 | |
| 2860 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 2861 | // valid VkBorderColor value |
| 2862 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2863 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2864 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2865 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 2866 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2867 | } |
| 2868 | |
| 2869 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the |
| 2870 | // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2871 | if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2872 | ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2873 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2874 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2875 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2876 | LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079", |
| 2877 | "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE " |
| 2878 | "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] | 2879 | } |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2880 | |
| 2881 | // Checks for the IMG cubic filtering extension |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2882 | if (device_extensions.vk_img_filter_cubic) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2883 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 2884 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2885 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 2886 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 2887 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2888 | } |
| 2889 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2890 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2891 | // Check for valid Lod range |
| 2892 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2893 | skip |= |
| 2894 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 2895 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2896 | } |
| 2897 | |
| 2898 | // Check mipLodBias to device limit |
| 2899 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2900 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 2901 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 2902 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2903 | } |
| 2904 | |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2905 | const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
| 2906 | if (sampler_conversion != nullptr) { |
| 2907 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2908 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2909 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2910 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2911 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2912 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2913 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 2914 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 2915 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 2916 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 2917 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 2918 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 2919 | } |
| 2920 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 2921 | |
| 2922 | if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) { |
| 2923 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
| 2924 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574", |
| 2925 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2926 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2927 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
| 2928 | } |
| 2929 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
| 2930 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575", |
| 2931 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2932 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 2933 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
| 2934 | } |
| 2935 | if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) { |
| 2936 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576", |
| 2937 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2938 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.", |
| 2939 | pCreateInfo->minLod, pCreateInfo->maxLod); |
| 2940 | } |
| 2941 | if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 2942 | (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) || |
| 2943 | ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 2944 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) { |
| 2945 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577", |
| 2946 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2947 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be " |
| 2948 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER", |
| 2949 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 2950 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
| 2951 | } |
| 2952 | if (pCreateInfo->anisotropyEnable) { |
| 2953 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578", |
| 2954 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2955 | "pCreateInfo->anisotropyEnable must be VK_FALSE"); |
| 2956 | } |
| 2957 | if (pCreateInfo->compareEnable) { |
| 2958 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579", |
| 2959 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2960 | "pCreateInfo->compareEnable must be VK_FALSE"); |
| 2961 | } |
| 2962 | if (pCreateInfo->unnormalizedCoordinates) { |
| 2963 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580", |
| 2964 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2965 | "pCreateInfo->unnormalizedCoordinates must be VK_FALSE"); |
| 2966 | } |
| 2967 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2968 | } |
| 2969 | |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 2970 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 2971 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
| 2972 | if (!device_extensions.vk_ext_custom_border_color) { |
| 2973 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2974 | "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n", |
| 2975 | string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 2976 | } |
| 2977 | auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext); |
| 2978 | if (!custom_create_info) { |
| 2979 | skip |= |
| 2980 | LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011", |
| 2981 | "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT " |
| 2982 | "struct in pNext chain.\n", |
| 2983 | string_VkBorderColor(pCreateInfo->borderColor)); |
| 2984 | } else { |
| 2985 | if ((custom_create_info->format != VK_FORMAT_UNDEFINED) && |
| 2986 | ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) || |
| 2987 | (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT && |
| 2988 | !FormatIsSampledFloat(custom_create_info->format)))) { |
| 2989 | skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013", |
| 2990 | "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s " |
| 2991 | "whose type does not match\n", |
| 2992 | string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format)); |
| 2993 | ; |
| 2994 | } |
| 2995 | } |
| 2996 | } |
| 2997 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2998 | return skip; |
| 2999 | } |
| 3000 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3001 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 3002 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 3003 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3004 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3005 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3006 | |
| 3007 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3008 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 3009 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 3010 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3011 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3012 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 3013 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 3014 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 3015 | ++descriptor_index) { |
| 3016 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Spencer Fricke | b0e3082 | 2020-03-23 10:32:30 -0700 | [diff] [blame] | 3017 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3018 | "vkCreateDescriptorSetLayout: required parameter " |
| 3019 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE", |
| 3020 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3021 | } |
| 3022 | } |
| 3023 | } |
| 3024 | |
| 3025 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 3026 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3027 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3028 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
| 3029 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 3030 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits " |
| 3031 | "values.", |
| 3032 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3033 | } |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 3034 | |
| 3035 | if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) && |
| 3036 | (pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3037 | (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) { |
| 3038 | skip |= |
| 3039 | LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510", |
| 3040 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and " |
| 3041 | "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags " |
| 3042 | "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s", |
| 3043 | i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str()); |
| 3044 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3045 | } |
| 3046 | } |
| 3047 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3048 | return skip; |
| 3049 | } |
| 3050 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3051 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 3052 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3053 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3054 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3055 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3056 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3057 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 3058 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3059 | } |
| 3060 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3061 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 3062 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3063 | const bool validateDstSet) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3064 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3065 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3066 | if (pDescriptorWrites != NULL) { |
| 3067 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 3068 | // descriptorCount must be greater than 0 |
| 3069 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 3070 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3071 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 3072 | "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3073 | } |
| 3074 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3075 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
| 3076 | if (validateDstSet) { |
| 3077 | // dstSet must be a valid VkDescriptorSet handle |
| 3078 | skip |= validate_required_handle(vkCallingFunction, |
| 3079 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 3080 | pDescriptorWrites[i].dstSet); |
| 3081 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3082 | |
| 3083 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3084 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 3085 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 3086 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 3087 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 3088 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 3089 | // 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] | 3090 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures. |
| 3091 | // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3092 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3093 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322", |
| 3094 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3095 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 3096 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 3097 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.", |
| 3098 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3099 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 3100 | // 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] | 3101 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout |
| 3102 | // member of any given element of pImageInfo must be a valid VkImageLayout |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3103 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 3104 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3105 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3106 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 3107 | ParameterName::IndexVector{i, descriptor_index}), |
| 3108 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3109 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3110 | } |
| 3111 | } |
| 3112 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3113 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3114 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 3115 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 3116 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 3117 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 3118 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3119 | // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3120 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3121 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
| 3122 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3123 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 3124 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
| 3125 | "pDescriptorWrites[%d].pBufferInfo must not be NULL.", |
| 3126 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3127 | } else { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3128 | const auto *robustness2_features = |
| 3129 | lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 3130 | if (robustness2_features && robustness2_features->nullDescriptor) { |
| 3131 | for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; |
| 3132 | ++descriptorIndex) { |
| 3133 | if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE && |
| 3134 | (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 || |
| 3135 | pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) { |
| 3136 | skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999", |
| 3137 | "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, " |
| 3138 | "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.", |
| 3139 | vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset, |
| 3140 | pDescriptorWrites[i].pBufferInfo[descriptorIndex].range); |
| 3141 | } |
| 3142 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3143 | } |
| 3144 | } |
| 3145 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 3146 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3147 | // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3148 | } |
| 3149 | |
| 3150 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3151 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3152 | VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3153 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3154 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 3155 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3156 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3157 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
| 3158 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3159 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 3160 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3161 | } |
| 3162 | } |
| 3163 | } |
| 3164 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3165 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3166 | VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3167 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3168 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 3169 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3170 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3171 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
| 3172 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3173 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 3174 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3175 | } |
| 3176 | } |
| 3177 | } |
| 3178 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3179 | // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR |
| 3180 | // or VkWriteDescriptorSetInlineUniformBlockEX |
| 3181 | if (pDescriptorWrites[i].pNext) { |
| 3182 | if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3183 | const auto *pnext_struct = |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3184 | lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext); |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3185 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3186 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382", |
| 3187 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext" |
| 3188 | "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose " |
| 3189 | "accelerationStructureCount %d member equals descriptorCount %d.", |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3190 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3191 | pDescriptorWrites[i].descriptorCount); |
| 3192 | } |
| 3193 | // further checks only if we have right structtype |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3194 | if (pnext_struct) { |
| 3195 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3196 | skip |= LogError( |
| 3197 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236", |
| 3198 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 3199 | ".", |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3200 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3201 | } |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3202 | if (pnext_struct->accelerationStructureCount == 0) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3203 | skip |= LogError( |
| 3204 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength", |
| 3205 | "%s(): accelerationStructureCount must be greater than 0 ."); |
| 3206 | } |
| 3207 | } |
| 3208 | } |
| 3209 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3210 | } |
| 3211 | } |
| 3212 | return skip; |
| 3213 | } |
| 3214 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3215 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 3216 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3217 | uint32_t descriptorCopyCount, |
| 3218 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
| 3219 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites); |
| 3220 | } |
| 3221 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3222 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3223 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3224 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3225 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 3226 | } |
| 3227 | |
| 3228 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3229 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3230 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3231 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 3232 | } |
| 3233 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3234 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 3235 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3236 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3237 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3238 | |
| 3239 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3240 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3241 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3242 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 3243 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3244 | return skip; |
| 3245 | } |
| 3246 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3247 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3248 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3249 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3250 | |
| 3251 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 3252 | const char *cmd_name = "vkBeginCommandBuffer"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3253 | const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo; |
| 3254 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3255 | // Implicit VUs |
| 3256 | // validate only sType here; pointer has to be validated in core_validation |
| 3257 | const bool kNotRequired = false; |
| 3258 | const char *kNoVUID = nullptr; |
| 3259 | skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", |
| 3260 | pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID, |
| 3261 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3262 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3263 | if (pInfo) { |
| 3264 | const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = { |
| 3265 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT}; |
| 3266 | skip |= validate_struct_pnext( |
| 3267 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext, |
| 3268 | ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 3269 | GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", |
| 3270 | "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3271 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3272 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3273 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3274 | // Explicit VUs |
| 3275 | if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3276 | skip |= LogError( |
| 3277 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3278 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 3279 | cmd_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3280 | } |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3281 | |
| 3282 | if (physical_device_features.inheritedQueries) { |
| 3283 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 3284 | AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3285 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3286 | } else { // !inheritedQueries |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3287 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags, |
Petr Kraus | 43aed2c | 2019-08-18 13:59:16 +0200 | [diff] [blame] | 3288 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3289 | } |
| 3290 | |
| 3291 | if (physical_device_features.pipelineStatisticsQuery) { |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3292 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 3293 | AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags, |
Petr Kraus | 43aed2c | 2019-08-18 13:59:16 +0200 | [diff] [blame] | 3294 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3295 | } else { // !pipelineStatisticsQuery |
| 3296 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics, |
| 3297 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3298 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 3299 | |
| 3300 | const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext); |
| 3301 | if (conditional_rendering) { |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 3302 | const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 3303 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 3304 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3305 | skip |= LogError( |
| 3306 | commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 3307 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 3308 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 3309 | } |
| 3310 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3311 | } |
| 3312 | |
| 3313 | return skip; |
| 3314 | } |
| 3315 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3316 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3317 | uint32_t viewportCount, const VkViewport *pViewports) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3318 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3319 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3320 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3321 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3322 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 3323 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 3324 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3325 | } |
| 3326 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3327 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 3328 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 3329 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3330 | } |
| 3331 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 3332 | 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] | 3333 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3334 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 3335 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3336 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3337 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3338 | } |
| 3339 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3340 | |
| 3341 | if (pViewports) { |
| 3342 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 3343 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 3344 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3345 | skip |= manual_PreCallValidateViewport( |
| 3346 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3347 | } |
| 3348 | } |
| 3349 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3350 | return skip; |
| 3351 | } |
| 3352 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3353 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3354 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3355 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3356 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3357 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3358 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3359 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 3360 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 3361 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3362 | } |
| 3363 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3364 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 3365 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 3366 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3367 | } |
| 3368 | } else { // multiViewport enabled |
| 3369 | 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] | 3370 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3371 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 3372 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3373 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3374 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3375 | } |
| 3376 | } |
| 3377 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3378 | if (pScissors) { |
| 3379 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 3380 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3381 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3382 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3383 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3384 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 3385 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3386 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3387 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3388 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3389 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3390 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 3391 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3392 | } |
| 3393 | |
| 3394 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 3395 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3396 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 3397 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3398 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3399 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3400 | } |
| 3401 | |
| 3402 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 3403 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3404 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 3405 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3406 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3407 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3408 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3409 | } |
| 3410 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3411 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3412 | return skip; |
| 3413 | } |
| 3414 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3415 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3416 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3417 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3418 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3419 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 3420 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3421 | } |
| 3422 | |
| 3423 | return skip; |
| 3424 | } |
| 3425 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3426 | bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3427 | uint32_t firstVertex, uint32_t firstInstance) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3428 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3429 | if (vertexCount == 0) { |
| 3430 | // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make |
| 3431 | // this an error or leave as is. |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3432 | skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3433 | } |
| 3434 | |
| 3435 | if (instanceCount == 0) { |
| 3436 | // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make |
| 3437 | // this an error or leave as is. |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3438 | skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3439 | } |
| 3440 | return skip; |
| 3441 | } |
| 3442 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3443 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3444 | uint32_t count, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3445 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3446 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3447 | if (!physical_device_features.multiDrawIndirect && ((count > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3448 | skip |= LogError(device, kVUID_PVError_DeviceFeature, |
| 3449 | "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3450 | } |
| 3451 | return skip; |
| 3452 | } |
| 3453 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3454 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3455 | VkDeviceSize offset, uint32_t count, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3456 | bool skip = false; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3457 | if (!physical_device_features.multiDrawIndirect && ((count > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3458 | skip |= |
| 3459 | LogError(device, kVUID_PVError_DeviceFeature, |
| 3460 | "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3461 | } |
| 3462 | return skip; |
| 3463 | } |
| 3464 | |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3465 | bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3466 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3467 | bool skip = false; |
| 3468 | const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()"; |
| 3469 | if (offset & 3) { |
| 3470 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710", |
| 3471 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset); |
| 3472 | } |
| 3473 | |
| 3474 | if (countBufferOffset & 3) { |
| 3475 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716", |
| 3476 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, |
| 3477 | countBufferOffset); |
| 3478 | } |
| 3479 | return skip; |
| 3480 | } |
| 3481 | |
| 3482 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3483 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3484 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3485 | uint32_t stride) const { |
| 3486 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3487 | } |
| 3488 | |
| 3489 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3490 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3491 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3492 | uint32_t stride) const { |
| 3493 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3494 | } |
| 3495 | |
| 3496 | bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3497 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3498 | bool skip = false; |
| 3499 | const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()"; |
| 3500 | if (offset & 3) { |
| 3501 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710", |
| 3502 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset); |
| 3503 | } |
| 3504 | |
| 3505 | if (countBufferOffset & 3) { |
| 3506 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716", |
| 3507 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, |
| 3508 | countBufferOffset); |
| 3509 | } |
| 3510 | return skip; |
| 3511 | } |
| 3512 | |
| 3513 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3514 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3515 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3516 | uint32_t stride) const { |
| 3517 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3518 | } |
| 3519 | |
| 3520 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3521 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3522 | VkDeviceSize countBufferOffset, |
| 3523 | uint32_t maxDrawCount, uint32_t stride) const { |
| 3524 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3525 | } |
| 3526 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3527 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 3528 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3529 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3530 | bool skip = false; |
| 3531 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 3532 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3533 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
| 3534 | "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3535 | } |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 3536 | if (pRects[rect].rect.extent.width == 0) { |
| 3537 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682", |
| 3538 | "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect); |
| 3539 | } |
| 3540 | if (pRects[rect].rect.extent.height == 0) { |
| 3541 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683", |
| 3542 | "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect); |
| 3543 | } |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3544 | } |
| 3545 | return skip; |
| 3546 | } |
| 3547 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3548 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 3549 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3550 | VkImageFormatProperties2 *pImageFormatProperties, |
| 3551 | const char *apiName) const { |
| 3552 | bool skip = false; |
| 3553 | |
| 3554 | if (pImageFormatInfo != nullptr) { |
| 3555 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext); |
| 3556 | if (image_stencil_struct != nullptr) { |
| 3557 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 3558 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 3559 | // No flags other than the legal attachment bits may be set |
| 3560 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 3561 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3562 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 3563 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 3564 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 3565 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 3566 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3567 | } |
| 3568 | } |
| 3569 | } |
| 3570 | } |
| 3571 | |
| 3572 | return skip; |
| 3573 | } |
| 3574 | |
| 3575 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 3576 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3577 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3578 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3579 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 3580 | } |
| 3581 | |
| 3582 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 3583 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3584 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3585 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3586 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 3587 | } |
| 3588 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3589 | bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 3590 | VkImageLayout srcImageLayout, VkImage dstImage, |
| 3591 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3592 | const VkImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3593 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3594 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3595 | VkImageAspectFlags legal_aspect_flags = |
| 3596 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3597 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3598 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3599 | } |
| 3600 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3601 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3602 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3603 | skip |= LogError( |
| 3604 | device, "VUID-VkImageSubresourceLayers-aspectMask-parameter", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3605 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3606 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3607 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3608 | skip |= LogError( |
| 3609 | device, "VUID-VkImageSubresourceLayers-aspectMask-parameter", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3610 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3611 | } |
| 3612 | } |
| 3613 | return skip; |
| 3614 | } |
| 3615 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3616 | bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 3617 | VkImageLayout srcImageLayout, VkImage dstImage, |
| 3618 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3619 | const VkImageBlit *pRegions, VkFilter filter) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3620 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3621 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3622 | VkImageAspectFlags legal_aspect_flags = |
| 3623 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3624 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3625 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3626 | } |
| 3627 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3628 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3629 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3630 | skip |= LogError( |
| 3631 | device, kVUID_PVError_UnrecognizedValue, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3632 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator"); |
| 3633 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3634 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3635 | skip |= LogError( |
| 3636 | device, kVUID_PVError_UnrecognizedValue, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3637 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator"); |
| 3638 | } |
| 3639 | } |
| 3640 | return skip; |
| 3641 | } |
| 3642 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3643 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 3644 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 3645 | bool skip = false; |
| 3646 | |
| 3647 | if (pRegions != nullptr) { |
| 3648 | for (uint32_t i = 0; i < regionCount; i++) { |
| 3649 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3650 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
| 3651 | "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3652 | } |
| 3653 | } |
| 3654 | } |
| 3655 | return skip; |
| 3656 | } |
| 3657 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3658 | bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, |
| 3659 | VkImage dstImage, VkImageLayout dstImageLayout, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3660 | uint32_t regionCount, |
| 3661 | const VkBufferImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3662 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3663 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3664 | VkImageAspectFlags legal_aspect_flags = |
| 3665 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3666 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3667 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3668 | } |
| 3669 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3670 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3671 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3672 | skip |= LogError(device, kVUID_PVError_UnrecognizedValue, |
| 3673 | "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an " |
| 3674 | "unrecognized enumerator"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3675 | } |
| 3676 | } |
| 3677 | return skip; |
| 3678 | } |
| 3679 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3680 | bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 3681 | VkImageLayout srcImageLayout, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3682 | uint32_t regionCount, |
| 3683 | const VkBufferImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3684 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3685 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3686 | VkImageAspectFlags legal_aspect_flags = |
| 3687 | VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3688 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3689 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3690 | } |
| 3691 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3692 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3693 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Petr Kraus | 3e6cd03 | 2020-04-14 20:41:16 +0200 | [diff] [blame] | 3694 | skip |= LogError( |
| 3695 | device, kVUID_PVError_UnrecognizedValue, |
| 3696 | "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized " |
| 3697 | "enumerator"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3698 | } |
| 3699 | } |
| 3700 | return skip; |
| 3701 | } |
| 3702 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3703 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3704 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 3705 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3706 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3707 | |
| 3708 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3709 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 3710 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3711 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3712 | } |
| 3713 | |
| 3714 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3715 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 3716 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 3717 | "), must be greater than zero and less than or equal to 65536.", |
| 3718 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3719 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3720 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 3721 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3722 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3723 | } |
| 3724 | return skip; |
| 3725 | } |
| 3726 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3727 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3728 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3729 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3730 | |
| 3731 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3732 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 3733 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3734 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3735 | } |
| 3736 | |
| 3737 | if (size != VK_WHOLE_SIZE) { |
| 3738 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3739 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3740 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 3741 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3742 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3743 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 3744 | "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] | 3745 | } |
| 3746 | } |
| 3747 | return skip; |
| 3748 | } |
| 3749 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3750 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3751 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3752 | VkSwapchainKHR *pSwapchain) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3753 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3754 | |
| 3755 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3756 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3757 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 3758 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 3759 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3760 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
| 3761 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3762 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3763 | } |
| 3764 | |
| 3765 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 3766 | // queueFamilyIndexCount uint32_t values |
| 3767 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3768 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
| 3769 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3770 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 3771 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3772 | } |
| 3773 | } |
| 3774 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3775 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3776 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3777 | } |
| 3778 | |
| 3779 | return skip; |
| 3780 | } |
| 3781 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3782 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3783 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3784 | |
| 3785 | if (pPresentInfo && pPresentInfo->pNext) { |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3786 | const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
| 3787 | if (present_regions) { |
| 3788 | // 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] | 3789 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3790 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 3791 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3792 | skip |= LogError(device, kVUID_PVError_InvalidUsage, |
| 3793 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 3794 | "extension swapchainCount is %i. These values must be equal.", |
| 3795 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3796 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3797 | 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] | 3798 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 3799 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3800 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 3801 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 3802 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3803 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3804 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3805 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3806 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3807 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3808 | } |
| 3809 | } |
| 3810 | |
| 3811 | return skip; |
| 3812 | } |
| 3813 | |
| 3814 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3815 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 3816 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 3817 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3818 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3819 | bool skip = false; |
| 3820 | |
| 3821 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3822 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 3823 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3824 | } |
| 3825 | |
| 3826 | return skip; |
| 3827 | } |
| 3828 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 3829 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3830 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3831 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3832 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3833 | bool skip = false; |
| 3834 | |
| 3835 | if (pCreateInfo) { |
| 3836 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3837 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 3838 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3839 | } |
| 3840 | |
| 3841 | if (pCreateInfo->pPoolSizes) { |
| 3842 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 3843 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3844 | skip |= LogError( |
| 3845 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3846 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3847 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3848 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 3849 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3850 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 3851 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 3852 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 3853 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 3854 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3855 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3856 | } |
| 3857 | } |
| 3858 | } |
| 3859 | |
| 3860 | return skip; |
| 3861 | } |
| 3862 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3863 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3864 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3865 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3866 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3867 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3868 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3869 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 3870 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3871 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3872 | } |
| 3873 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3874 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3875 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3876 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 3877 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3878 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3879 | } |
| 3880 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3881 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3882 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3883 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 3884 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3885 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3886 | } |
| 3887 | |
| 3888 | return skip; |
| 3889 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3890 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3891 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3892 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3893 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3894 | |
| 3895 | if ((offset % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3896 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
| 3897 | "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3898 | } |
| 3899 | return skip; |
| 3900 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3901 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3902 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 3903 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3904 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3905 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3906 | |
| 3907 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3908 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3909 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3910 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 3911 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 3912 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3913 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3914 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3915 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 3916 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 3917 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3918 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3919 | } |
| 3920 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3921 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3922 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3923 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 3924 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 3925 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3926 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3927 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3928 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 3929 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 3930 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3931 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3932 | } |
| 3933 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3934 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3935 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3936 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 3937 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 3938 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3939 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3940 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3941 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 3942 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 3943 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3944 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3945 | } |
| 3946 | |
| 3947 | return skip; |
| 3948 | } |
| 3949 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3950 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 3951 | VkPipelineBindPoint pipelineBindPoint, |
| 3952 | VkPipelineLayout layout, uint32_t set, |
| 3953 | uint32_t descriptorWriteCount, |
| 3954 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
| 3955 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false); |
| 3956 | } |
| 3957 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3958 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 3959 | uint32_t firstExclusiveScissor, |
| 3960 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3961 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3962 | bool skip = false; |
| 3963 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3964 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3965 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3966 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3967 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 3968 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 3969 | ") is not 0.", |
| 3970 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3971 | } |
| 3972 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3973 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3974 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 3975 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 3976 | ") is not 1.", |
| 3977 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3978 | } |
| 3979 | } else { // multiViewport enabled |
| 3980 | 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] | 3981 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3982 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 3983 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 3984 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3985 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3986 | } |
| 3987 | } |
| 3988 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3989 | if (firstExclusiveScissor >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3990 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033", |
| 3991 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32 |
| 3992 | ") must be less than maxViewports (=%" PRIu32 ").", |
| 3993 | firstExclusiveScissor, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3994 | } |
| 3995 | |
| 3996 | if (pExclusiveScissors) { |
| 3997 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 3998 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 3999 | |
| 4000 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4001 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4002 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 4003 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4004 | } |
| 4005 | |
| 4006 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4007 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4008 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 4009 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4010 | } |
| 4011 | |
| 4012 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 4013 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4014 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 4015 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4016 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4017 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4018 | } |
| 4019 | |
| 4020 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 4021 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4022 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 4023 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4024 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4025 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4026 | } |
| 4027 | } |
| 4028 | } |
| 4029 | |
| 4030 | return skip; |
| 4031 | } |
| 4032 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4033 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 4034 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4035 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4036 | bool skip = false; |
| 4037 | if (firstViewport >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4038 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323", |
| 4039 | "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").", |
| 4040 | firstViewport, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4041 | } else { |
| 4042 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 4043 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4044 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 4045 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4046 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 4047 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4048 | } |
| 4049 | } |
| 4050 | |
| 4051 | return skip; |
| 4052 | } |
| 4053 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4054 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 4055 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4056 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4057 | bool skip = false; |
| 4058 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4059 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4060 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4061 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4062 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 4063 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 4064 | ") is not 0.", |
| 4065 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4066 | } |
| 4067 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4068 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4069 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 4070 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 4071 | ") is not 1.", |
| 4072 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4073 | } |
| 4074 | } |
| 4075 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4076 | if (firstViewport >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4077 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066", |
| 4078 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32 |
| 4079 | ") must be less than maxViewports (=%" PRIu32 ").", |
| 4080 | firstViewport, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4081 | } |
| 4082 | |
| 4083 | 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] | 4084 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4085 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 4086 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 4087 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4088 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4089 | } |
| 4090 | |
| 4091 | return skip; |
| 4092 | } |
| 4093 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4094 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 4095 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 4096 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4097 | bool skip = false; |
| 4098 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4099 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4100 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 4101 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 4102 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4103 | } |
| 4104 | |
| 4105 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4106 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4107 | } |
| 4108 | |
| 4109 | return skip; |
| 4110 | } |
| 4111 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4112 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4113 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4114 | bool skip = false; |
| 4115 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4116 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4117 | skip |= LogError( |
| 4118 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4119 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 4120 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4121 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4122 | } |
| 4123 | |
| 4124 | return skip; |
| 4125 | } |
| 4126 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4127 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4128 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4129 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4130 | bool skip = false; |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4131 | static const int condition_multiples = 0b0011; |
| 4132 | if (offset & condition_multiples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4133 | skip |= LogError( |
| 4134 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4135 | "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] | 4136 | } |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4137 | if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4138 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 4139 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 4140 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 4141 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4142 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4143 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4144 | skip |= LogError( |
| 4145 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
| 4146 | "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] | 4147 | } |
| 4148 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4149 | return skip; |
| 4150 | } |
| 4151 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4152 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4153 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4154 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4155 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4156 | bool skip = false; |
| 4157 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4158 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4159 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 4160 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 4161 | "), is not a multiple of 4.", |
| 4162 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4163 | } |
| 4164 | |
| 4165 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4166 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 4167 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 4168 | "), is not a multiple of 4.", |
| 4169 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4170 | } |
| 4171 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4172 | return skip; |
| 4173 | } |
| 4174 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4175 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4176 | const VkAllocationCallbacks *pAllocator, |
| 4177 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4178 | bool skip = false; |
| 4179 | |
| 4180 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4181 | if (pCreateInfo != nullptr) { |
| 4182 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 4183 | // VkQueryPipelineStatisticFlagBits values |
| 4184 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 4185 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4186 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 4187 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 4188 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 4189 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4190 | } |
sfricke-samsung | 7d69d0d | 2020-04-25 10:27:27 -0700 | [diff] [blame] | 4191 | if (pCreateInfo->queryCount == 0) { |
| 4192 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763", |
| 4193 | "vkCreateQueryPool(): queryCount must be greater than zero."); |
| 4194 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 4195 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4196 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4197 | } |
| 4198 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4199 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 4200 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4201 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4202 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 4203 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4204 | } |
| 4205 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4206 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4207 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4208 | VkResult result) { |
| 4209 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4210 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4211 | } |
| 4212 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4213 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4214 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4215 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4216 | // 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] | 4217 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4218 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4219 | } |
| 4220 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4221 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 4222 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4223 | // 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] | 4224 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4225 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4226 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4227 | |
| 4228 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4229 | const VkAllocationCallbacks *pAllocator, |
| 4230 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4231 | bool skip = false; |
| 4232 | |
| 4233 | if (pAllocateInfo) { |
| 4234 | auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
| 4235 | 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] | 4236 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 4237 | "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] | 4238 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4239 | |
| 4240 | VkMemoryAllocateFlags flags = 0; |
| 4241 | auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
| 4242 | if (flags_info) { |
| 4243 | flags = flags_info->flags; |
| 4244 | } |
| 4245 | |
| 4246 | auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext); |
| 4247 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
| 4248 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4249 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 4250 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
| 4251 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4252 | } |
| 4253 | |
| 4254 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4255 | auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
| 4256 | #endif |
| 4257 | auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 4258 | auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
| 4259 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 4260 | auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
| 4261 | #endif |
| 4262 | |
| 4263 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4264 | skip |= LogError( |
| 4265 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4266 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 4267 | } |
| 4268 | if ( |
| 4269 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4270 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 4271 | #endif |
| 4272 | (import_memory_fd && import_memory_fd->handleType) || |
| 4273 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 4274 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 4275 | #endif |
| 4276 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4277 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 4278 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4279 | } |
| 4280 | } |
| 4281 | |
| 4282 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 4283 | VkBool32 capture_replay = false; |
| 4284 | VkBool32 buffer_device_address = false; |
| 4285 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
| 4286 | if (vulkan_12_features) { |
| 4287 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 4288 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 4289 | } else { |
| 4290 | const auto *bda_features = |
| 4291 | lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext); |
| 4292 | if (bda_features) { |
| 4293 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 4294 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 4295 | } |
| 4296 | } |
| 4297 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4298 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
| 4299 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, " |
| 4300 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4301 | } |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 4302 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4303 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
| 4304 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4305 | } |
| 4306 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4307 | } |
| 4308 | return skip; |
| 4309 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4310 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4311 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4312 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4313 | bool skip = false; |
| 4314 | |
| 4315 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 4316 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 4317 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4318 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4319 | } else { |
| 4320 | uint32_t vertex_component_size = 0; |
| 4321 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 4322 | vertex_component_size = 4; |
| 4323 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 4324 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 4325 | vertex_component_size = 2; |
| 4326 | } |
| 4327 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4328 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4329 | } |
| 4330 | } |
| 4331 | |
| 4332 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 4333 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4334 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4335 | } else { |
| 4336 | uint32_t index_element_size = 0; |
| 4337 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 4338 | index_element_size = 4; |
| 4339 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 4340 | index_element_size = 2; |
| 4341 | } |
| 4342 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4343 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4344 | } |
| 4345 | } |
| 4346 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 4347 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4348 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4349 | } |
| 4350 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4351 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4352 | } |
| 4353 | } |
| 4354 | |
| 4355 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4356 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4357 | } |
| 4358 | |
| 4359 | return skip; |
| 4360 | } |
| 4361 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4362 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 4363 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4364 | bool skip = false; |
| 4365 | |
| 4366 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4367 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4368 | } |
| 4369 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4370 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4371 | } |
| 4372 | |
| 4373 | return skip; |
| 4374 | } |
| 4375 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4376 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 4377 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4378 | bool skip = false; |
| 4379 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4380 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4381 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4382 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4383 | } |
| 4384 | return skip; |
| 4385 | } |
| 4386 | |
| 4387 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4388 | VkAccelerationStructureNV object_handle, const char *func_name, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 4389 | bool is_cmd) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4390 | bool skip = false; |
| 4391 | 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] | 4392 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 4393 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 4394 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4395 | } |
| 4396 | 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] | 4397 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 4398 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 4399 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4400 | } |
| 4401 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 4402 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4403 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 4404 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 4405 | "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] | 4406 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4407 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4408 | skip |= LogError(object_handle, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 4409 | is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241" |
| 4410 | : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4411 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 4412 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4413 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4414 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4415 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 4416 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 4417 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4418 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4419 | 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] | 4420 | uint64_t total_triangle_count = 0; |
| 4421 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 4422 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4423 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4424 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4425 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4426 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 4427 | continue; |
| 4428 | } |
| 4429 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 4430 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4431 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4432 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 4433 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 4434 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4435 | } |
| 4436 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4437 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 4438 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 4439 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 4440 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 4441 | if (geometry.geometryType != first_geometry_type) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4442 | skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4443 | "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match " |
| 4444 | "info.pGeometries[0].geometryType.", |
| 4445 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4446 | } |
| 4447 | } |
| 4448 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4449 | for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) { |
| 4450 | if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV || |
| 4451 | info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) { |
| 4452 | skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503", |
| 4453 | "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV" |
| 4454 | "or VK_GEOMETRY_TYPE_AABBS_NV."); |
| 4455 | } |
| 4456 | } |
| 4457 | skip |= |
| 4458 | validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV, |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 4459 | info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4460 | return skip; |
| 4461 | } |
| 4462 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4463 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 4464 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4465 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4466 | bool skip = false; |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4467 | if (pCreateInfo) { |
| 4468 | if ((pCreateInfo->compactedSize != 0) && |
| 4469 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4470 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 4471 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 4472 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 4473 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4474 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4475 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4476 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4477 | "vkCreateAccelerationStructureNV()", false); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4478 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4479 | return skip; |
| 4480 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4481 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4482 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 4483 | const VkAccelerationStructureInfoNV *pInfo, |
| 4484 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 4485 | VkBool32 update, VkAccelerationStructureNV dst, |
| 4486 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 4487 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4488 | bool skip = false; |
| 4489 | |
| 4490 | if (pInfo != nullptr) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4491 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4492 | } |
| 4493 | |
| 4494 | return skip; |
| 4495 | } |
| 4496 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4497 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR( |
| 4498 | VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 4499 | VkAccelerationStructureKHR *pAccelerationStructure) const { |
| 4500 | bool skip = false; |
| 4501 | |
| 4502 | if (pCreateInfo) { |
| 4503 | for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) { |
| 4504 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) { |
| 4505 | if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 4506 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496", |
| 4507 | "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure " |
| 4508 | "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 4509 | i); |
| 4510 | } |
| 4511 | } |
| 4512 | |
| 4513 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) { |
| 4514 | if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 4515 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497", |
| 4516 | "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure " |
| 4517 | "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 4518 | i); |
| 4519 | } |
| 4520 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4521 | if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 4522 | if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 || |
| 4523 | pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 || |
| 4524 | pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) { |
| 4525 | skip |= LogError( |
| 4526 | device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502", |
| 4527 | "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType" |
| 4528 | "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR."); |
| 4529 | } |
| 4530 | } |
| 4531 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) { |
| 4532 | if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) { |
| 4533 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492", |
| 4534 | "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR" |
| 4535 | "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to " |
| 4536 | "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.", |
| 4537 | pCreateInfo->pGeometryInfos[i].maxPrimitiveCount, |
| 4538 | phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount); |
| 4539 | } |
| 4540 | } |
| 4541 | } |
| 4542 | |
| 4543 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 && |
| 4544 | pCreateInfo->maxGeometryCount != 1) { |
| 4545 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495", |
| 4546 | "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR" |
| 4547 | "and compactedSize is 0, maxGeometryCount must be 1."); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4548 | } |
sourav parmar | d152180 | 2020-06-07 21:49:02 -0700 | [diff] [blame] | 4549 | // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490 |
| 4550 | if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) { |
| 4551 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993", |
| 4552 | "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0."); |
| 4553 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4554 | |
| 4555 | if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR && |
| 4556 | pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) { |
| 4557 | skip |= LogError( |
| 4558 | device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499", |
| 4559 | "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR" |
| 4560 | "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set."); |
| 4561 | } |
| 4562 | |
| 4563 | if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) { |
| 4564 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490", |
| 4565 | "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 4566 | ") with maxGeometryCount (%" PRIu32 ") nonzero.", |
| 4567 | pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount); |
| 4568 | } |
| 4569 | |
| 4570 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) { |
| 4571 | const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType; |
| 4572 | for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) { |
| 4573 | const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType; |
| 4574 | if (geometry_type != first_geometry_type) { |
| 4575 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498", |
| 4576 | "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match " |
| 4577 | "pGeometryInfos[0].geometryType.", |
| 4578 | i); |
| 4579 | } |
| 4580 | } |
| 4581 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4582 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && |
| 4583 | (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) { |
| 4584 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491", |
| 4585 | "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR" |
| 4586 | "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR " |
| 4587 | "maxGeometryCount %d.", |
| 4588 | pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount); |
| 4589 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4590 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4591 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4592 | if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) { |
| 4593 | if (pCreateInfo->deviceAddress != 0) { |
| 4594 | skip |= |
| 4595 | LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500", |
| 4596 | "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, " |
| 4597 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE."); |
| 4598 | } |
| 4599 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4600 | if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) { |
| 4601 | skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487", |
| 4602 | "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled."); |
| 4603 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4604 | return skip; |
| 4605 | } |
| 4606 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4607 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 4608 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4609 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4610 | bool skip = false; |
| 4611 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4612 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 4613 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4614 | } |
| 4615 | return skip; |
| 4616 | } |
| 4617 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4618 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 4619 | uint32_t createInfoCount, |
| 4620 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 4621 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4622 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4623 | bool skip = false; |
| 4624 | |
| 4625 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 4626 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 4627 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4628 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4629 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 4630 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 4631 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 4632 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4633 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4634 | |
| 4635 | const auto *pipeline_cache_contol_features = |
| 4636 | lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
| 4637 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4638 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4639 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4640 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905", |
| 4641 | "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled," |
| 4642 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4643 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4644 | } |
| 4645 | } |
| 4646 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4647 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 4648 | skip |= |
| 4649 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904", |
| 4650 | "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 4651 | } |
| 4652 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) && |
| 4653 | (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) { |
| 4654 | skip |= |
| 4655 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957", |
| 4656 | "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and" |
| 4657 | "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time."); |
| 4658 | } |
| 4659 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4660 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4661 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4662 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423", |
| 4663 | "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be " |
| 4664 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4665 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4666 | } |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4667 | if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) { |
| 4668 | skip |= |
| 4669 | LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415", |
| 4670 | "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the" |
| 4671 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element" |
| 4672 | "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to " |
| 4673 | "that element."); |
| 4674 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4675 | } |
| 4676 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 4677 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4678 | skip |= |
| 4679 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422", |
| 4680 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4681 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling" |
| 4682 | "commands pCreateInfos parameter."); |
| 4683 | } |
| 4684 | } else { |
| 4685 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4686 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424", |
| 4687 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4688 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4689 | } |
| 4690 | } |
| 4691 | } |
| 4692 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 4693 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456", |
| 4694 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR."); |
| 4695 | } |
| 4696 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) { |
| 4697 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458", |
| 4698 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4699 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR."); |
| 4700 | } |
| 4701 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) { |
| 4702 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459", |
| 4703 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4704 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR."); |
| 4705 | } |
| 4706 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) { |
| 4707 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460", |
| 4708 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4709 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR."); |
| 4710 | } |
| 4711 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) { |
| 4712 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461", |
| 4713 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4714 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR."); |
| 4715 | } |
| 4716 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4717 | skip |= LogError( |
| 4718 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462", |
| 4719 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4720 | } |
| 4721 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4722 | skip |= LogError( |
| 4723 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463", |
| 4724 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 4725 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4726 | } |
| 4727 | |
| 4728 | return skip; |
| 4729 | } |
| 4730 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4731 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache, |
| 4732 | uint32_t createInfoCount, |
| 4733 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, |
| 4734 | const VkAllocationCallbacks *pAllocator, |
| 4735 | VkPipeline *pPipelines) const { |
| 4736 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4737 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4738 | if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) { |
| 4739 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455", |
| 4740 | "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled."); |
| 4741 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4742 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 4743 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 4744 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
| 4745 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670", |
| 4746 | "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32 |
| 4747 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 4748 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").", |
| 4749 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
| 4750 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4751 | const auto *pipeline_cache_contol_features = |
| 4752 | lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
| 4753 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4754 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4755 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4756 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905", |
| 4757 | "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled," |
| 4758 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4759 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4760 | } |
| 4761 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4762 | if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) { |
| 4763 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4764 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472", |
| 4765 | "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled," |
| 4766 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4767 | } |
| 4768 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4769 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473", |
| 4770 | "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled," |
| 4771 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 4772 | } |
| 4773 | } |
| 4774 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4775 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 4776 | skip |= |
| 4777 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904", |
| 4778 | "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 4779 | } |
| 4780 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 4781 | if (pCreateInfos[i].pLibraryInterface == NULL) |
| 4782 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465", |
| 4783 | "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL."); |
| 4784 | } |
| 4785 | for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) { |
| 4786 | if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) || |
| 4787 | (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) { |
| 4788 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) && |
| 4789 | (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4790 | skip |= LogError( |
| 4791 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470", |
| 4792 | "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR," |
| 4793 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4794 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element " |
| 4795 | "must not be VK_SHADER_UNUSED_KHR"); |
| 4796 | } |
| 4797 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) && |
| 4798 | (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4799 | skip |= LogError( |
| 4800 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471", |
| 4801 | "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR," |
| 4802 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4803 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that " |
| 4804 | "element must not be VK_SHADER_UNUSED_KHR"); |
| 4805 | } |
| 4806 | } |
| 4807 | } |
| 4808 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4809 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4810 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4811 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423", |
| 4812 | "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be " |
| 4813 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4814 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4815 | } |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4816 | if (pCreateInfos[i].basePipelineIndex > (int32_t)i) { |
| 4817 | skip |= |
| 4818 | LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415", |
| 4819 | "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the" |
| 4820 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is" |
| 4821 | "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that " |
| 4822 | "element."); |
| 4823 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4824 | } |
| 4825 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 4826 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4827 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422", |
| 4828 | "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4829 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling" |
| 4830 | "commands pCreateInfos parameter %d.", |
| 4831 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 4832 | } |
| 4833 | } else { |
| 4834 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4835 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424", |
| 4836 | "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4837 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4838 | } |
| 4839 | } |
| 4840 | } |
| 4841 | if (pCreateInfos[i].libraries.libraryCount == 0) { |
| 4842 | if (pCreateInfos[i].stageCount == 0) { |
| 4843 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958", |
| 4844 | "If libraries.libraryCount is zero, then stageCount must not be zero ."); |
| 4845 | } |
| 4846 | if (pCreateInfos[i].groupCount == 0) { |
| 4847 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959", |
| 4848 | "If libraries.libraryCount is zero, then groupCount must not be zero ."); |
| 4849 | } |
| 4850 | } else { |
| 4851 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
| 4852 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466", |
| 4853 | "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL."); |
| 4854 | } |
| 4855 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4856 | } |
| 4857 | |
| 4858 | return skip; |
| 4859 | } |
| 4860 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4861 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4862 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 4863 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4864 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4865 | bool skip = false; |
| 4866 | if (!device_extensions.vk_khr_swapchain) |
| 4867 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 4868 | if (!device_extensions.vk_khr_get_surface_capabilities_2) |
| 4869 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
| 4870 | if (!device_extensions.vk_khr_surface) |
| 4871 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
| 4872 | if (!device_extensions.vk_khr_get_physical_device_properties_2) |
| 4873 | skip |= |
| 4874 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 4875 | if (!device_extensions.vk_ext_full_screen_exclusive) |
| 4876 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 4877 | skip |= validate_struct_type( |
| 4878 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 4879 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 4880 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 4881 | if (pSurfaceInfo != NULL) { |
| 4882 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 4883 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 4884 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 4885 | |
| 4886 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 4887 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 4888 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 4889 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 4890 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 4891 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4892 | |
| 4893 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 4894 | } |
| 4895 | return skip; |
| 4896 | } |
| 4897 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4898 | |
| 4899 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 4900 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4901 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4902 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4903 | bool skip = false; |
| 4904 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) { |
| 4905 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 4906 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 4907 | } |
| 4908 | return skip; |
| 4909 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4910 | |
| 4911 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4912 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4913 | bool skip = false; |
| 4914 | |
| 4915 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4916 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
| 4917 | "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4918 | } |
| 4919 | |
| 4920 | return skip; |
| 4921 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 4922 | |
| 4923 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4924 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 4925 | bool skip = false; |
| 4926 | |
| 4927 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4928 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 4929 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 4930 | } |
| 4931 | |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 4932 | const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext); |
Mark Lobodzinski | 804fde8 | 2020-05-08 07:49:25 -0600 | [diff] [blame] | 4933 | 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] | 4934 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 4935 | "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] | 4936 | } |
| 4937 | |
| 4938 | return skip; |
| 4939 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4940 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 4941 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 4942 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 4943 | const VkDeviceSize *pOffsets) const { |
| 4944 | bool skip = false; |
| 4945 | if (firstBinding > device_limits.maxVertexInputBindings) { |
| 4946 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 4947 | "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding, |
| 4948 | device_limits.maxVertexInputBindings); |
| 4949 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 4950 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
| 4951 | "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 4952 | "maxVertexInputBindings (%u)", |
| 4953 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 4954 | } |
| 4955 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4956 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 4957 | if (pBuffers[i] == VK_NULL_HANDLE) { |
| 4958 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 4959 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 4960 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001", |
| 4961 | "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 4962 | } else { |
| 4963 | if (pOffsets[i] != 0) { |
| 4964 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002", |
| 4965 | "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 4966 | } |
| 4967 | } |
| 4968 | } |
| 4969 | } |
| 4970 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 4971 | return skip; |
| 4972 | } |
| 4973 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4974 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4975 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4976 | bool skip = false; |
| 4977 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4978 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 4979 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4980 | } |
| 4981 | return skip; |
| 4982 | } |
| 4983 | |
| 4984 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4985 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4986 | bool skip = false; |
| 4987 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4988 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 4989 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4990 | } |
| 4991 | return skip; |
| 4992 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 4993 | |
| 4994 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 4995 | VkSemaphore semaphore, VkFence fence, |
| 4996 | uint32_t *pImageIndex) const { |
| 4997 | bool skip = false; |
| 4998 | |
| 4999 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5000 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 5001 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5002 | } |
| 5003 | |
| 5004 | return skip; |
| 5005 | } |
| 5006 | |
| 5007 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 5008 | uint32_t *pImageIndex) const { |
| 5009 | bool skip = false; |
| 5010 | |
| 5011 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5012 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 5013 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5014 | } |
| 5015 | |
| 5016 | return skip; |
| 5017 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5018 | |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 5019 | bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, |
| 5020 | uint32_t firstBinding, uint32_t bindingCount, |
| 5021 | const VkBuffer *pBuffers, |
| 5022 | const VkDeviceSize *pOffsets, |
| 5023 | const VkDeviceSize *pSizes) const { |
| 5024 | bool skip = false; |
| 5025 | |
| 5026 | char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT"; |
| 5027 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5028 | if (pOffsets[i] & 3) { |
| 5029 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359", |
| 5030 | "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]); |
| 5031 | } |
| 5032 | } |
| 5033 | |
| 5034 | if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5035 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356", |
| 5036 | "%s: The firstBinding(%" PRIu32 |
| 5037 | ") index is greater than or equal to " |
| 5038 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5039 | cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5040 | } |
| 5041 | |
| 5042 | if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5043 | skip |= |
| 5044 | LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357", |
| 5045 | "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32 |
| 5046 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5047 | cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5048 | } |
| 5049 | |
| 5050 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5051 | // pSizes is optional and may be nullptr. |
| 5052 | if (pSizes != nullptr) { |
| 5053 | if (pSizes[i] != VK_WHOLE_SIZE && |
| 5054 | pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) { |
| 5055 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361", |
| 5056 | "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64 |
| 5057 | ") is not VK_WHOLE_SIZE and is greater than " |
| 5058 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.", |
| 5059 | cmd_name, i, pSizes[i]); |
| 5060 | } |
| 5061 | } |
| 5062 | } |
| 5063 | |
| 5064 | return skip; |
| 5065 | } |
| 5066 | |
| 5067 | bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5068 | uint32_t firstCounterBuffer, |
| 5069 | uint32_t counterBufferCount, |
| 5070 | const VkBuffer *pCounterBuffers, |
| 5071 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5072 | bool skip = false; |
| 5073 | |
| 5074 | char const *const cmd_name = "CmdBeginTransformFeedbackEXT"; |
| 5075 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5076 | skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368", |
| 5077 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5078 | ") index is greater than or equal to " |
| 5079 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5080 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5081 | } |
| 5082 | |
| 5083 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5084 | skip |= |
| 5085 | LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369", |
| 5086 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5087 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5088 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5089 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5090 | } |
| 5091 | |
| 5092 | return skip; |
| 5093 | } |
| 5094 | |
| 5095 | bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5096 | uint32_t firstCounterBuffer, uint32_t counterBufferCount, |
| 5097 | const VkBuffer *pCounterBuffers, |
| 5098 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5099 | bool skip = false; |
| 5100 | |
| 5101 | char const *const cmd_name = "CmdEndTransformFeedbackEXT"; |
| 5102 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5103 | skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376", |
| 5104 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5105 | ") index is greater than or equal to " |
| 5106 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5107 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5108 | } |
| 5109 | |
| 5110 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5111 | skip |= |
| 5112 | LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377", |
| 5113 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5114 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5115 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5116 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5117 | } |
| 5118 | |
| 5119 | return skip; |
| 5120 | } |
| 5121 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5122 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 5123 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 5124 | VkDeviceSize counterBufferOffset, |
| 5125 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 5126 | bool skip = false; |
| 5127 | |
| 5128 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5129 | skip |= LogError( |
| 5130 | counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5131 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).", |
| 5132 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
| 5133 | } |
| 5134 | |
| 5135 | return skip; |
| 5136 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5137 | |
| 5138 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 5139 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 5140 | const VkAllocationCallbacks *pAllocator, |
| 5141 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 5142 | const char *apiName) const { |
| 5143 | bool skip = false; |
| 5144 | |
| 5145 | // Check samplerYcbcrConversion feature is set |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 5146 | const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5147 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5148 | const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext); |
| 5149 | if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) { |
| 5150 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5151 | "%s: samplerYcbcrConversion must be enabled.", apiName); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5152 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5153 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5154 | |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5155 | const VkFormat format = pCreateInfo->format; |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5156 | const VkComponentMapping components = pCreateInfo->components; |
| 5157 | // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5158 | if (FormatIsXChromaSubsampled(format) == true) { |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5159 | if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) { |
| 5160 | skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581", |
| 5161 | "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G " |
| 5162 | "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5163 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g)); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5164 | } |
| 5165 | |
| 5166 | if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5167 | (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) { |
| 5168 | skip |= |
| 5169 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582", |
| 5170 | "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or " |
| 5171 | "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5172 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a)); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5173 | } |
| 5174 | |
| 5175 | if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5176 | (components.r != VK_COMPONENT_SWIZZLE_B)) { |
| 5177 | skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583", |
| 5178 | "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R " |
| 5179 | "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] | 5180 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r)); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5181 | } |
| 5182 | |
| 5183 | if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5184 | (components.b != VK_COMPONENT_SWIZZLE_R)) { |
| 5185 | skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584", |
| 5186 | "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B " |
| 5187 | "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] | 5188 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b)); |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5189 | } |
| 5190 | |
| 5191 | // If one is identity, both need to be |
| 5192 | const bool rIdentity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 5193 | const bool bIdentity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 5194 | if ((rIdentity != bIdentity) && ((rIdentity == true) || (bIdentity == true))) { |
| 5195 | skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585", |
| 5196 | "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) " |
| 5197 | "are an identity swizzle, then both need to be an identity swizzle.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5198 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r), |
| 5199 | string_VkComponentSwizzle(components.b)); |
| 5200 | } |
| 5201 | } |
| 5202 | |
| 5203 | if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) { |
| 5204 | // Checks same VU multiple ways in order to give a more useful error message |
| 5205 | const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655"; |
| 5206 | if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) || |
| 5207 | (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) || |
| 5208 | (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) { |
| 5209 | skip |= |
| 5210 | LogError(device, vuid, |
| 5211 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5212 | "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.", |
| 5213 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5214 | string_VkComponentSwizzle(components.b)); |
| 5215 | } |
| 5216 | |
| 5217 | // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA" |
| 5218 | // 4 channel format = no issue |
| 5219 | // 3 = no [a] |
| 5220 | // 2 = no [b,a] |
| 5221 | // 1 = no [g,b,a] |
| 5222 | // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it) |
| 5223 | const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format); |
| 5224 | |
| 5225 | if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) || |
| 5226 | (components.b == VK_COMPONENT_SWIZZLE_A))) { |
| 5227 | skip |= LogError(device, vuid, |
| 5228 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5229 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.", |
| 5230 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5231 | string_VkComponentSwizzle(components.b)); |
| 5232 | } else if ((channels < 3) && |
| 5233 | ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) || |
| 5234 | (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) { |
| 5235 | skip |= LogError(device, vuid, |
| 5236 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5237 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B " |
| 5238 | "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 5239 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5240 | string_VkComponentSwizzle(components.b)); |
| 5241 | } else if ((channels < 2) && |
| 5242 | ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) || |
| 5243 | (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) { |
| 5244 | skip |= LogError(device, vuid, |
| 5245 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5246 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G " |
| 5247 | "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 5248 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5249 | string_VkComponentSwizzle(components.b)); |
| 5250 | } |
| 5251 | } |
| 5252 | |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5253 | return skip; |
| 5254 | } |
| 5255 | |
| 5256 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 5257 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 5258 | const VkAllocationCallbacks *pAllocator, |
| 5259 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 5260 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 5261 | "vkCreateSamplerYcbcrConversion"); |
| 5262 | } |
| 5263 | |
| 5264 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 5265 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 5266 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 5267 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 5268 | "vkCreateSamplerYcbcrConversionKHR"); |
| 5269 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 5270 | |
| 5271 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR( |
| 5272 | VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const { |
| 5273 | bool skip = false; |
| 5274 | VkExternalSemaphoreHandleTypeFlags supported_handle_types = |
| 5275 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 5276 | |
| 5277 | if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5278 | skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", |
| 5279 | "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).", |
| 5280 | report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(), |
| 5281 | string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType), |
| 5282 | string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 5283 | } |
| 5284 | return skip; |
| 5285 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5286 | |
| 5287 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR( |
| 5288 | VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 5289 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5290 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5291 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 5292 | skip |= |
| 5293 | LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447", |
| 5294 | "vkCopyAccelerationStructureToMemoryKHR: the " |
| 5295 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled."); |
| 5296 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5297 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 5298 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 5299 | "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 5300 | } |
| 5301 | return skip; |
| 5302 | } |
| 5303 | |
| 5304 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR( |
| 5305 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 5306 | bool skip = false; |
| 5307 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 5308 | skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update |
| 5309 | LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 5310 | "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 5311 | } |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5312 | const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext); |
| 5313 | if (pnext_struct) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5314 | skip |= LogError( |
| 5315 | commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560", |
| 5316 | "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the" |
| 5317 | "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure."); |
| 5318 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5319 | return skip; |
| 5320 | } |
| 5321 | |
| 5322 | bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 5323 | const char *api_name) const { |
| 5324 | bool skip = false; |
| 5325 | if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR || |
| 5326 | pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) { |
| 5327 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410", |
| 5328 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR" |
| 5329 | "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.", |
| 5330 | api_name); |
| 5331 | } |
| 5332 | return skip; |
| 5333 | } |
| 5334 | |
| 5335 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR( |
| 5336 | VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 5337 | bool skip = false; |
| 5338 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5339 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5340 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 5341 | skip |= LogError( |
| 5342 | device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441", |
| 5343 | "vkCopyAccelerationStructureKHR(): the " |
| 5344 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled ."); |
| 5345 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5346 | return skip; |
| 5347 | } |
| 5348 | |
| 5349 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR( |
| 5350 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 5351 | bool skip = false; |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5352 | const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext); |
| 5353 | if (pnext_struct) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5354 | skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557", |
| 5355 | "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in " |
| 5356 | "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure."); |
| 5357 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5358 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()"); |
| 5359 | return skip; |
| 5360 | } |
| 5361 | |
| 5362 | bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 5363 | const char *api_name, bool is_cmd) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5364 | bool skip = false; |
| 5365 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5366 | skip |= LogError(device, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 5367 | is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413" |
Shannon McPherson | afe5512 | 2020-05-25 16:20:19 -0600 | [diff] [blame] | 5368 | : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413", |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5369 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name); |
| 5370 | } |
| 5371 | return skip; |
| 5372 | } |
| 5373 | |
| 5374 | bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR( |
| 5375 | VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 5376 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5377 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true); |
| 5378 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5379 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 5380 | skip |= |
| 5381 | LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444", |
| 5382 | "vkCopyMemoryToAccelerationStructureKHR() :the " |
| 5383 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled."); |
| 5384 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5385 | return skip; |
| 5386 | } |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 5387 | |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5388 | bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR( |
| 5389 | VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 5390 | bool skip = false; |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5391 | const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext); |
| 5392 | if (pnext_struct) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5393 | skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564", |
| 5394 | "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must" |
| 5395 | "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure."); |
| 5396 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5397 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false); |
| 5398 | return skip; |
| 5399 | } |
| 5400 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR( |
| 5401 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 5402 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 5403 | bool skip = false; |
| 5404 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 5405 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 5406 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 5407 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 5408 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 5409 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 5410 | } |
| 5411 | return skip; |
| 5412 | } |
| 5413 | bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR( |
| 5414 | VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 5415 | VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const { |
| 5416 | bool skip = false; |
| 5417 | if (dataSize < accelerationStructureCount * stride) { |
| 5418 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452", |
| 5419 | "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to " |
| 5420 | "accelerationStructureCount (%d) *stride(%zu).", |
| 5421 | dataSize, accelerationStructureCount, stride); |
| 5422 | } |
| 5423 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 5424 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 5425 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 5426 | "vkWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 5427 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 5428 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 5429 | } |
| 5430 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) { |
| 5431 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 5432 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448", |
| 5433 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 5434 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR," |
| 5435 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 5436 | stride); |
| 5437 | } |
| 5438 | } |
| 5439 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) { |
| 5440 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 5441 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450", |
| 5442 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 5443 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR," |
| 5444 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 5445 | stride); |
| 5446 | } |
| 5447 | } |
| 5448 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5449 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 5450 | skip |= |
| 5451 | LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454", |
| 5452 | "vkWriteAccelerationStructuresPropertiesKHR: the " |
| 5453 | "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands" |
| 5454 | "feature must be enabled "); |
| 5455 | } |
| 5456 | return skip; |
| 5457 | } |
| 5458 | bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR( |
| 5459 | VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const { |
| 5460 | bool skip = false; |
| 5461 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5462 | if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) { |
| 5463 | skip |= LogError(device, |
| 5464 | "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485", |
| 5465 | "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: " |
| 5466 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay" |
| 5467 | "must be enabled to call this function."); |
| 5468 | } |
| 5469 | return skip; |
| 5470 | } |
| 5471 | |
| 5472 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
| 5473 | const VkStridedBufferRegionKHR *pRaygenShaderBindingTable, |
| 5474 | const VkStridedBufferRegionKHR *pMissShaderBindingTable, |
| 5475 | const VkStridedBufferRegionKHR *pHitShaderBindingTable, |
| 5476 | const VkStridedBufferRegionKHR *pCallableShaderBindingTable, |
| 5477 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 5478 | bool skip = false; |
| 5479 | if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5480 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038", |
| 5481 | "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable" |
| 5482 | "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5483 | } |
| 5484 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5485 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040", |
| 5486 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple" |
| 5487 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5488 | } |
| 5489 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5490 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041", |
| 5491 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be" |
| 5492 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5493 | } |
| 5494 | // hitShader |
| 5495 | if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5496 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032", |
| 5497 | "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple" |
| 5498 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5499 | } |
| 5500 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5501 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034", |
| 5502 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple" |
| 5503 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5504 | } |
| 5505 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5506 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035", |
| 5507 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be" |
| 5508 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5509 | } |
| 5510 | |
| 5511 | // missShader |
| 5512 | if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5513 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026", |
| 5514 | "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple" |
| 5515 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5516 | } |
| 5517 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5518 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028", |
| 5519 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple" |
| 5520 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5521 | } |
| 5522 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5523 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029", |
| 5524 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be" |
| 5525 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5526 | } |
| 5527 | |
| 5528 | // raygenShader |
| 5529 | if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5530 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021", |
| 5531 | "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple" |
| 5532 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5533 | } |
| 5534 | return skip; |
| 5535 | } |
| 5536 | |
| 5537 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, |
| 5538 | const VkStridedBufferRegionKHR *pRaygenShaderBindingTable, |
| 5539 | const VkStridedBufferRegionKHR *pMissShaderBindingTable, |
| 5540 | const VkStridedBufferRegionKHR *pHitShaderBindingTable, |
| 5541 | const VkStridedBufferRegionKHR *pCallableShaderBindingTable, |
| 5542 | VkBuffer buffer, VkDeviceSize offset) const { |
| 5543 | bool skip = false; |
| 5544 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5545 | if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) { |
| 5546 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518", |
| 5547 | "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays " |
| 5548 | "feature must be enabled."); |
| 5549 | } |
| 5550 | if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5551 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038", |
| 5552 | "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable" |
| 5553 | "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5554 | } |
| 5555 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5556 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040", |
| 5557 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple" |
| 5558 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5559 | } |
| 5560 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5561 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041", |
| 5562 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be" |
| 5563 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5564 | } |
| 5565 | // hitShader |
| 5566 | if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5567 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032", |
| 5568 | "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple" |
| 5569 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5570 | } |
| 5571 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5572 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034", |
| 5573 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple" |
| 5574 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5575 | } |
| 5576 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5577 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035", |
| 5578 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be" |
| 5579 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5580 | } |
| 5581 | |
| 5582 | // missShader |
| 5583 | if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5584 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026", |
| 5585 | "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple" |
| 5586 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5587 | } |
| 5588 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5589 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028", |
| 5590 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple" |
| 5591 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5592 | } |
| 5593 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5594 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029", |
| 5595 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be" |
| 5596 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5597 | } |
| 5598 | |
| 5599 | // raygenShader |
| 5600 | if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5601 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021", |
| 5602 | "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple" |
| 5603 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5604 | } |
| 5605 | return skip; |
| 5606 | } |
| 5607 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV( |
| 5608 | VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, |
| 5609 | VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 5610 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, |
| 5611 | VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 5612 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 5613 | bool skip = false; |
| 5614 | if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5615 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462", |
| 5616 | "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of " |
| 5617 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5618 | } |
| 5619 | if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5620 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465", |
| 5621 | "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of " |
| 5622 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5623 | } |
| 5624 | if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5625 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468", |
| 5626 | "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to " |
| 5627 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. "); |
| 5628 | } |
| 5629 | |
| 5630 | // hitShader |
| 5631 | if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5632 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460", |
| 5633 | "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of " |
| 5634 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5635 | } |
| 5636 | if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5637 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464", |
| 5638 | "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of " |
| 5639 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5640 | } |
| 5641 | if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5642 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467", |
| 5643 | "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to " |
| 5644 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5645 | } |
| 5646 | |
| 5647 | // missShader |
| 5648 | if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5649 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458", |
| 5650 | "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of " |
| 5651 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5652 | } |
| 5653 | if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5654 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463", |
| 5655 | "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of " |
| 5656 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5657 | } |
| 5658 | if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5659 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466", |
| 5660 | "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to " |
| 5661 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5662 | } |
| 5663 | |
| 5664 | // raygenShader |
| 5665 | if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5666 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456", |
| 5667 | "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of " |
sourav parmar | d152180 | 2020-06-07 21:49:02 -0700 | [diff] [blame] | 5668 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5669 | } |
| 5670 | if (width > device_limits.maxComputeWorkGroupCount[0]) { |
| 5671 | skip |= |
| 5672 | LogError(device, "VUID-vkCmdTraceRaysNV-width-02469", |
| 5673 | "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o]."); |
| 5674 | } |
| 5675 | if (height > device_limits.maxComputeWorkGroupCount[1]) { |
| 5676 | skip |= |
| 5677 | LogError(device, "VUID-vkCmdTraceRaysNV-height-02470", |
| 5678 | "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1]."); |
| 5679 | } |
| 5680 | if (depth > device_limits.maxComputeWorkGroupCount[2]) { |
| 5681 | skip |= |
| 5682 | LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471", |
| 5683 | "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2]."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5684 | } |
| 5685 | return skip; |
| 5686 | } |
| 5687 | |
| 5688 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR( |
| 5689 | VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer, |
| 5690 | VkDeviceSize indirectOffset, uint32_t indirectStride) const { |
| 5691 | bool skip = false; |
| 5692 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5693 | if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) { |
| 5694 | skip |= LogError( |
| 5695 | device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535", |
| 5696 | "vkCmdBuildAccelerationStructureIndirectKHR: The " |
| 5697 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled."); |
| 5698 | } |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5699 | const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext); |
| 5700 | if (pnext_struct) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5701 | skip |= |
| 5702 | LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536", |
| 5703 | "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in " |
| 5704 | "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures."); |
| 5705 | } |
| 5706 | return false; |
| 5707 | } |
| 5708 | |
| 5709 | bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR( |
| 5710 | VkDevice device, const VkAccelerationStructureVersionKHR *version) const { |
| 5711 | bool skip = false; |
| 5712 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5713 | if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) { |
| 5714 | skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565", |
| 5715 | "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled."); |
| 5716 | } |
| 5717 | return skip; |
| 5718 | } |
| 5719 | |
| 5720 | bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR( |
| 5721 | VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 5722 | const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const { |
| 5723 | bool skip = false; |
| 5724 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5725 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5726 | skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439", |
| 5727 | "vkBuildAccelerationStructureKHR: The " |
| 5728 | "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands" |
| 5729 | "feature must be enabled ."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5730 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5731 | return skip; |
| 5732 | } |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5733 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR( |
| 5734 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 5735 | const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const { |
| 5736 | bool skip = false; |
| 5737 | for (uint32_t i = 0; i < infoCount; ++i) { |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5738 | const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext); |
| 5739 | if (pnext_struct) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 5740 | skip |= |
| 5741 | LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532", |
| 5742 | "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the" |
| 5743 | "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures."); |
| 5744 | } |
| 5745 | } |
| 5746 | return skip; |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 5747 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 5748 | |
| 5749 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 5750 | const VkViewport *pViewports) const { |
| 5751 | bool skip = false; |
| 5752 | |
| 5753 | if (!physical_device_features.multiViewport) { |
| 5754 | if (viewportCount != 1) { |
| 5755 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395", |
| 5756 | "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 5757 | ") is not 1.", |
| 5758 | viewportCount); |
| 5759 | } |
| 5760 | } else { // multiViewport enabled |
| 5761 | if (viewportCount < 1 || viewportCount > device_limits.maxViewports) { |
| 5762 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394", |
| 5763 | "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32 |
| 5764 | ") must " |
| 5765 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5766 | viewportCount, device_limits.maxViewports); |
| 5767 | } |
| 5768 | } |
| 5769 | |
| 5770 | if (pViewports) { |
| 5771 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 5772 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
| 5773 | const char *fn_name = "vkCmdSetViewportWithCountEXT"; |
| 5774 | skip |= manual_PreCallValidateViewport( |
| 5775 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
| 5776 | } |
| 5777 | } |
| 5778 | |
| 5779 | return skip; |
| 5780 | } |
| 5781 | |
| 5782 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 5783 | const VkRect2D *pScissors) const { |
| 5784 | bool skip = false; |
| 5785 | |
| 5786 | if (!physical_device_features.multiViewport) { |
| 5787 | if (scissorCount != 1) { |
| 5788 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398", |
| 5789 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5790 | ") must " |
| 5791 | "be 1 when the multiViewport feature is disabled.", |
| 5792 | scissorCount); |
| 5793 | } |
| 5794 | } else { // multiViewport enabled |
| 5795 | if (scissorCount == 0) { |
| 5796 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 5797 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5798 | ") must " |
| 5799 | "be great than zero.", |
| 5800 | scissorCount); |
| 5801 | } else if (scissorCount > device_limits.maxViewports) { |
| 5802 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 5803 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5804 | ") must " |
| 5805 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5806 | scissorCount, device_limits.maxViewports); |
| 5807 | } |
| 5808 | } |
| 5809 | |
| 5810 | if (pScissors) { |
| 5811 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 5812 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
| 5813 | |
| 5814 | if (scissor.offset.x < 0) { |
| 5815 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 5816 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 5817 | scissor.offset.x); |
| 5818 | } |
| 5819 | |
| 5820 | if (scissor.offset.y < 0) { |
| 5821 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 5822 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 5823 | scissor.offset.y); |
| 5824 | } |
| 5825 | |
| 5826 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 5827 | if (x_sum > INT32_MAX) { |
| 5828 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400", |
| 5829 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5830 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5831 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
| 5832 | } |
| 5833 | |
| 5834 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 5835 | if (y_sum > INT32_MAX) { |
| 5836 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401", |
| 5837 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5838 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5839 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
| 5840 | } |
| 5841 | } |
| 5842 | } |
| 5843 | |
| 5844 | return skip; |
| 5845 | } |
| 5846 | |
| 5847 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 5848 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 5849 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 5850 | const VkDeviceSize *pStrides) const { |
| 5851 | bool skip = false; |
| 5852 | if (firstBinding >= device_limits.maxVertexInputBindings) { |
| 5853 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355", |
| 5854 | "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)", |
| 5855 | firstBinding, device_limits.maxVertexInputBindings); |
| 5856 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 5857 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356", |
| 5858 | "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 5859 | "maxVertexInputBindings (%u)", |
| 5860 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 5861 | } |
| 5862 | |
| 5863 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5864 | if (pBuffers[i] == VK_NULL_HANDLE) { |
| 5865 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 5866 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 5867 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111", |
| 5868 | "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 5869 | } else { |
| 5870 | if (pOffsets[i] != 0) { |
| 5871 | skip |= |
| 5872 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112", |
| 5873 | "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 5874 | } |
| 5875 | } |
| 5876 | } |
| 5877 | if (pStrides) { |
| 5878 | if (pStrides[i] > device_limits.maxVertexInputBindingStride) { |
| 5879 | skip |= |
| 5880 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362", |
| 5881 | "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i, |
| 5882 | pStrides[i], device_limits.maxVertexInputBindingStride); |
| 5883 | } |
| 5884 | } |
| 5885 | } |
| 5886 | |
| 5887 | return skip; |
| 5888 | } |