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; |
| 160 | } |
| 161 | |
| 162 | void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 163 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 164 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 165 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 166 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); |
| 167 | StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 168 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 169 | // Parmeter validation also uses extension data |
| 170 | stateless_validation->device_extensions = this->device_extensions; |
| 171 | |
| 172 | VkPhysicalDeviceProperties device_properties = {}; |
| 173 | // Need to get instance and do a getlayerdata call... |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 174 | DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 175 | memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 176 | |
| 177 | if (device_extensions.vk_nv_shading_rate_image) { |
| 178 | // Get the needed shading rate image limits |
| 179 | auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); |
| 180 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 181 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 182 | phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; |
| 183 | } |
| 184 | |
| 185 | if (device_extensions.vk_nv_mesh_shader) { |
| 186 | // Get the needed mesh shader limits |
| 187 | auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>(); |
| 188 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 189 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 190 | phys_dev_ext_props.mesh_shader_props = mesh_shader_props; |
| 191 | } |
| 192 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 193 | if (device_extensions.vk_nv_ray_tracing) { |
| 194 | // Get the needed ray tracing limits |
| 195 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>(); |
| 196 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props); |
| 197 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 198 | phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props; |
| 199 | } |
| 200 | |
| 201 | if (device_extensions.vk_khr_ray_tracing) { |
| 202 | // Get the needed ray tracing limits |
| 203 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>(); |
| 204 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props); |
| 205 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 206 | phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props; |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 207 | } |
| 208 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 209 | if (device_extensions.vk_ext_transform_feedback) { |
| 210 | // Get the needed transform feedback limits |
| 211 | auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
| 212 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props); |
| 213 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 214 | phys_dev_ext_props.transform_feedback_props = transform_feedback_props; |
| 215 | } |
| 216 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 217 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 218 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 219 | // Save app-enabled features in this device's validation object |
| 220 | // 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] | 221 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
| 222 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 223 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 224 | if (features2) { |
| 225 | tmp_features2_state.features = features2->features; |
| 226 | } else if (pCreateInfo->pEnabledFeatures) { |
| 227 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 228 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 229 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 230 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 231 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 232 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 233 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 236 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 237 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 238 | bool skip = false; |
| 239 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 240 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 241 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 242 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 243 | } |
| 244 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 245 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 246 | skip |= |
| 247 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 248 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 249 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 250 | pCreateInfo->ppEnabledExtensionNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 251 | } |
| 252 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 253 | { |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 254 | bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME)); |
| 255 | bool negative_viewport = |
| 256 | 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] | 257 | if (maint1 && negative_viewport) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 258 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 259 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
| 260 | "VK_AMD_negative_viewport_height."); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 261 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 262 | } |
| 263 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 264 | { |
| 265 | bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 266 | bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 267 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 268 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 269 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 270 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 274 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 275 | // Check for get_physical_device_properties2 struct |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 276 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext); |
| 277 | if (features2) { |
| 278 | // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 279 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 280 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when " |
| 281 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 285 | auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
| 286 | if (features2) { |
| 287 | if (!instance_extensions.vk_khr_get_physical_device_properties_2) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 288 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 289 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, " |
| 290 | "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] | 291 | } |
| 292 | } |
| 293 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 294 | const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; |
| 295 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
| 296 | if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { |
| 297 | skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", |
| 298 | "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); |
| 299 | } |
| 300 | |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 301 | auto vertex_attribute_divisor_features = |
| 302 | lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
| 303 | if (vertex_attribute_divisor_features) { |
| 304 | bool extension_found = false; |
| 305 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) { |
| 306 | if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME, |
| 307 | VK_MAX_EXTENSION_NAME_SIZE)) { |
| 308 | extension_found = true; |
| 309 | break; |
| 310 | } |
| 311 | } |
| 312 | if (!extension_found) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 313 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 314 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 315 | "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] | 316 | } |
| 317 | } |
| 318 | |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 319 | const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
| 320 | if (vulkan_11_features) { |
| 321 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 322 | while (current) { |
| 323 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 324 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 325 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 326 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 327 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 328 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 329 | skip |= LogError( |
| 330 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 331 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 332 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 333 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 334 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 335 | break; |
| 336 | } |
| 337 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
| 342 | if (vulkan_12_features) { |
| 343 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 344 | while (current) { |
| 345 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 346 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 347 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 348 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 349 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 350 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 351 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 352 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 353 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 354 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 355 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 356 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 357 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 358 | skip |= LogError( |
| 359 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 360 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 361 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 362 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 363 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 364 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 365 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 366 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 367 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 368 | break; |
| 369 | } |
| 370 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 371 | } |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 372 | // Check features are enabled if matching extension is passed in as well |
| 373 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 374 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 375 | if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 376 | (vulkan_12_features->drawIndirectCount == VK_FALSE)) { |
| 377 | skip |= LogError( |
| 378 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831", |
| 379 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", |
| 380 | VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 381 | } |
| 382 | if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 383 | (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { |
| 384 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832", |
| 385 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " |
| 386 | "is not VK_TRUE.", |
| 387 | VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); |
| 388 | } |
| 389 | if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 390 | (vulkan_12_features->descriptorIndexing == VK_FALSE)) { |
| 391 | skip |= LogError( |
| 392 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833", |
| 393 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", |
| 394 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 395 | } |
| 396 | if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 397 | (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { |
| 398 | skip |= LogError( |
| 399 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834", |
| 400 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", |
| 401 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 402 | } |
| 403 | if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 404 | ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || |
| 405 | (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { |
| 406 | skip |= |
| 407 | LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835", |
| 408 | "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " |
| 409 | "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", |
| 410 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); |
| 411 | } |
| 412 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 413 | } |
| 414 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 415 | // Validate pCreateInfo->pQueueCreateInfos |
| 416 | if (pCreateInfo->pQueueCreateInfos) { |
| 417 | std::unordered_set<uint32_t> set; |
| 418 | |
| 419 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 420 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
| 421 | const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 422 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 423 | skip |= |
| 424 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 425 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 426 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 427 | "index value.", |
| 428 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 429 | } else if (set.count(requested_queue_family)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 430 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372", |
| 431 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 |
| 432 | ") is not unique within pCreateInfo->pQueueCreateInfos array.", |
| 433 | i, requested_queue_family); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 434 | } else { |
| 435 | set.insert(requested_queue_family); |
| 436 | } |
| 437 | |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 438 | if (queue_create_info.pQueuePriorities != nullptr) { |
| 439 | for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { |
| 440 | const float queue_priority = queue_create_info.pQueuePriorities[j]; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 441 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 442 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 443 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 444 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 445 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 446 | } |
| 447 | } |
| 448 | } |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 449 | |
| 450 | // Need to know if protectedMemory feature is passed in preCall to creating the device |
| 451 | VkBool32 protectedMemory = VK_FALSE; |
| 452 | const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = |
| 453 | lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
| 454 | if (protected_features) { |
| 455 | protectedMemory = protected_features->protectedMemory; |
| 456 | } else if (vulkan_11_features) { |
| 457 | protectedMemory = vulkan_11_features->protectedMemory; |
| 458 | } |
| 459 | if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) { |
| 460 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", |
| 461 | "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " |
| 462 | "protectedMemory feature being set as well."); |
| 463 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 464 | } |
| 465 | } |
| 466 | |
| 467 | return skip; |
| 468 | } |
| 469 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 470 | 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] | 471 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 472 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 473 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 474 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 475 | } |
| 476 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 477 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 478 | } |
| 479 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 480 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 481 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 482 | bool skip = false; |
| 483 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 484 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 485 | skip |= |
| 486 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 487 | |
| 488 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 489 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 490 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 491 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 492 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 493 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 494 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 498 | // queueFamilyIndexCount uint32_t values |
| 499 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 500 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 501 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 502 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 503 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 504 | } |
| 505 | } |
| 506 | |
| 507 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 508 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 509 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 510 | ((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] | 511 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 512 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 513 | "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] | 514 | } |
| 515 | } |
| 516 | |
| 517 | return skip; |
| 518 | } |
| 519 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 520 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 521 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 522 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 523 | |
| 524 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 525 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 526 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 527 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 528 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 529 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942", |
| 530 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 531 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 535 | // queueFamilyIndexCount uint32_t values |
| 536 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 537 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941", |
| 538 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 539 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 540 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 541 | } |
| 542 | } |
| 543 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 544 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 545 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 546 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 547 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 548 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 549 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 550 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 551 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 552 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 553 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 554 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 555 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 556 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 557 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 558 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 559 | skip |= LogError( |
| 560 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 561 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 562 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 563 | } |
| 564 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 565 | // 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] | 566 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 567 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 568 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 569 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 570 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 574 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 575 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 576 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 577 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 578 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 579 | ") are not equal.", |
| 580 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 584 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 585 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 586 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 587 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 588 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 592 | skip |= LogError( |
| 593 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 594 | "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] | 595 | } |
| 596 | } |
| 597 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 598 | // 3D image may have only 1 layer |
| 599 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 600 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 601 | "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] | 602 | } |
| 603 | |
| 604 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 605 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
| 606 | ((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] | 607 | (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 608 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 609 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 613 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 614 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 615 | // At least one of the legal attachment bits must be set |
| 616 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 617 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 618 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 619 | } |
| 620 | // No flags other than the legal attachment bits may be set |
| 621 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 622 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 623 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 624 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 625 | } |
| 626 | } |
| 627 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 628 | // 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] | 629 | 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] | 630 | // Max mip levels is different for corner-sampled images vs normal images. |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 631 | uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim))) |
| 632 | : (uint32_t)(floor(log2(maxDim)) + 1); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 633 | if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 634 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 635 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 636 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 637 | "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] | 638 | } |
| 639 | |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 640 | 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] | 641 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 642 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 643 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 644 | } |
| 645 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 646 | 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] | 647 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 648 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 649 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 650 | } |
| 651 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 652 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 653 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
| 654 | if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 655 | ((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] | 656 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 657 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 658 | "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] | 659 | } |
| 660 | |
| 661 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
| 662 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
| 663 | // Linear tiling is unsupported |
| 664 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 665 | skip |= LogError(device, kVUID_PVError_InvalidUsage, |
| 666 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 667 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | // Sparse 1D image isn't valid |
| 671 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 672 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 673 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 677 | 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] | 678 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 679 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 680 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 684 | 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] | 685 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 686 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 687 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | // Multi-sample 2D image when device doesn't support it |
| 691 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 692 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 693 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 694 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 695 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 696 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 697 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 698 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 699 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 700 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 701 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 702 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 703 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 704 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 705 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 706 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 707 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 708 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 709 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 710 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 711 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 712 | } |
| 713 | } |
| 714 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 715 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 716 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 717 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 718 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 719 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 720 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 721 | } |
| 722 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 723 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 724 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 725 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 726 | } |
| 727 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 728 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 729 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 730 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 731 | } |
| 732 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 733 | |
| 734 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 735 | 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] | 736 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 737 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 738 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 739 | } |
| 740 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 741 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 742 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 743 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 744 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must " |
| 745 | "not be a depth/stencil format."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 746 | } |
| 747 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 748 | 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] | 749 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 750 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 751 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 752 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 753 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 754 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 755 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 756 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 757 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 758 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 759 | } |
| 760 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 761 | |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 762 | if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) && |
| 763 | (FormatHasDepth(pCreateInfo->format) == false)) { |
| 764 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533", |
| 765 | "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the " |
| 766 | "format must be a depth or depth/stencil format."); |
| 767 | } |
| 768 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 769 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext); |
| 770 | if (image_stencil_struct != nullptr) { |
| 771 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 772 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 773 | // No flags other than the legal attachment bits may be set |
| 774 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 775 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 776 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 777 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 778 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 779 | "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] | 780 | } |
| 781 | } |
| 782 | |
| 783 | if (FormatIsDepthOrStencil(pCreateInfo->format)) { |
| 784 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 785 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
| 786 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 787 | LogError(device, "VUID-VkImageCreateInfo-Format-02536", |
| 788 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 789 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device " |
| 790 | "maxFramebufferWidth"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
| 794 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 795 | LogError(device, "VUID-VkImageCreateInfo-format-02537", |
| 796 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 797 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device " |
| 798 | "maxFramebufferHeight"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 799 | } |
| 800 | } |
| 801 | |
| 802 | if (!physical_device_features.shaderStorageImageMultisample && |
| 803 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 804 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 805 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 806 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 807 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 808 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 809 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 813 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 814 | skip |= LogError( |
| 815 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 816 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 817 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 818 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 819 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 820 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 821 | skip |= LogError( |
| 822 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 823 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 824 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 825 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 826 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 827 | } |
| 828 | |
| 829 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 830 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 831 | skip |= LogError( |
| 832 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 833 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 834 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 835 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 836 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 837 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 838 | skip |= LogError( |
| 839 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 840 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 841 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 842 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 843 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 844 | } |
| 845 | } |
| 846 | } |
Spencer Fricke | ca52b5c | 2020-03-16 17:34:00 -0700 | [diff] [blame] | 847 | |
| 848 | if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 849 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 850 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968", |
| 851 | "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images " |
| 852 | "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
| 853 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 854 | |
| 855 | if (device_extensions.vk_ext_image_drm_format_modifier) { |
| 856 | const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext); |
| 857 | const auto drm_format_mod_explict = |
| 858 | lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext); |
| 859 | if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 860 | if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) || |
| 861 | ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) { |
| 862 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261", |
| 863 | "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have " |
| 864 | "either VkImageDrmFormatModifierListCreateInfoEXT or " |
| 865 | "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain"); |
| 866 | } |
| 867 | } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) { |
| 868 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262", |
| 869 | "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a " |
| 870 | "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT " |
| 871 | "in the pNext chain"); |
| 872 | } |
| 873 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 874 | |
| 875 | if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) { |
| 876 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 877 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557", |
| 878 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 879 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 880 | } |
| 881 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 882 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558", |
| 883 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 884 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
| 885 | } |
| 886 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 887 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 888 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 889 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 890 | } |
| 891 | } |
| 892 | if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) { |
| 893 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 894 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565", |
| 895 | "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 896 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 897 | } |
| 898 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 899 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566", |
| 900 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 901 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 902 | } |
| 903 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 904 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567", |
| 905 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 906 | "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT."); |
| 907 | } |
| 908 | if (pCreateInfo->mipLevels != 1) { |
| 909 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568", |
| 910 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.", |
| 911 | pCreateInfo->mipLevels); |
| 912 | } |
| 913 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 914 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 915 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 916 | return skip; |
| 917 | } |
| 918 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 919 | bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 920 | const VkAllocationCallbacks *pAllocator, VkImageView *pView) const { |
| 921 | bool skip = false; |
| 922 | |
| 923 | if (pCreateInfo != nullptr) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 924 | // Validate feature set if using CUBE_ARRAY |
| 925 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) { |
| 926 | skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004", |
| 927 | "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without " |
| 928 | "enabling the imageCubeArray feature."); |
| 929 | } |
| 930 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 931 | if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 932 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) { |
| 933 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960", |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 934 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.", |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 935 | pCreateInfo->subresourceRange.layerCount); |
| 936 | } |
| 937 | 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] | 938 | skip |= LogError( |
| 939 | device, "VUID-VkImageViewCreateInfo-viewType-02961", |
| 940 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.", |
| 941 | pCreateInfo->subresourceRange.layerCount); |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 942 | } |
| 943 | } |
| 944 | } |
| 945 | return skip; |
| 946 | } |
| 947 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 948 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 949 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 950 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 951 | |
| 952 | // Note: for numerical correctness |
| 953 | // - float comparisons should expect NaN (comparison always false). |
| 954 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 955 | |
| 956 | 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] | 957 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 958 | if (v1_f <= 0.0f) return true; |
| 959 | |
| 960 | float intpart; |
| 961 | const float fract = modff(v1_f, &intpart); |
| 962 | |
| 963 | assert(std::numeric_limits<float>::radix == 2); |
| 964 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 965 | if (intpart >= u32_max_plus1) return false; |
| 966 | |
| 967 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
| 968 | if (v1_u32 < v2_u32) |
| 969 | return true; |
| 970 | else if (v1_u32 == v2_u32 && fract == 0.0f) |
| 971 | return true; |
| 972 | else |
| 973 | return false; |
| 974 | }; |
| 975 | |
| 976 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 977 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 978 | return (v1_f <= v2_f); |
| 979 | }; |
| 980 | |
| 981 | // width |
| 982 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 983 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 984 | |
| 985 | if (!(viewport.width > 0.0f)) { |
| 986 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 987 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 988 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 989 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 990 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 991 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 992 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 993 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 994 | } 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] | 995 | skip |= LogWarning(object, kVUID_PVError_NONE, |
| 996 | "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 |
| 997 | "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.", |
| 998 | fn_name, parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | // height |
| 1002 | bool height_healthy = true; |
Mark Lobodzinski | a09ab94 | 2020-02-20 11:01:59 -0700 | [diff] [blame] | 1003 | 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] | 1004 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1005 | |
| 1006 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1007 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1008 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 1009 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1010 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1011 | height_healthy = false; |
| 1012 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1013 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 1014 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 1015 | ").", |
| 1016 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1017 | } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) { |
| 1018 | height_healthy = false; |
| 1019 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1020 | skip |= LogWarning( |
| 1021 | object, kVUID_PVError_NONE, |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1022 | "%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] | 1023 | "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.", |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1024 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | // x |
| 1028 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1029 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1030 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1031 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 1032 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1033 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
| 1036 | // x + width |
| 1037 | if (x_healthy && width_healthy) { |
| 1038 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1039 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1040 | skip |= LogError( |
| 1041 | object, "VUID-VkViewport-x-01232", |
| 1042 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1043 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 1044 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | // y |
| 1049 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1050 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1051 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1052 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 1053 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1054 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1055 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1056 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1057 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 1058 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1059 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | // y + height |
| 1063 | if (y_healthy && height_healthy) { |
| 1064 | const float boundary = viewport.y + viewport.height; |
| 1065 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1066 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1067 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 1068 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1069 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 1070 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1071 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1072 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1073 | LogError(object, "VUID-VkViewport-y-01777", |
| 1074 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 1075 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 1076 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1077 | } |
| 1078 | } |
| 1079 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1080 | if (!device_extensions.vk_ext_depth_range_unrestricted) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1081 | // minDepth |
| 1082 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1083 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1084 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1085 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 1086 | "[0.0, 1.0] range.", |
| 1087 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | // maxDepth |
| 1091 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1092 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1093 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1094 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 1095 | "[0.0, 1.0] range.", |
| 1096 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1097 | } |
| 1098 | } |
| 1099 | |
| 1100 | return skip; |
| 1101 | } |
| 1102 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1103 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1104 | VkShadingRatePaletteEntryNV shadingRate; |
| 1105 | uint32_t width; |
| 1106 | uint32_t height; |
| 1107 | }; |
| 1108 | |
| 1109 | // All palette entries with more than one pixel per fragment |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1110 | static SampleOrderInfo sampleOrderInfos[] = { |
| 1111 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 1112 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 1113 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 1114 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 1115 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 1116 | {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] | 1117 | }; |
| 1118 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 1119 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1120 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1121 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 1122 | SampleOrderInfo *sampleOrderInfo; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1123 | uint32_t infoIdx = 0; |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 1124 | for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1125 | if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) { |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1126 | sampleOrderInfo = &sampleOrderInfos[infoIdx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1127 | break; |
| 1128 | } |
| 1129 | } |
| 1130 | |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1131 | if (sampleOrderInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1132 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 1133 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 1134 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1135 | return skip; |
| 1136 | } |
| 1137 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1138 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1139 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1140 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 1141 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 1142 | ") must " |
| 1143 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 1144 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 1145 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1146 | } |
| 1147 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1148 | if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1149 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 1150 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1151 | ") must " |
| 1152 | "be equal to the product of sampleCount (=%" PRIu32 |
| 1153 | "), the fragment width for shadingRate " |
| 1154 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
| 1155 | order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1156 | } |
| 1157 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1158 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1159 | skip |= LogError( |
| 1160 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1161 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1162 | ") must " |
| 1163 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1164 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1165 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1166 | |
| 1167 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1168 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 1169 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 1170 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1171 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1172 | uint64_t sampleLocationsMask = 0; |
| 1173 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
| 1174 | const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i]; |
| 1175 | if (sampleLoc->pixelX >= sampleOrderInfo->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1176 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 1177 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1178 | } |
| 1179 | if (sampleLoc->pixelY >= sampleOrderInfo->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1180 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 1181 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1182 | } |
| 1183 | if (sampleLoc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1184 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 1185 | "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] | 1186 | } |
| 1187 | uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY); |
| 1188 | sampleLocationsMask |= 1ULL << idx; |
| 1189 | } |
| 1190 | |
| 1191 | uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 1192 | if (sampleLocationsMask != expectedMask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1193 | skip |= LogError( |
| 1194 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1195 | "The array pSampleLocations must contain exactly one entry for " |
| 1196 | "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] | 1197 | } |
| 1198 | |
| 1199 | return skip; |
| 1200 | } |
| 1201 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1202 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 1203 | uint32_t createInfoCount, |
| 1204 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1205 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1206 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1207 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1208 | |
| 1209 | if (pCreateInfos != nullptr) { |
| 1210 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1211 | bool has_dynamic_viewport = false; |
| 1212 | bool has_dynamic_scissor = false; |
| 1213 | bool has_dynamic_line_width = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1214 | bool has_dynamic_depth_bias = false; |
| 1215 | bool has_dynamic_blend_constant = false; |
| 1216 | bool has_dynamic_depth_bounds = false; |
| 1217 | bool has_dynamic_stencil_compare = false; |
| 1218 | bool has_dynamic_stencil_write = false; |
| 1219 | bool has_dynamic_stencil_reference = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1220 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1221 | bool has_dynamic_discard_rectangle_ext = false; |
| 1222 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1223 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1224 | bool has_dynamic_shading_rate_palette_nv = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1225 | bool has_dynamic_viewport_course_sample_order_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1226 | bool has_dynamic_line_stipple = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1227 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1228 | const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState; |
| 1229 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1230 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1231 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1232 | if (has_dynamic_viewport == true) { |
| 1233 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1234 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the " |
| 1235 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1236 | i); |
| 1237 | } |
| 1238 | has_dynamic_viewport = true; |
| 1239 | } |
| 1240 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) { |
| 1241 | if (has_dynamic_scissor == true) { |
| 1242 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1243 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the " |
| 1244 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1245 | i); |
| 1246 | } |
| 1247 | has_dynamic_scissor = true; |
| 1248 | } |
| 1249 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) { |
| 1250 | if (has_dynamic_line_width == true) { |
| 1251 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1252 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the " |
| 1253 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1254 | i); |
| 1255 | } |
| 1256 | has_dynamic_line_width = true; |
| 1257 | } |
| 1258 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) { |
| 1259 | if (has_dynamic_depth_bias == true) { |
| 1260 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1261 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the " |
| 1262 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1263 | i); |
| 1264 | } |
| 1265 | has_dynamic_depth_bias = true; |
| 1266 | } |
| 1267 | if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) { |
| 1268 | if (has_dynamic_blend_constant == true) { |
| 1269 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1270 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the " |
| 1271 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1272 | i); |
| 1273 | } |
| 1274 | has_dynamic_blend_constant = true; |
| 1275 | } |
| 1276 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) { |
| 1277 | if (has_dynamic_depth_bounds == true) { |
| 1278 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1279 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the " |
| 1280 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1281 | i); |
| 1282 | } |
| 1283 | has_dynamic_depth_bounds = true; |
| 1284 | } |
| 1285 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) { |
| 1286 | if (has_dynamic_stencil_compare == true) { |
| 1287 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1288 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in " |
| 1289 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1290 | i); |
| 1291 | } |
| 1292 | has_dynamic_stencil_compare = true; |
| 1293 | } |
| 1294 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) { |
| 1295 | if (has_dynamic_stencil_write == true) { |
| 1296 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1297 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in " |
| 1298 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1299 | i); |
| 1300 | } |
| 1301 | has_dynamic_stencil_write = true; |
| 1302 | } |
| 1303 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) { |
| 1304 | if (has_dynamic_stencil_reference == true) { |
| 1305 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1306 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in " |
| 1307 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1308 | i); |
| 1309 | } |
| 1310 | has_dynamic_stencil_reference = true; |
| 1311 | } |
| 1312 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) { |
| 1313 | if (has_dynamic_viewport_w_scaling_nv == true) { |
| 1314 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1315 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice " |
| 1316 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1317 | i); |
| 1318 | } |
| 1319 | has_dynamic_viewport_w_scaling_nv = true; |
| 1320 | } |
| 1321 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) { |
| 1322 | if (has_dynamic_discard_rectangle_ext == true) { |
| 1323 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1324 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice " |
| 1325 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1326 | i); |
| 1327 | } |
| 1328 | has_dynamic_discard_rectangle_ext = true; |
| 1329 | } |
| 1330 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) { |
| 1331 | if (has_dynamic_sample_locations_ext == true) { |
| 1332 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1333 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in " |
| 1334 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1335 | i); |
| 1336 | } |
| 1337 | has_dynamic_sample_locations_ext = true; |
| 1338 | } |
| 1339 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) { |
| 1340 | if (has_dynamic_exclusive_scissor_nv == true) { |
| 1341 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1342 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in " |
| 1343 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1344 | i); |
| 1345 | } |
| 1346 | has_dynamic_exclusive_scissor_nv = true; |
| 1347 | } |
| 1348 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) { |
| 1349 | if (has_dynamic_shading_rate_palette_nv == true) { |
| 1350 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1351 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was " |
| 1352 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1353 | i); |
| 1354 | } |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1355 | has_dynamic_shading_rate_palette_nv = true; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1356 | } |
| 1357 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) { |
| 1358 | if (has_dynamic_viewport_course_sample_order_nv == true) { |
| 1359 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1360 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was " |
| 1361 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1362 | i); |
| 1363 | } |
| 1364 | has_dynamic_viewport_course_sample_order_nv = true; |
| 1365 | } |
| 1366 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) { |
| 1367 | if (has_dynamic_line_stipple == true) { |
| 1368 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1369 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the " |
| 1370 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1371 | i); |
| 1372 | } |
| 1373 | has_dynamic_line_stipple = true; |
| 1374 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1375 | } |
| 1376 | } |
| 1377 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1378 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 1379 | if ((feedback_struct != nullptr) && |
| 1380 | (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1381 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668", |
| 1382 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 1383 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 1384 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
| 1385 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1386 | } |
| 1387 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1388 | // 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] | 1389 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1390 | // Collect active stages and other information |
| 1391 | // Only want to loop through pStages once |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1392 | uint32_t active_shaders = 0; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1393 | bool has_eval = false; |
| 1394 | bool has_control = false; |
| 1395 | if (pCreateInfos[i].pStages != nullptr) { |
| 1396 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 1397 | active_shaders |= pCreateInfos[i].pStages[stage_index].stage; |
| 1398 | |
| 1399 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 1400 | has_control = true; |
| 1401 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 1402 | has_eval = true; |
| 1403 | } |
| 1404 | |
| 1405 | skip |= validate_string( |
| 1406 | "vkCreateGraphicsPipelines", |
| 1407 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}), |
| 1408 | "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName); |
| 1409 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1410 | } |
| 1411 | |
| 1412 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
| 1413 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) { |
| 1414 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 1415 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 1416 | pCreateInfos[i].pTessellationState, |
| 1417 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1418 | "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
| 1419 | |
| 1420 | const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = { |
| 1421 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 1422 | |
| 1423 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
| 1424 | "VkPipelineTessellationDomainOriginStateCreateInfo", |
| 1425 | pCreateInfos[i].pTessellationState->pNext, |
| 1426 | ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo), |
| 1427 | allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1428 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 1429 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1430 | |
| 1431 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
| 1432 | pCreateInfos[i].pTessellationState->flags, |
| 1433 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 1434 | } |
| 1435 | |
| 1436 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) { |
| 1437 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 1438 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
| 1439 | pCreateInfos[i].pInputAssemblyState, |
| 1440 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1441 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 1442 | |
| 1443 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
| 1444 | pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1445 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1446 | |
| 1447 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
| 1448 | pCreateInfos[i].pInputAssemblyState->flags, |
| 1449 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 1450 | |
| 1451 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 1452 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
| 1453 | pCreateInfos[i].pInputAssemblyState->topology, |
| 1454 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 1455 | |
| 1456 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
| 1457 | pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable); |
| 1458 | } |
| 1459 | |
| 1460 | 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] | 1461 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1462 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1463 | if (pCreateInfos[i].pVertexInputState->flags != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1464 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 1465 | "vkCreateGraphicsPipelines: pararameter " |
| 1466 | "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.", |
| 1467 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1468 | } |
| 1469 | |
| 1470 | const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = { |
| 1471 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
| 1472 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 1473 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", |
| 1474 | pCreateInfos[i].pVertexInputState->pNext, 1, |
| 1475 | allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1476 | "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
| 1477 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1478 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 1479 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 1480 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1481 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 1482 | skip |= |
| 1483 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 1484 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
| 1485 | pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount, |
| 1486 | &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
| 1487 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 1488 | |
| 1489 | skip |= validate_array( |
| 1490 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 1491 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 1492 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 1493 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 1494 | |
| 1495 | if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) { |
| 1496 | for (uint32_t vertexBindingDescriptionIndex = 0; |
| 1497 | vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount; |
| 1498 | ++vertexBindingDescriptionIndex) { |
| 1499 | skip |= validate_ranged_enum( |
| 1500 | "vkCreateGraphicsPipelines", |
| 1501 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 1502 | AllVkVertexInputRateEnums, |
| 1503 | pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate, |
| 1504 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 1505 | } |
| 1506 | } |
| 1507 | |
| 1508 | if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) { |
| 1509 | for (uint32_t vertexAttributeDescriptionIndex = 0; |
| 1510 | vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount; |
| 1511 | ++vertexAttributeDescriptionIndex) { |
| 1512 | skip |= validate_ranged_enum( |
| 1513 | "vkCreateGraphicsPipelines", |
| 1514 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 1515 | AllVkFormatEnums, |
| 1516 | pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format, |
| 1517 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
| 1518 | } |
| 1519 | } |
| 1520 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1521 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1522 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 1523 | "vkCreateGraphicsPipelines: pararameter " |
| 1524 | "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is " |
| 1525 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1526 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1527 | } |
| 1528 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1529 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1530 | skip |= |
| 1531 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 1532 | "vkCreateGraphicsPipelines: pararameter " |
| 1533 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is " |
| 1534 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1535 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1536 | } |
| 1537 | |
| 1538 | std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1539 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 1540 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1541 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 1542 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1543 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 1544 | "vkCreateGraphicsPipelines: parameter " |
| 1545 | "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding " |
| 1546 | "(%" PRIu32 ") is not distinct.", |
| 1547 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1548 | } |
| 1549 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 1550 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1551 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1552 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 1553 | "vkCreateGraphicsPipelines: parameter " |
| 1554 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
| 1555 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1556 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1557 | } |
| 1558 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1559 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1560 | skip |= |
| 1561 | LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 1562 | "vkCreateGraphicsPipelines: parameter " |
| 1563 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
| 1564 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).", |
| 1565 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1566 | } |
| 1567 | } |
| 1568 | |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1569 | std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1570 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 1571 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1572 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 1573 | if (location_it != attribute_locations.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1574 | skip |= LogError( |
| 1575 | device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1576 | "vkCreateGraphicsPipelines: parameter " |
| 1577 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.", |
| 1578 | i, d, vertex_attrib_desc.location); |
| 1579 | } |
| 1580 | attribute_locations.insert(vertex_attrib_desc.location); |
| 1581 | |
| 1582 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 1583 | if (binding_it == vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1584 | skip |= LogError( |
| 1585 | device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1586 | "vkCreateGraphicsPipelines: parameter " |
| 1587 | " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist " |
| 1588 | "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.", |
| 1589 | i, d, vertex_attrib_desc.binding, i); |
| 1590 | } |
| 1591 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1592 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1593 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 1594 | "vkCreateGraphicsPipelines: parameter " |
| 1595 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
| 1596 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1597 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1598 | } |
| 1599 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1600 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1601 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 1602 | "vkCreateGraphicsPipelines: parameter " |
| 1603 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
| 1604 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1605 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1606 | } |
| 1607 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1608 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1609 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 1610 | "vkCreateGraphicsPipelines: parameter " |
| 1611 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 1612 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).", |
| 1613 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1614 | } |
| 1615 | } |
| 1616 | } |
| 1617 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1618 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 1619 | if (has_control && has_eval) { |
| 1620 | if (pCreateInfos[i].pTessellationState == nullptr) { |
| 1621 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
| 1622 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 1623 | "shader stage and a tessellation evaluation shader stage, " |
| 1624 | "pCreateInfos[%d].pTessellationState must not be NULL.", |
| 1625 | i, i); |
| 1626 | } else { |
| 1627 | const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
| 1628 | skip |= validate_struct_pnext( |
| 1629 | "vkCreateGraphicsPipelines", |
| 1630 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
| 1631 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1, |
| 1632 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 1633 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1634 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1635 | skip |= validate_reserved_flags( |
| 1636 | "vkCreateGraphicsPipelines", |
| 1637 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
| 1638 | pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1639 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1640 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
| 1641 | pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
| 1642 | skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 1643 | "vkCreateGraphicsPipelines: invalid parameter " |
| 1644 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
| 1645 | "should be >0 and <=%u.", |
| 1646 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
| 1647 | device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1648 | } |
| 1649 | } |
| 1650 | } |
| 1651 | |
| 1652 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 1653 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 1654 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 1655 | if (pCreateInfos[i].pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1656 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 1657 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 1658 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 1659 | "].pViewportState (=NULL) is not a valid pointer.", |
| 1660 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1661 | } else { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1662 | const auto &viewport_state = *pCreateInfos[i].pViewportState; |
| 1663 | |
| 1664 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1665 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 1666 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1667 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 1668 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1669 | } |
| 1670 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1671 | const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = { |
| 1672 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1673 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 1674 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1675 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 1676 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1677 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1678 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1679 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1680 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1681 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1682 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
| 1683 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1684 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo), |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1685 | allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
| 1686 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1687 | |
| 1688 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1689 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1690 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1691 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1692 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1693 | auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>( |
| 1694 | pCreateInfos[i].pViewportState->pNext); |
| 1695 | auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>( |
| 1696 | pCreateInfos[i].pViewportState->pNext); |
| 1697 | auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>( |
| 1698 | pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 1699 | const auto vp_swizzle_struct = |
| 1700 | lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1701 | const auto vp_w_scaling_struct = |
| 1702 | lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1703 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1704 | if (!physical_device_features.multiViewport) { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1705 | if (viewport_state.viewportCount != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1706 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 1707 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1708 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 1709 | ") is not 1.", |
| 1710 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1711 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1712 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1713 | if (viewport_state.scissorCount != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1714 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 1715 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1716 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 1717 | ") is not 1.", |
| 1718 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1719 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1720 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1721 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 1722 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1723 | skip |= LogError( |
| 1724 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 1725 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1726 | "disabled, but pCreateInfos[%" PRIu32 |
| 1727 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 1728 | ") is not 1.", |
| 1729 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1730 | } |
| 1731 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1732 | if (shading_rate_image_struct && |
| 1733 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1734 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 1735 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1736 | "disabled, but pCreateInfos[%" PRIu32 |
| 1737 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 1738 | ") is neither 0 nor 1.", |
| 1739 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1740 | } |
| 1741 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1742 | } else { // multiViewport enabled |
| 1743 | if (viewport_state.viewportCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1744 | skip |= LogError( |
| 1745 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1746 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1747 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1748 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 1749 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1750 | "].pViewportState->viewportCount (=%" PRIu32 |
| 1751 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1752 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1753 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1754 | |
| 1755 | if (viewport_state.scissorCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1756 | skip |= LogError( |
| 1757 | device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1758 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1759 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1760 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 1761 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1762 | "].pViewportState->scissorCount (=%" PRIu32 |
| 1763 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1764 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1765 | } |
| 1766 | } |
| 1767 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1768 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1769 | skip |= |
| 1770 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 1771 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 1772 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1773 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1774 | } |
| 1775 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1776 | 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] | 1777 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 1778 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1779 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 1780 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1781 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1782 | } |
| 1783 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1784 | if (viewport_state.scissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1785 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220", |
| 1786 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1787 | "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32 |
| 1788 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 1789 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1790 | } |
| 1791 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1792 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1793 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1794 | skip |= |
| 1795 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 1796 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 1797 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 1798 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 1799 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1800 | } |
| 1801 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1802 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1803 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1804 | skip |= LogError( |
| 1805 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1806 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 1807 | "] " |
| 1808 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 1809 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 1810 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1811 | } |
| 1812 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1813 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1814 | skip |= LogError( |
| 1815 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1816 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 1817 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1818 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 1819 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1820 | } |
| 1821 | |
| 1822 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1823 | skip |= LogError( |
| 1824 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1825 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 1826 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1827 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 1828 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1829 | } |
| 1830 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1831 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1832 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 1833 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 1834 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1835 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030", |
| 1836 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 1837 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 1838 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 1839 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1840 | } |
| 1841 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1842 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1843 | shading_rate_image_struct->viewportCount > 0 && |
| 1844 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1845 | skip |= LogError( |
| 1846 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1847 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1848 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 1849 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1850 | i, i); |
| 1851 | } |
| 1852 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 1853 | if (vp_swizzle_struct) { |
| 1854 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1855 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 1856 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 1857 | " does " |
| 1858 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 1859 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 1860 | } |
| 1861 | } |
| 1862 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1863 | // validate the VkViewports |
| 1864 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 1865 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 1866 | 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] | 1867 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 1868 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 1869 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 1870 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1871 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1872 | } |
| 1873 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1874 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1875 | 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] | 1876 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1877 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1878 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 1879 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 1880 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1881 | } |
| 1882 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1883 | if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1884 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1885 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1886 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 1887 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 1888 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1889 | } |
| 1890 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1891 | if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1892 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1893 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1894 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 1895 | "VK_EXT_sample_locations extension is not enabled.", |
| 1896 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1897 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1898 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1899 | if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1900 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1901 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1902 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 1903 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 1904 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1905 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1906 | |
| 1907 | if (coarse_sample_order_struct && |
| 1908 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 1909 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1910 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 1911 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1912 | "] " |
| 1913 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 1914 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 1915 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1916 | } |
| 1917 | |
| 1918 | if (coarse_sample_order_struct) { |
| 1919 | 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] | 1920 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1921 | } |
| 1922 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1923 | |
| 1924 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 1925 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1926 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 1927 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1928 | "] " |
| 1929 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 1930 | ") " |
| 1931 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 1932 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1933 | } |
| 1934 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1935 | skip |= LogError( |
| 1936 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1937 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1938 | "] " |
| 1939 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 1940 | i); |
| 1941 | } |
| 1942 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1943 | } |
| 1944 | |
| 1945 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1946 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
| 1947 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 1948 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.", |
| 1949 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1950 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 1951 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
| 1952 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 1953 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 1954 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1955 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 1956 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1957 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1958 | "vkCreateGraphicsPipelines", |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 1959 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1960 | valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1961 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 1962 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1963 | |
| 1964 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1965 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1966 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1967 | pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1968 | |
| 1969 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1970 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1971 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 1972 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 1973 | |
| 1974 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1975 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1976 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 1977 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 1978 | pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1979 | true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1980 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1981 | skip |= validate_flags( |
| 1982 | "vkCreateGraphicsPipelines", |
| 1983 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 1984 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 1985 | kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1986 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1987 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1988 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1989 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 1990 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 1991 | |
| 1992 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1993 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1994 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 1995 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 1996 | |
| 1997 | 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] | 1998 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 1999 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 2000 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 2001 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2002 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2003 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2004 | if (!physical_device_features.sampleRateShading) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2005 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 2006 | "vkCreateGraphicsPipelines(): parameter " |
| 2007 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.", |
| 2008 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2009 | } |
| 2010 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 2011 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
| 2012 | if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2013 | skip |= LogError( |
| 2014 | device, |
| 2015 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2016 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2017 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2018 | } |
| 2019 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2020 | |
| 2021 | const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>( |
| 2022 | pCreateInfos[i].pRasterizationState->pNext); |
| 2023 | |
| 2024 | if (line_state) { |
| 2025 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 2026 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
| 2027 | if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) { |
| 2028 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2029 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2030 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2031 | "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
| 2032 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2033 | } |
| 2034 | if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) { |
| 2035 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2036 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2037 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2038 | "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
| 2039 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2040 | } |
| 2041 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) { |
| 2042 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2043 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2044 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2045 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
| 2046 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2047 | } |
| 2048 | } |
| 2049 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 2050 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 2051 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2052 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
| 2053 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the " |
| 2054 | "range [1,256].", |
| 2055 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2056 | } |
| 2057 | } |
| 2058 | const auto *line_features = |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 2059 | lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2060 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2061 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2062 | skip |= |
| 2063 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
| 2064 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2065 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 2066 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2067 | } |
| 2068 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2069 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2070 | skip |= |
| 2071 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
| 2072 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2073 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 2074 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2075 | } |
| 2076 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2077 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2078 | skip |= |
| 2079 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
| 2080 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2081 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 2082 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2083 | } |
| 2084 | if (line_state->stippledLineEnable) { |
| 2085 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2086 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2087 | skip |= |
| 2088 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
| 2089 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2090 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 2091 | "stippledRectangularLines feature.", |
| 2092 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2093 | } |
| 2094 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2095 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2096 | skip |= |
| 2097 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
| 2098 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2099 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 2100 | "stippledBresenhamLines feature.", |
| 2101 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2102 | } |
| 2103 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2104 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2105 | skip |= |
| 2106 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
| 2107 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2108 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 2109 | "stippledSmoothLines feature.", |
| 2110 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2111 | } |
| 2112 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
| 2113 | (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2114 | skip |= |
| 2115 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
| 2116 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2117 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 2118 | "stippledRectangularLines and strictLines features.", |
| 2119 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2120 | } |
| 2121 | } |
| 2122 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2123 | } |
| 2124 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2125 | bool uses_color_attachment = false; |
| 2126 | bool uses_depthstencil_attachment = false; |
| 2127 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2128 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2129 | const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass); |
| 2130 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2131 | const auto &subpasses_uses = subpasses_uses_it->second; |
| 2132 | if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) |
| 2133 | uses_color_attachment = true; |
| 2134 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) |
| 2135 | uses_depthstencil_attachment = true; |
| 2136 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2137 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2138 | } |
| 2139 | |
| 2140 | if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2141 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2142 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2143 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2144 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2145 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2146 | |
| 2147 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2148 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2149 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2150 | pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2151 | |
| 2152 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2153 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2154 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 2155 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 2156 | |
| 2157 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2158 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2159 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 2160 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 2161 | |
| 2162 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2163 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2164 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 2165 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2166 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2167 | |
| 2168 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2169 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2170 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 2171 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 2172 | |
| 2173 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2174 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2175 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 2176 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 2177 | |
| 2178 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2179 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2180 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 2181 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2182 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2183 | |
| 2184 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2185 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2186 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 2187 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2188 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2189 | |
| 2190 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2191 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2192 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 2193 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2194 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2195 | |
| 2196 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2197 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2198 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 2199 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2200 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2201 | |
| 2202 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2203 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2204 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
| 2205 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2206 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2207 | |
| 2208 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2209 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2210 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
| 2211 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2212 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2213 | |
| 2214 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2215 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2216 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 2217 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2218 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2219 | |
| 2220 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2221 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2222 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 2223 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2224 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2225 | |
| 2226 | 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] | 2227 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 2228 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 2229 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 2230 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2231 | } |
| 2232 | } |
| 2233 | |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2234 | const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = { |
| 2235 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT}; |
| 2236 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2237 | if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2238 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 2239 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 2240 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2241 | pCreateInfos[i].pColorBlendState, |
| 2242 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2243 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
| 2244 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2245 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2246 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2247 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
| 2248 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext, |
| 2249 | ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo), |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2250 | allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2251 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 2252 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2253 | |
| 2254 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2255 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2256 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2257 | pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2258 | |
| 2259 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2260 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2261 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 2262 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 2263 | |
| 2264 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2265 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2266 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 2267 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2268 | pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2269 | true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2270 | |
| 2271 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
| 2272 | for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 2273 | ++attachmentIndex) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2274 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2275 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
| 2276 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2277 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable); |
| 2278 | |
| 2279 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2280 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2281 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
| 2282 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2283 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2284 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2285 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2286 | |
| 2287 | skip |= validate_ranged_enum( |
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].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
| 2290 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2291 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2292 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2293 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2294 | |
| 2295 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2296 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2297 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
| 2298 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2299 | "VkBlendOp", AllVkBlendOpEnums, |
| 2300 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2301 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2302 | |
| 2303 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2304 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2305 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
| 2306 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2307 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2308 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2309 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2310 | |
| 2311 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2312 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2313 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
| 2314 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2315 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 2316 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2317 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2318 | |
| 2319 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2320 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2321 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
| 2322 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2323 | "VkBlendOp", AllVkBlendOpEnums, |
| 2324 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2325 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2326 | |
| 2327 | skip |= |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2328 | validate_flags("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2329 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
| 2330 | ParameterName::IndexVector{i, attachmentIndex}), |
| 2331 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
| 2332 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2333 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2334 | } |
| 2335 | } |
| 2336 | |
| 2337 | 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] | 2338 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 2339 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 2340 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2341 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2342 | } |
| 2343 | |
| 2344 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 2345 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 2346 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2347 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2348 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2349 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, |
| 2350 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2351 | } |
| 2352 | } |
| 2353 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2354 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2355 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 2356 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 2357 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2358 | skip |= |
| 2359 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame^] | 2360 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2361 | "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^] | 2362 | "and pCreateInfos->basePipelineIndex is not -1.", |
| 2363 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2364 | } |
| 2365 | } |
| 2366 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2367 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 2368 | if (pCreateInfos[i].basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2369 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame^] | 2370 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2371 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame^] | 2372 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 2373 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2374 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2375 | } else { |
Mike Schuchardt | e5c15cf | 2020-04-06 22:57:13 -0700 | [diff] [blame] | 2376 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame^] | 2377 | skip |= |
| 2378 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
| 2379 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid" |
| 2380 | "index into the pCreateInfos array, of size %d.", |
| 2381 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2382 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2383 | } |
| 2384 | } |
| 2385 | |
sfricke-samsung | 898cf22 | 2020-05-15 23:10:19 -0700 | [diff] [blame] | 2386 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) { |
| 2387 | skip |= LogError( |
| 2388 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764", |
| 2389 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE", |
| 2390 | i); |
| 2391 | } |
| 2392 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2393 | if (pCreateInfos[i].pRasterizationState) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2394 | if (!device_extensions.vk_nv_fill_rectangle) { |
| 2395 | if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
| 2396 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2397 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 2398 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 2399 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 2400 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2401 | } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2402 | (physical_device_features.fillModeNonSolid == false)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2403 | skip |= LogError(device, kVUID_PVError_DeviceFeature, |
| 2404 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame^] | 2405 | "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
| 2406 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2407 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2408 | } |
| 2409 | } else { |
| 2410 | if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2411 | (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
| 2412 | (physical_device_features.fillModeNonSolid == false)) { |
| 2413 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2414 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 2415 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame^] | 2416 | "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
| 2417 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2418 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2419 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2420 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2421 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2422 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2423 | (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2424 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 2425 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 2426 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 2427 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 2428 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
| 2429 | i, i, pCreateInfos[i].pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2430 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2431 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2432 | } |
| 2433 | } |
| 2434 | |
| 2435 | return skip; |
| 2436 | } |
| 2437 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2438 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 2439 | uint32_t createInfoCount, |
| 2440 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 2441 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2442 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2443 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2444 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2445 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2446 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 2447 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2448 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 2449 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2450 | skip |= |
| 2451 | LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669", |
| 2452 | "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32 |
| 2453 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".", |
| 2454 | i, feedback_struct->pipelineStageCreationFeedbackCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2455 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2456 | |
| 2457 | // Make sure compute stage is selected |
| 2458 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2459 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
| 2460 | "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
| 2461 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2462 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2463 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2464 | return skip; |
| 2465 | } |
| 2466 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2467 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2468 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2469 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2470 | |
| 2471 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2472 | const auto &features = physical_device_features; |
| 2473 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2474 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2475 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 2476 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2477 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 2478 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 2479 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 2480 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2481 | } |
| 2482 | |
| 2483 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 2484 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2485 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 2486 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 2487 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2488 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2489 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2490 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2491 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 2492 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2493 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 2494 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2495 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2496 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2497 | } |
| 2498 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2499 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 2500 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2501 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 2502 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2503 | } |
| 2504 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2505 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 2506 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2507 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 2508 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2509 | } |
| 2510 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2511 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2512 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2513 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2514 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 2515 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2516 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 2517 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 2518 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 2519 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2520 | } |
| 2521 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2522 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 2523 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2524 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2525 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2526 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2527 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 2528 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2529 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2530 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2531 | } |
| 2532 | |
| 2533 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 2534 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2535 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 2536 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 2537 | const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext); |
| 2538 | if (sampler_reduction != nullptr) { |
| 2539 | if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
| 2540 | skip |= LogError( |
| 2541 | device, "VUID-VkSamplerCreateInfo-compareEnable-01423", |
| 2542 | "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE."); |
| 2543 | } |
| 2544 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2545 | } |
| 2546 | |
| 2547 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 2548 | // valid VkBorderColor value |
| 2549 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2550 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2551 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2552 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 2553 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2554 | } |
| 2555 | |
| 2556 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the |
| 2557 | // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2558 | if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2559 | ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2560 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2561 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2562 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2563 | LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079", |
| 2564 | "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE " |
| 2565 | "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] | 2566 | } |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2567 | |
| 2568 | // Checks for the IMG cubic filtering extension |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2569 | if (device_extensions.vk_img_filter_cubic) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2570 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 2571 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2572 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 2573 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 2574 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2575 | } |
| 2576 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2577 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2578 | // Check for valid Lod range |
| 2579 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2580 | skip |= |
| 2581 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 2582 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2583 | } |
| 2584 | |
| 2585 | // Check mipLodBias to device limit |
| 2586 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2587 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 2588 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 2589 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2590 | } |
| 2591 | |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2592 | const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
| 2593 | if (sampler_conversion != nullptr) { |
| 2594 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2595 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2596 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2597 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2598 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2599 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2600 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 2601 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 2602 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 2603 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 2604 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 2605 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 2606 | } |
| 2607 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 2608 | |
| 2609 | if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) { |
| 2610 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
| 2611 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574", |
| 2612 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2613 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2614 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
| 2615 | } |
| 2616 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
| 2617 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575", |
| 2618 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2619 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 2620 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
| 2621 | } |
| 2622 | if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) { |
| 2623 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576", |
| 2624 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2625 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.", |
| 2626 | pCreateInfo->minLod, pCreateInfo->maxLod); |
| 2627 | } |
| 2628 | if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 2629 | (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) || |
| 2630 | ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 2631 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) { |
| 2632 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577", |
| 2633 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2634 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be " |
| 2635 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER", |
| 2636 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 2637 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
| 2638 | } |
| 2639 | if (pCreateInfo->anisotropyEnable) { |
| 2640 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578", |
| 2641 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2642 | "pCreateInfo->anisotropyEnable must be VK_FALSE"); |
| 2643 | } |
| 2644 | if (pCreateInfo->compareEnable) { |
| 2645 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579", |
| 2646 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2647 | "pCreateInfo->compareEnable must be VK_FALSE"); |
| 2648 | } |
| 2649 | if (pCreateInfo->unnormalizedCoordinates) { |
| 2650 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580", |
| 2651 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2652 | "pCreateInfo->unnormalizedCoordinates must be VK_FALSE"); |
| 2653 | } |
| 2654 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2655 | } |
| 2656 | |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 2657 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 2658 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
| 2659 | if (!device_extensions.vk_ext_custom_border_color) { |
| 2660 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2661 | "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n", |
| 2662 | string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 2663 | } |
| 2664 | auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext); |
| 2665 | if (!custom_create_info) { |
| 2666 | skip |= |
| 2667 | LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011", |
| 2668 | "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT " |
| 2669 | "struct in pNext chain.\n", |
| 2670 | string_VkBorderColor(pCreateInfo->borderColor)); |
| 2671 | } else { |
| 2672 | if ((custom_create_info->format != VK_FORMAT_UNDEFINED) && |
| 2673 | ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) || |
| 2674 | (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT && |
| 2675 | !FormatIsSampledFloat(custom_create_info->format)))) { |
| 2676 | skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013", |
| 2677 | "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s " |
| 2678 | "whose type does not match\n", |
| 2679 | string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format)); |
| 2680 | ; |
| 2681 | } |
| 2682 | } |
| 2683 | } |
| 2684 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2685 | return skip; |
| 2686 | } |
| 2687 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2688 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 2689 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 2690 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2691 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2692 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2693 | |
| 2694 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2695 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 2696 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 2697 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2698 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 2699 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 2700 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 2701 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 2702 | ++descriptor_index) { |
| 2703 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Spencer Fricke | b0e3082 | 2020-03-23 10:32:30 -0700 | [diff] [blame] | 2704 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2705 | "vkCreateDescriptorSetLayout: required parameter " |
| 2706 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE", |
| 2707 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2708 | } |
| 2709 | } |
| 2710 | } |
| 2711 | |
| 2712 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 2713 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 2714 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2715 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
| 2716 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 2717 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits " |
| 2718 | "values.", |
| 2719 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2720 | } |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 2721 | |
| 2722 | if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) && |
| 2723 | (pCreateInfo->pBindings[i].stageFlags != 0) && |
| 2724 | (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) { |
| 2725 | skip |= |
| 2726 | LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510", |
| 2727 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and " |
| 2728 | "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags " |
| 2729 | "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s", |
| 2730 | i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str()); |
| 2731 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2732 | } |
| 2733 | } |
| 2734 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2735 | return skip; |
| 2736 | } |
| 2737 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2738 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 2739 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2740 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2741 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2742 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 2743 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2744 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 2745 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2746 | } |
| 2747 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2748 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 2749 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 2750 | const bool validateDstSet) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2751 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2752 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2753 | if (pDescriptorWrites != NULL) { |
| 2754 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 2755 | // descriptorCount must be greater than 0 |
| 2756 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 2757 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2758 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 2759 | "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2760 | } |
| 2761 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2762 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
| 2763 | if (validateDstSet) { |
| 2764 | // dstSet must be a valid VkDescriptorSet handle |
| 2765 | skip |= validate_required_handle(vkCallingFunction, |
| 2766 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 2767 | pDescriptorWrites[i].dstSet); |
| 2768 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2769 | |
| 2770 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 2771 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 2772 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 2773 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 2774 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 2775 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 2776 | // 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] | 2777 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures. |
| 2778 | // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2779 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2780 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322", |
| 2781 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 2782 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 2783 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 2784 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.", |
| 2785 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2786 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 2787 | // 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] | 2788 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout |
| 2789 | // member of any given element of pImageInfo must be a valid VkImageLayout |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2790 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 2791 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2792 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2793 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 2794 | ParameterName::IndexVector{i, descriptor_index}), |
| 2795 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2796 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2797 | } |
| 2798 | } |
| 2799 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 2800 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 2801 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 2802 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 2803 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 2804 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 2805 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 2806 | // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2807 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2808 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
| 2809 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 2810 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 2811 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
| 2812 | "pDescriptorWrites[%d].pBufferInfo must not be NULL.", |
| 2813 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2814 | } else { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 2815 | const auto *robustness2_features = |
| 2816 | lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 2817 | if (robustness2_features && robustness2_features->nullDescriptor) { |
| 2818 | for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; |
| 2819 | ++descriptorIndex) { |
| 2820 | if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE && |
| 2821 | (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 || |
| 2822 | pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) { |
| 2823 | skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999", |
| 2824 | "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, " |
| 2825 | "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.", |
| 2826 | vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset, |
| 2827 | pDescriptorWrites[i].pBufferInfo[descriptorIndex].range); |
| 2828 | } |
| 2829 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2830 | } |
| 2831 | } |
| 2832 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 2833 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 2834 | // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2835 | } |
| 2836 | |
| 2837 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 2838 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2839 | VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2840 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 2841 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 2842 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2843 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2844 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
| 2845 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 2846 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 2847 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2848 | } |
| 2849 | } |
| 2850 | } |
| 2851 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 2852 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2853 | VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2854 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 2855 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 2856 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2857 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2858 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
| 2859 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 2860 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 2861 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2862 | } |
| 2863 | } |
| 2864 | } |
| 2865 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 2866 | // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR |
| 2867 | // or VkWriteDescriptorSetInlineUniformBlockEX |
| 2868 | if (pDescriptorWrites[i].pNext) { |
| 2869 | if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
| 2870 | const auto *pNext_struct = |
| 2871 | lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext); |
| 2872 | if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 2873 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382", |
| 2874 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext" |
| 2875 | "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose " |
| 2876 | "accelerationStructureCount %d member equals descriptorCount %d.", |
| 2877 | vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1, |
| 2878 | pDescriptorWrites[i].descriptorCount); |
| 2879 | } |
| 2880 | // further checks only if we have right structtype |
| 2881 | if (pNext_struct) { |
| 2882 | if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 2883 | skip |= LogError( |
| 2884 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236", |
| 2885 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 2886 | ".", |
| 2887 | vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
| 2888 | } |
| 2889 | if (pNext_struct->accelerationStructureCount == 0) { |
| 2890 | skip |= LogError( |
| 2891 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength", |
| 2892 | "%s(): accelerationStructureCount must be greater than 0 ."); |
| 2893 | } |
| 2894 | } |
| 2895 | } |
| 2896 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2897 | } |
| 2898 | } |
| 2899 | return skip; |
| 2900 | } |
| 2901 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2902 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 2903 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 2904 | uint32_t descriptorCopyCount, |
| 2905 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
| 2906 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites); |
| 2907 | } |
| 2908 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2909 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2910 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2911 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2912 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 2913 | } |
| 2914 | |
| 2915 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2916 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2917 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2918 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 2919 | } |
| 2920 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2921 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 2922 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2923 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2924 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2925 | |
| 2926 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2927 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 2928 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2929 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 2930 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2931 | return skip; |
| 2932 | } |
| 2933 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2934 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2935 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2936 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2937 | |
| 2938 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 2939 | const char *cmd_name = "vkBeginCommandBuffer"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2940 | const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo; |
| 2941 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2942 | // Implicit VUs |
| 2943 | // validate only sType here; pointer has to be validated in core_validation |
| 2944 | const bool kNotRequired = false; |
| 2945 | const char *kNoVUID = nullptr; |
| 2946 | skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", |
| 2947 | pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID, |
| 2948 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2949 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2950 | if (pInfo) { |
| 2951 | const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = { |
| 2952 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT}; |
| 2953 | skip |= validate_struct_pnext( |
| 2954 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext, |
| 2955 | ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2956 | GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", |
| 2957 | "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2958 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2959 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2960 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2961 | // Explicit VUs |
| 2962 | if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2963 | skip |= LogError( |
| 2964 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2965 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 2966 | cmd_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2967 | } |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2968 | |
| 2969 | if (physical_device_features.inheritedQueries) { |
| 2970 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2971 | AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2972 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2973 | } else { // !inheritedQueries |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2974 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags, |
Petr Kraus | 43aed2c | 2019-08-18 13:59:16 +0200 | [diff] [blame] | 2975 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2976 | } |
| 2977 | |
| 2978 | if (physical_device_features.pipelineStatisticsQuery) { |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2979 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2980 | AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags, |
Petr Kraus | 43aed2c | 2019-08-18 13:59:16 +0200 | [diff] [blame] | 2981 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2982 | } else { // !pipelineStatisticsQuery |
| 2983 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics, |
| 2984 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2985 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 2986 | |
| 2987 | const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext); |
| 2988 | if (conditional_rendering) { |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 2989 | const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 2990 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 2991 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2992 | skip |= LogError( |
| 2993 | commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 2994 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 2995 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 2996 | } |
| 2997 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2998 | } |
| 2999 | |
| 3000 | return skip; |
| 3001 | } |
| 3002 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3003 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3004 | uint32_t viewportCount, const VkViewport *pViewports) 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 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3007 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3008 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3009 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 3010 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 3011 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3012 | } |
| 3013 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3014 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 3015 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 3016 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3017 | } |
| 3018 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 3019 | 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] | 3020 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3021 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 3022 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3023 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3024 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3025 | } |
| 3026 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3027 | |
| 3028 | if (pViewports) { |
| 3029 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 3030 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 3031 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3032 | skip |= manual_PreCallValidateViewport( |
| 3033 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3034 | } |
| 3035 | } |
| 3036 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3037 | return skip; |
| 3038 | } |
| 3039 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3040 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3041 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3042 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3043 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3044 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3045 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3046 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 3047 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 3048 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3049 | } |
| 3050 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3051 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 3052 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 3053 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3054 | } |
| 3055 | } else { // multiViewport enabled |
| 3056 | 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] | 3057 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3058 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 3059 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3060 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3061 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3062 | } |
| 3063 | } |
| 3064 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3065 | if (pScissors) { |
| 3066 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 3067 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3068 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3069 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3070 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3071 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 3072 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3073 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3074 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3075 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3076 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3077 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 3078 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3079 | } |
| 3080 | |
| 3081 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 3082 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3083 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 3084 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3085 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3086 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3087 | } |
| 3088 | |
| 3089 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 3090 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3091 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 3092 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3093 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3094 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3095 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3096 | } |
| 3097 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3098 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3099 | return skip; |
| 3100 | } |
| 3101 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3102 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3103 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3104 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3105 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3106 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 3107 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3108 | } |
| 3109 | |
| 3110 | return skip; |
| 3111 | } |
| 3112 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3113 | bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3114 | uint32_t firstVertex, uint32_t firstInstance) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3115 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3116 | if (vertexCount == 0) { |
| 3117 | // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make |
| 3118 | // this an error or leave as is. |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3119 | 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] | 3120 | } |
| 3121 | |
| 3122 | if (instanceCount == 0) { |
| 3123 | // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make |
| 3124 | // this an error or leave as is. |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3125 | 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] | 3126 | } |
| 3127 | return skip; |
| 3128 | } |
| 3129 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3130 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3131 | uint32_t count, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3132 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3133 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3134 | if (!physical_device_features.multiDrawIndirect && ((count > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3135 | skip |= LogError(device, kVUID_PVError_DeviceFeature, |
| 3136 | "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] | 3137 | } |
| 3138 | return skip; |
| 3139 | } |
| 3140 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3141 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3142 | VkDeviceSize offset, uint32_t count, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3143 | bool skip = false; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3144 | if (!physical_device_features.multiDrawIndirect && ((count > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3145 | skip |= |
| 3146 | LogError(device, kVUID_PVError_DeviceFeature, |
| 3147 | "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] | 3148 | } |
| 3149 | return skip; |
| 3150 | } |
| 3151 | |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3152 | bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3153 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3154 | bool skip = false; |
| 3155 | const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()"; |
| 3156 | if (offset & 3) { |
| 3157 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710", |
| 3158 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset); |
| 3159 | } |
| 3160 | |
| 3161 | if (countBufferOffset & 3) { |
| 3162 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716", |
| 3163 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, |
| 3164 | countBufferOffset); |
| 3165 | } |
| 3166 | return skip; |
| 3167 | } |
| 3168 | |
| 3169 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3170 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3171 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3172 | uint32_t stride) const { |
| 3173 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3174 | } |
| 3175 | |
| 3176 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3177 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3178 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3179 | uint32_t stride) const { |
| 3180 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3181 | } |
| 3182 | |
| 3183 | bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3184 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3185 | bool skip = false; |
| 3186 | const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()"; |
| 3187 | if (offset & 3) { |
| 3188 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710", |
| 3189 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset); |
| 3190 | } |
| 3191 | |
| 3192 | if (countBufferOffset & 3) { |
| 3193 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716", |
| 3194 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, |
| 3195 | countBufferOffset); |
| 3196 | } |
| 3197 | return skip; |
| 3198 | } |
| 3199 | |
| 3200 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3201 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3202 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3203 | uint32_t stride) const { |
| 3204 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3205 | } |
| 3206 | |
| 3207 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3208 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3209 | VkDeviceSize countBufferOffset, |
| 3210 | uint32_t maxDrawCount, uint32_t stride) const { |
| 3211 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3212 | } |
| 3213 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3214 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 3215 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3216 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3217 | bool skip = false; |
| 3218 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 3219 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3220 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
| 3221 | "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3222 | } |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 3223 | if (pRects[rect].rect.extent.width == 0) { |
| 3224 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682", |
| 3225 | "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect); |
| 3226 | } |
| 3227 | if (pRects[rect].rect.extent.height == 0) { |
| 3228 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683", |
| 3229 | "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect); |
| 3230 | } |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3231 | } |
| 3232 | return skip; |
| 3233 | } |
| 3234 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3235 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 3236 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3237 | VkImageFormatProperties2 *pImageFormatProperties, |
| 3238 | const char *apiName) const { |
| 3239 | bool skip = false; |
| 3240 | |
| 3241 | if (pImageFormatInfo != nullptr) { |
| 3242 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext); |
| 3243 | if (image_stencil_struct != nullptr) { |
| 3244 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 3245 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 3246 | // No flags other than the legal attachment bits may be set |
| 3247 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 3248 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3249 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 3250 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 3251 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 3252 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 3253 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3254 | } |
| 3255 | } |
| 3256 | } |
| 3257 | } |
| 3258 | |
| 3259 | return skip; |
| 3260 | } |
| 3261 | |
| 3262 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 3263 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3264 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3265 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3266 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 3267 | } |
| 3268 | |
| 3269 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 3270 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3271 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3272 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3273 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 3274 | } |
| 3275 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3276 | bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 3277 | VkImageLayout srcImageLayout, VkImage dstImage, |
| 3278 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3279 | const VkImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3280 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3281 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3282 | VkImageAspectFlags legal_aspect_flags = |
| 3283 | 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] | 3284 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3285 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3286 | } |
| 3287 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3288 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3289 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3290 | skip |= LogError( |
| 3291 | device, "VUID-VkImageSubresourceLayers-aspectMask-parameter", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3292 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3293 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3294 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3295 | skip |= LogError( |
| 3296 | device, "VUID-VkImageSubresourceLayers-aspectMask-parameter", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3297 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3298 | } |
| 3299 | } |
| 3300 | return skip; |
| 3301 | } |
| 3302 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3303 | bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 3304 | VkImageLayout srcImageLayout, VkImage dstImage, |
| 3305 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3306 | const VkImageBlit *pRegions, VkFilter filter) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3307 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3308 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3309 | VkImageAspectFlags legal_aspect_flags = |
| 3310 | 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] | 3311 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3312 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3313 | } |
| 3314 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3315 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3316 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3317 | skip |= LogError( |
| 3318 | device, kVUID_PVError_UnrecognizedValue, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3319 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator"); |
| 3320 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3321 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3322 | skip |= LogError( |
| 3323 | device, kVUID_PVError_UnrecognizedValue, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3324 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator"); |
| 3325 | } |
| 3326 | } |
| 3327 | return skip; |
| 3328 | } |
| 3329 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3330 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 3331 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 3332 | bool skip = false; |
| 3333 | |
| 3334 | if (pRegions != nullptr) { |
| 3335 | for (uint32_t i = 0; i < regionCount; i++) { |
| 3336 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3337 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
| 3338 | "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3339 | } |
| 3340 | } |
| 3341 | } |
| 3342 | return skip; |
| 3343 | } |
| 3344 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3345 | bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, |
| 3346 | VkImage dstImage, VkImageLayout dstImageLayout, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3347 | uint32_t regionCount, |
| 3348 | const VkBufferImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3349 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3350 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3351 | VkImageAspectFlags legal_aspect_flags = |
| 3352 | 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] | 3353 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3354 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3355 | } |
| 3356 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3357 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3358 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3359 | skip |= LogError(device, kVUID_PVError_UnrecognizedValue, |
| 3360 | "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an " |
| 3361 | "unrecognized enumerator"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3362 | } |
| 3363 | } |
| 3364 | return skip; |
| 3365 | } |
| 3366 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3367 | bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 3368 | VkImageLayout srcImageLayout, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3369 | uint32_t regionCount, |
| 3370 | const VkBufferImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3371 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3372 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3373 | VkImageAspectFlags legal_aspect_flags = |
| 3374 | 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] | 3375 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3376 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 3377 | } |
| 3378 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3379 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 3380 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Petr Kraus | 3e6cd03 | 2020-04-14 20:41:16 +0200 | [diff] [blame] | 3381 | skip |= LogError( |
| 3382 | device, kVUID_PVError_UnrecognizedValue, |
| 3383 | "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized " |
| 3384 | "enumerator"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3385 | } |
| 3386 | } |
| 3387 | return skip; |
| 3388 | } |
| 3389 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3390 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3391 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 3392 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3393 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3394 | |
| 3395 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3396 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 3397 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3398 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3399 | } |
| 3400 | |
| 3401 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3402 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 3403 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 3404 | "), must be greater than zero and less than or equal to 65536.", |
| 3405 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3406 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3407 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 3408 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3409 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3410 | } |
| 3411 | return skip; |
| 3412 | } |
| 3413 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3414 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3415 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3416 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3417 | |
| 3418 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3419 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 3420 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3421 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3422 | } |
| 3423 | |
| 3424 | if (size != VK_WHOLE_SIZE) { |
| 3425 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3426 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3427 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 3428 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3429 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3430 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 3431 | "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] | 3432 | } |
| 3433 | } |
| 3434 | return skip; |
| 3435 | } |
| 3436 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3437 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3438 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3439 | VkSwapchainKHR *pSwapchain) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3440 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3441 | |
| 3442 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3443 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3444 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 3445 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 3446 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3447 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
| 3448 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3449 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3450 | } |
| 3451 | |
| 3452 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 3453 | // queueFamilyIndexCount uint32_t values |
| 3454 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3455 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
| 3456 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3457 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 3458 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3459 | } |
| 3460 | } |
| 3461 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3462 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3463 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3464 | } |
| 3465 | |
| 3466 | return skip; |
| 3467 | } |
| 3468 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3469 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3470 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3471 | |
| 3472 | if (pPresentInfo && pPresentInfo->pNext) { |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3473 | const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
| 3474 | if (present_regions) { |
| 3475 | // 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] | 3476 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3477 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 3478 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3479 | skip |= LogError(device, kVUID_PVError_InvalidUsage, |
| 3480 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 3481 | "extension swapchainCount is %i. These values must be equal.", |
| 3482 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3483 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3484 | 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] | 3485 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 3486 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3487 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 3488 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 3489 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3490 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3491 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3492 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3493 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3494 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3495 | } |
| 3496 | } |
| 3497 | |
| 3498 | return skip; |
| 3499 | } |
| 3500 | |
| 3501 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3502 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 3503 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 3504 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3505 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3506 | bool skip = false; |
| 3507 | |
| 3508 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3509 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 3510 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3511 | } |
| 3512 | |
| 3513 | return skip; |
| 3514 | } |
| 3515 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 3516 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3517 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3518 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3519 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3520 | bool skip = false; |
| 3521 | |
| 3522 | if (pCreateInfo) { |
| 3523 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3524 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 3525 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3526 | } |
| 3527 | |
| 3528 | if (pCreateInfo->pPoolSizes) { |
| 3529 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 3530 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3531 | skip |= LogError( |
| 3532 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3533 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3534 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3535 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 3536 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3537 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 3538 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 3539 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 3540 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 3541 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3542 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3543 | } |
| 3544 | } |
| 3545 | } |
| 3546 | |
| 3547 | return skip; |
| 3548 | } |
| 3549 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3550 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3551 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3552 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3553 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3554 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3555 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3556 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 3557 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3558 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3559 | } |
| 3560 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3561 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3562 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3563 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 3564 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3565 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3566 | } |
| 3567 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3568 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3569 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3570 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 3571 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3572 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3573 | } |
| 3574 | |
| 3575 | return skip; |
| 3576 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3577 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3578 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3579 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3580 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3581 | |
| 3582 | if ((offset % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3583 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
| 3584 | "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3585 | } |
| 3586 | return skip; |
| 3587 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3588 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3589 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 3590 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3591 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3592 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3593 | |
| 3594 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3595 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3596 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3597 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 3598 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 3599 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3600 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3601 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3602 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 3603 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 3604 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3605 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3606 | } |
| 3607 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3608 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3609 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3610 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 3611 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 3612 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3613 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3614 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3615 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 3616 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 3617 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3618 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3619 | } |
| 3620 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3621 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3622 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3623 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 3624 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 3625 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3626 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3627 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3628 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 3629 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 3630 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3631 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3632 | } |
| 3633 | |
| 3634 | return skip; |
| 3635 | } |
| 3636 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3637 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 3638 | VkPipelineBindPoint pipelineBindPoint, |
| 3639 | VkPipelineLayout layout, uint32_t set, |
| 3640 | uint32_t descriptorWriteCount, |
| 3641 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
| 3642 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false); |
| 3643 | } |
| 3644 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3645 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 3646 | uint32_t firstExclusiveScissor, |
| 3647 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3648 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3649 | bool skip = false; |
| 3650 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3651 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3652 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3653 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3654 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 3655 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 3656 | ") is not 0.", |
| 3657 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3658 | } |
| 3659 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3660 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3661 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 3662 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 3663 | ") is not 1.", |
| 3664 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3665 | } |
| 3666 | } else { // multiViewport enabled |
| 3667 | 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] | 3668 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3669 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 3670 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 3671 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3672 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3673 | } |
| 3674 | } |
| 3675 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3676 | if (firstExclusiveScissor >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3677 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033", |
| 3678 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32 |
| 3679 | ") must be less than maxViewports (=%" PRIu32 ").", |
| 3680 | firstExclusiveScissor, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3681 | } |
| 3682 | |
| 3683 | if (pExclusiveScissors) { |
| 3684 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 3685 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 3686 | |
| 3687 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3688 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 3689 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 3690 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3691 | } |
| 3692 | |
| 3693 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3694 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 3695 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 3696 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3697 | } |
| 3698 | |
| 3699 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 3700 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3701 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 3702 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3703 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3704 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3705 | } |
| 3706 | |
| 3707 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 3708 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3709 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 3710 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3711 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3712 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3713 | } |
| 3714 | } |
| 3715 | } |
| 3716 | |
| 3717 | return skip; |
| 3718 | } |
| 3719 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3720 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 3721 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3722 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3723 | bool skip = false; |
| 3724 | if (firstViewport >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3725 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323", |
| 3726 | "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").", |
| 3727 | firstViewport, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3728 | } else { |
| 3729 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 3730 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3731 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 3732 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3733 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 3734 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3735 | } |
| 3736 | } |
| 3737 | |
| 3738 | return skip; |
| 3739 | } |
| 3740 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3741 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 3742 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3743 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3744 | bool skip = false; |
| 3745 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3746 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3747 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3748 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3749 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 3750 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 3751 | ") is not 0.", |
| 3752 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3753 | } |
| 3754 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3755 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3756 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 3757 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 3758 | ") is not 1.", |
| 3759 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3760 | } |
| 3761 | } |
| 3762 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3763 | if (firstViewport >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3764 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066", |
| 3765 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32 |
| 3766 | ") must be less than maxViewports (=%" PRIu32 ").", |
| 3767 | firstViewport, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3768 | } |
| 3769 | |
| 3770 | 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] | 3771 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3772 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 3773 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 3774 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3775 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3776 | } |
| 3777 | |
| 3778 | return skip; |
| 3779 | } |
| 3780 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3781 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 3782 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 3783 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3784 | bool skip = false; |
| 3785 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3786 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3787 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 3788 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 3789 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3790 | } |
| 3791 | |
| 3792 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3793 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3794 | } |
| 3795 | |
| 3796 | return skip; |
| 3797 | } |
| 3798 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3799 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3800 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3801 | bool skip = false; |
| 3802 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3803 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3804 | skip |= LogError( |
| 3805 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3806 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 3807 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3808 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3809 | } |
| 3810 | |
| 3811 | return skip; |
| 3812 | } |
| 3813 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3814 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3815 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3816 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3817 | bool skip = false; |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 3818 | static const int condition_multiples = 0b0011; |
| 3819 | if (offset & condition_multiples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3820 | skip |= LogError( |
| 3821 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3822 | "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] | 3823 | } |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 3824 | if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3825 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 3826 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 3827 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 3828 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 3829 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3830 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3831 | skip |= LogError( |
| 3832 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
| 3833 | "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] | 3834 | } |
| 3835 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3836 | return skip; |
| 3837 | } |
| 3838 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3839 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3840 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3841 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3842 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3843 | bool skip = false; |
| 3844 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3845 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3846 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 3847 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 3848 | "), is not a multiple of 4.", |
| 3849 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3850 | } |
| 3851 | |
| 3852 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3853 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 3854 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 3855 | "), is not a multiple of 4.", |
| 3856 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3857 | } |
| 3858 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3859 | return skip; |
| 3860 | } |
| 3861 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3862 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3863 | const VkAllocationCallbacks *pAllocator, |
| 3864 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3865 | bool skip = false; |
| 3866 | |
| 3867 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3868 | if (pCreateInfo != nullptr) { |
| 3869 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 3870 | // VkQueryPipelineStatisticFlagBits values |
| 3871 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 3872 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3873 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 3874 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 3875 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 3876 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3877 | } |
sfricke-samsung | 7d69d0d | 2020-04-25 10:27:27 -0700 | [diff] [blame] | 3878 | if (pCreateInfo->queryCount == 0) { |
| 3879 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763", |
| 3880 | "vkCreateQueryPool(): queryCount must be greater than zero."); |
| 3881 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 3882 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3883 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3884 | } |
| 3885 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3886 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 3887 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3888 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3889 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 3890 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3891 | } |
| 3892 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3893 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 3894 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 3895 | VkResult result) { |
| 3896 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3897 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3898 | } |
| 3899 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3900 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 3901 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 3902 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3903 | // 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] | 3904 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3905 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3906 | } |
| 3907 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3908 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 3909 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3910 | // 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] | 3911 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3912 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3913 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 3914 | |
| 3915 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3916 | const VkAllocationCallbacks *pAllocator, |
| 3917 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 3918 | bool skip = false; |
| 3919 | |
| 3920 | if (pAllocateInfo) { |
| 3921 | auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
| 3922 | 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] | 3923 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 3924 | "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] | 3925 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3926 | |
| 3927 | VkMemoryAllocateFlags flags = 0; |
| 3928 | auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
| 3929 | if (flags_info) { |
| 3930 | flags = flags_info->flags; |
| 3931 | } |
| 3932 | |
| 3933 | auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext); |
| 3934 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
| 3935 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3936 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 3937 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
| 3938 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3939 | } |
| 3940 | |
| 3941 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 3942 | auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
| 3943 | #endif |
| 3944 | auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 3945 | auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
| 3946 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 3947 | auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
| 3948 | #endif |
| 3949 | |
| 3950 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3951 | skip |= LogError( |
| 3952 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3953 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 3954 | } |
| 3955 | if ( |
| 3956 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 3957 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 3958 | #endif |
| 3959 | (import_memory_fd && import_memory_fd->handleType) || |
| 3960 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 3961 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 3962 | #endif |
| 3963 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3964 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 3965 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3966 | } |
| 3967 | } |
| 3968 | |
| 3969 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 3970 | VkBool32 capture_replay = false; |
| 3971 | VkBool32 buffer_device_address = false; |
| 3972 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
| 3973 | if (vulkan_12_features) { |
| 3974 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 3975 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 3976 | } else { |
| 3977 | const auto *bda_features = |
| 3978 | lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext); |
| 3979 | if (bda_features) { |
| 3980 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 3981 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 3982 | } |
| 3983 | } |
| 3984 | 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] | 3985 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
| 3986 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, " |
| 3987 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3988 | } |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 3989 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3990 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
| 3991 | "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] | 3992 | } |
| 3993 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 3994 | } |
| 3995 | return skip; |
| 3996 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 3997 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3998 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3999 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4000 | bool skip = false; |
| 4001 | |
| 4002 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 4003 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 4004 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4005 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4006 | } else { |
| 4007 | uint32_t vertex_component_size = 0; |
| 4008 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 4009 | vertex_component_size = 4; |
| 4010 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 4011 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 4012 | vertex_component_size = 2; |
| 4013 | } |
| 4014 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4015 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4016 | } |
| 4017 | } |
| 4018 | |
| 4019 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 4020 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4021 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4022 | } else { |
| 4023 | uint32_t index_element_size = 0; |
| 4024 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 4025 | index_element_size = 4; |
| 4026 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 4027 | index_element_size = 2; |
| 4028 | } |
| 4029 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4030 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4031 | } |
| 4032 | } |
| 4033 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 4034 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4035 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4036 | } |
| 4037 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4038 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4039 | } |
| 4040 | } |
| 4041 | |
| 4042 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4043 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4044 | } |
| 4045 | |
| 4046 | return skip; |
| 4047 | } |
| 4048 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4049 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 4050 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4051 | bool skip = false; |
| 4052 | |
| 4053 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4054 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4055 | } |
| 4056 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4057 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4058 | } |
| 4059 | |
| 4060 | return skip; |
| 4061 | } |
| 4062 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4063 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 4064 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4065 | bool skip = false; |
| 4066 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4067 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4068 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4069 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4070 | } |
| 4071 | return skip; |
| 4072 | } |
| 4073 | |
| 4074 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4075 | VkAccelerationStructureNV object_handle, |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4076 | const char *func_name) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4077 | bool skip = false; |
| 4078 | 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] | 4079 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 4080 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 4081 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4082 | } |
| 4083 | 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] | 4084 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 4085 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 4086 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4087 | } |
| 4088 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 4089 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4090 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 4091 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 4092 | "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] | 4093 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4094 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4095 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
| 4096 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 4097 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4098 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4099 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4100 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 4101 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 4102 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4103 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4104 | 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] | 4105 | uint64_t total_triangle_count = 0; |
| 4106 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 4107 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4108 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4109 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4110 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4111 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 4112 | continue; |
| 4113 | } |
| 4114 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 4115 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4116 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4117 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 4118 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 4119 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4120 | } |
| 4121 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4122 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 4123 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 4124 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 4125 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 4126 | if (geometry.geometryType != first_geometry_type) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4127 | skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4128 | "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match " |
| 4129 | "info.pGeometries[0].geometryType.", |
| 4130 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4131 | } |
| 4132 | } |
| 4133 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4134 | for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) { |
| 4135 | if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV || |
| 4136 | info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) { |
| 4137 | skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503", |
| 4138 | "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV" |
| 4139 | "or VK_GEOMETRY_TYPE_AABBS_NV."); |
| 4140 | } |
| 4141 | } |
| 4142 | skip |= |
| 4143 | validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV, |
| 4144 | info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4145 | return skip; |
| 4146 | } |
| 4147 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4148 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 4149 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4150 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4151 | bool skip = false; |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4152 | if (pCreateInfo) { |
| 4153 | if ((pCreateInfo->compactedSize != 0) && |
| 4154 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4155 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 4156 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 4157 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 4158 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4159 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4160 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4161 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4162 | "vkCreateAccelerationStructureNV()"); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4163 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4164 | return skip; |
| 4165 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4166 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4167 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 4168 | const VkAccelerationStructureInfoNV *pInfo, |
| 4169 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 4170 | VkBool32 update, VkAccelerationStructureNV dst, |
| 4171 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 4172 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4173 | bool skip = false; |
| 4174 | |
| 4175 | if (pInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4176 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4177 | } |
| 4178 | |
| 4179 | return skip; |
| 4180 | } |
| 4181 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4182 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR( |
| 4183 | VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 4184 | VkAccelerationStructureKHR *pAccelerationStructure) const { |
| 4185 | bool skip = false; |
| 4186 | |
| 4187 | if (pCreateInfo) { |
| 4188 | for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) { |
| 4189 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) { |
| 4190 | if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 4191 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496", |
| 4192 | "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure " |
| 4193 | "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 4194 | i); |
| 4195 | } |
| 4196 | } |
| 4197 | |
| 4198 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) { |
| 4199 | if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 4200 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497", |
| 4201 | "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure " |
| 4202 | "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 4203 | i); |
| 4204 | } |
| 4205 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4206 | if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 4207 | if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 || |
| 4208 | pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 || |
| 4209 | pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) { |
| 4210 | skip |= LogError( |
| 4211 | device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502", |
| 4212 | "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType" |
| 4213 | "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR."); |
| 4214 | } |
| 4215 | } |
| 4216 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) { |
| 4217 | if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) { |
| 4218 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492", |
| 4219 | "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR" |
| 4220 | "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to " |
| 4221 | "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.", |
| 4222 | pCreateInfo->pGeometryInfos[i].maxPrimitiveCount, |
| 4223 | phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount); |
| 4224 | } |
| 4225 | } |
| 4226 | } |
| 4227 | |
| 4228 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 && |
| 4229 | pCreateInfo->maxGeometryCount != 1) { |
| 4230 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495", |
| 4231 | "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR" |
| 4232 | "and compactedSize is 0, maxGeometryCount must be 1."); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4233 | } |
| 4234 | |
| 4235 | if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR && |
| 4236 | pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) { |
| 4237 | skip |= LogError( |
| 4238 | device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499", |
| 4239 | "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR" |
| 4240 | "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set."); |
| 4241 | } |
| 4242 | |
| 4243 | if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) { |
| 4244 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490", |
| 4245 | "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 4246 | ") with maxGeometryCount (%" PRIu32 ") nonzero.", |
| 4247 | pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount); |
| 4248 | } |
| 4249 | |
| 4250 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) { |
| 4251 | const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType; |
| 4252 | for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) { |
| 4253 | const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType; |
| 4254 | if (geometry_type != first_geometry_type) { |
| 4255 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498", |
| 4256 | "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match " |
| 4257 | "pGeometryInfos[0].geometryType.", |
| 4258 | i); |
| 4259 | } |
| 4260 | } |
| 4261 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4262 | if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && |
| 4263 | (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) { |
| 4264 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491", |
| 4265 | "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR" |
| 4266 | "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR " |
| 4267 | "maxGeometryCount %d.", |
| 4268 | pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount); |
| 4269 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4270 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4271 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4272 | if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) { |
| 4273 | if (pCreateInfo->deviceAddress != 0) { |
| 4274 | skip |= |
| 4275 | LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500", |
| 4276 | "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, " |
| 4277 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE."); |
| 4278 | } |
| 4279 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4280 | if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) { |
| 4281 | skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487", |
| 4282 | "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled."); |
| 4283 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4284 | return skip; |
| 4285 | } |
| 4286 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4287 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 4288 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4289 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4290 | bool skip = false; |
| 4291 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4292 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 4293 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4294 | } |
| 4295 | return skip; |
| 4296 | } |
| 4297 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4298 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 4299 | uint32_t createInfoCount, |
| 4300 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 4301 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4302 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4303 | bool skip = false; |
| 4304 | |
| 4305 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 4306 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 4307 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4308 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4309 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 4310 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 4311 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 4312 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4313 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4314 | |
| 4315 | const auto *pipeline_cache_contol_features = |
| 4316 | lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
| 4317 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4318 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4319 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4320 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905", |
| 4321 | "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled," |
| 4322 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4323 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4324 | } |
| 4325 | } |
| 4326 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4327 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 4328 | skip |= |
| 4329 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904", |
| 4330 | "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 4331 | } |
| 4332 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) && |
| 4333 | (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) { |
| 4334 | skip |= |
| 4335 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957", |
| 4336 | "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and" |
| 4337 | "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time."); |
| 4338 | } |
| 4339 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4340 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4341 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4342 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423", |
| 4343 | "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be " |
| 4344 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4345 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4346 | } |
| 4347 | } |
| 4348 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
| 4349 | if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
| 4350 | skip |= |
| 4351 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422", |
| 4352 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4353 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling" |
| 4354 | "commands pCreateInfos parameter."); |
| 4355 | } |
| 4356 | } else { |
| 4357 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4358 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424", |
| 4359 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4360 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4361 | } |
| 4362 | } |
| 4363 | } |
| 4364 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 4365 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456", |
| 4366 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR."); |
| 4367 | } |
| 4368 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) { |
| 4369 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458", |
| 4370 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4371 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR."); |
| 4372 | } |
| 4373 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) { |
| 4374 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459", |
| 4375 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4376 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR."); |
| 4377 | } |
| 4378 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) { |
| 4379 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460", |
| 4380 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4381 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR."); |
| 4382 | } |
| 4383 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) { |
| 4384 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461", |
| 4385 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4386 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR."); |
| 4387 | } |
| 4388 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4389 | skip |= LogError( |
| 4390 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462", |
| 4391 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4392 | } |
| 4393 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4394 | skip |= LogError( |
| 4395 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463", |
| 4396 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 4397 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4398 | } |
| 4399 | |
| 4400 | return skip; |
| 4401 | } |
| 4402 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4403 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache, |
| 4404 | uint32_t createInfoCount, |
| 4405 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, |
| 4406 | const VkAllocationCallbacks *pAllocator, |
| 4407 | VkPipeline *pPipelines) const { |
| 4408 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4409 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4410 | if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) { |
| 4411 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455", |
| 4412 | "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled."); |
| 4413 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4414 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 4415 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 4416 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
| 4417 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670", |
| 4418 | "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32 |
| 4419 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 4420 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").", |
| 4421 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
| 4422 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4423 | const auto *pipeline_cache_contol_features = |
| 4424 | lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
| 4425 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4426 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4427 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4428 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905", |
| 4429 | "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled," |
| 4430 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4431 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4432 | } |
| 4433 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4434 | if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) { |
| 4435 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4436 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472", |
| 4437 | "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled," |
| 4438 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4439 | } |
| 4440 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4441 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473", |
| 4442 | "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled," |
| 4443 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 4444 | } |
| 4445 | } |
| 4446 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4447 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 4448 | skip |= |
| 4449 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904", |
| 4450 | "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 4451 | } |
| 4452 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 4453 | if (pCreateInfos[i].pLibraryInterface == NULL) |
| 4454 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465", |
| 4455 | "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL."); |
| 4456 | } |
| 4457 | for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) { |
| 4458 | if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) || |
| 4459 | (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) { |
| 4460 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) && |
| 4461 | (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4462 | skip |= LogError( |
| 4463 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470", |
| 4464 | "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR," |
| 4465 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4466 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element " |
| 4467 | "must not be VK_SHADER_UNUSED_KHR"); |
| 4468 | } |
| 4469 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) && |
| 4470 | (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4471 | skip |= LogError( |
| 4472 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471", |
| 4473 | "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR," |
| 4474 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4475 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that " |
| 4476 | "element must not be VK_SHADER_UNUSED_KHR"); |
| 4477 | } |
| 4478 | } |
| 4479 | } |
| 4480 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4481 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4482 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4483 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423", |
| 4484 | "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be " |
| 4485 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4486 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4487 | } |
| 4488 | } |
| 4489 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
| 4490 | if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
| 4491 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422", |
| 4492 | "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4493 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling" |
| 4494 | "commands pCreateInfos parameter %d.", |
| 4495 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 4496 | } |
| 4497 | } else { |
| 4498 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4499 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424", |
| 4500 | "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4501 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4502 | } |
| 4503 | } |
| 4504 | } |
| 4505 | if (pCreateInfos[i].libraries.libraryCount == 0) { |
| 4506 | if (pCreateInfos[i].stageCount == 0) { |
| 4507 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958", |
| 4508 | "If libraries.libraryCount is zero, then stageCount must not be zero ."); |
| 4509 | } |
| 4510 | if (pCreateInfos[i].groupCount == 0) { |
| 4511 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959", |
| 4512 | "If libraries.libraryCount is zero, then groupCount must not be zero ."); |
| 4513 | } |
| 4514 | } else { |
| 4515 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
| 4516 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466", |
| 4517 | "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL."); |
| 4518 | } |
| 4519 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4520 | } |
| 4521 | |
| 4522 | return skip; |
| 4523 | } |
| 4524 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4525 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4526 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 4527 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4528 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4529 | bool skip = false; |
| 4530 | if (!device_extensions.vk_khr_swapchain) |
| 4531 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 4532 | if (!device_extensions.vk_khr_get_surface_capabilities_2) |
| 4533 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
| 4534 | if (!device_extensions.vk_khr_surface) |
| 4535 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
| 4536 | if (!device_extensions.vk_khr_get_physical_device_properties_2) |
| 4537 | skip |= |
| 4538 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 4539 | if (!device_extensions.vk_ext_full_screen_exclusive) |
| 4540 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 4541 | skip |= validate_struct_type( |
| 4542 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 4543 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 4544 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 4545 | if (pSurfaceInfo != NULL) { |
| 4546 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 4547 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 4548 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 4549 | |
| 4550 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 4551 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 4552 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 4553 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 4554 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 4555 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4556 | |
| 4557 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 4558 | } |
| 4559 | return skip; |
| 4560 | } |
| 4561 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4562 | |
| 4563 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 4564 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4565 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4566 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4567 | bool skip = false; |
| 4568 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) { |
| 4569 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 4570 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 4571 | } |
| 4572 | return skip; |
| 4573 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4574 | |
| 4575 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4576 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4577 | bool skip = false; |
| 4578 | |
| 4579 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4580 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
| 4581 | "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 4582 | } |
| 4583 | |
| 4584 | return skip; |
| 4585 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 4586 | |
| 4587 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4588 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 4589 | bool skip = false; |
| 4590 | |
| 4591 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4592 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 4593 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 4594 | } |
| 4595 | |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 4596 | 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] | 4597 | 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] | 4598 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 4599 | "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] | 4600 | } |
| 4601 | |
| 4602 | return skip; |
| 4603 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4604 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 4605 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 4606 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 4607 | const VkDeviceSize *pOffsets) const { |
| 4608 | bool skip = false; |
| 4609 | if (firstBinding > device_limits.maxVertexInputBindings) { |
| 4610 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 4611 | "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding, |
| 4612 | device_limits.maxVertexInputBindings); |
| 4613 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 4614 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
| 4615 | "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 4616 | "maxVertexInputBindings (%u)", |
| 4617 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 4618 | } |
| 4619 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 4620 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 4621 | if (pBuffers[i] == VK_NULL_HANDLE) { |
| 4622 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 4623 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 4624 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001", |
| 4625 | "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 4626 | } else { |
| 4627 | if (pOffsets[i] != 0) { |
| 4628 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002", |
| 4629 | "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 4630 | } |
| 4631 | } |
| 4632 | } |
| 4633 | } |
| 4634 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 4635 | return skip; |
| 4636 | } |
| 4637 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4638 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4639 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4640 | bool skip = false; |
| 4641 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4642 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 4643 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4644 | } |
| 4645 | return skip; |
| 4646 | } |
| 4647 | |
| 4648 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4649 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4650 | bool skip = false; |
| 4651 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4652 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 4653 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 4654 | } |
| 4655 | return skip; |
| 4656 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 4657 | |
| 4658 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 4659 | VkSemaphore semaphore, VkFence fence, |
| 4660 | uint32_t *pImageIndex) const { |
| 4661 | bool skip = false; |
| 4662 | |
| 4663 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4664 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 4665 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 4666 | } |
| 4667 | |
| 4668 | return skip; |
| 4669 | } |
| 4670 | |
| 4671 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 4672 | uint32_t *pImageIndex) const { |
| 4673 | bool skip = false; |
| 4674 | |
| 4675 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4676 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 4677 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 4678 | } |
| 4679 | |
| 4680 | return skip; |
| 4681 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 4682 | |
| 4683 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 4684 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 4685 | VkDeviceSize counterBufferOffset, |
| 4686 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 4687 | bool skip = false; |
| 4688 | |
| 4689 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4690 | skip |= LogError( |
| 4691 | counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 4692 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).", |
| 4693 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
| 4694 | } |
| 4695 | |
| 4696 | return skip; |
| 4697 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 4698 | |
| 4699 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 4700 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 4701 | const VkAllocationCallbacks *pAllocator, |
| 4702 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 4703 | const char *apiName) const { |
| 4704 | bool skip = false; |
| 4705 | |
| 4706 | // Check samplerYcbcrConversion feature is set |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 4707 | const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 4708 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4709 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
| 4710 | "samplerYcbcrConversion must be enabled to call %s.", apiName); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 4711 | } |
| 4712 | return skip; |
| 4713 | } |
| 4714 | |
| 4715 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 4716 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 4717 | const VkAllocationCallbacks *pAllocator, |
| 4718 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 4719 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 4720 | "vkCreateSamplerYcbcrConversion"); |
| 4721 | } |
| 4722 | |
| 4723 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 4724 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 4725 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 4726 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 4727 | "vkCreateSamplerYcbcrConversionKHR"); |
| 4728 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 4729 | |
| 4730 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR( |
| 4731 | VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const { |
| 4732 | bool skip = false; |
| 4733 | VkExternalSemaphoreHandleTypeFlags supported_handle_types = |
| 4734 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 4735 | |
| 4736 | if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4737 | skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", |
| 4738 | "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).", |
| 4739 | report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(), |
| 4740 | string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType), |
| 4741 | string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 4742 | } |
| 4743 | return skip; |
| 4744 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4745 | |
| 4746 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR( |
| 4747 | VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 4748 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4749 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4750 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 4751 | skip |= |
| 4752 | LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447", |
| 4753 | "vkCopyAccelerationStructureToMemoryKHR: the " |
| 4754 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled."); |
| 4755 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4756 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 4757 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 4758 | "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 4759 | } |
| 4760 | return skip; |
| 4761 | } |
| 4762 | |
| 4763 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR( |
| 4764 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 4765 | bool skip = false; |
| 4766 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 4767 | skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update |
| 4768 | LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 4769 | "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 4770 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4771 | const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext); |
| 4772 | if (pNext_struct) { |
| 4773 | skip |= LogError( |
| 4774 | commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560", |
| 4775 | "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the" |
| 4776 | "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure."); |
| 4777 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4778 | return skip; |
| 4779 | } |
| 4780 | |
| 4781 | bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 4782 | const char *api_name) const { |
| 4783 | bool skip = false; |
| 4784 | if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR || |
| 4785 | pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) { |
| 4786 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410", |
| 4787 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR" |
| 4788 | "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.", |
| 4789 | api_name); |
| 4790 | } |
| 4791 | return skip; |
| 4792 | } |
| 4793 | |
| 4794 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR( |
| 4795 | VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 4796 | bool skip = false; |
| 4797 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4798 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4799 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 4800 | skip |= LogError( |
| 4801 | device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441", |
| 4802 | "vkCopyAccelerationStructureKHR(): the " |
| 4803 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled ."); |
| 4804 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4805 | return skip; |
| 4806 | } |
| 4807 | |
| 4808 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR( |
| 4809 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 4810 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4811 | const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext); |
| 4812 | if (pNext_struct) { |
| 4813 | skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557", |
| 4814 | "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in " |
| 4815 | "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure."); |
| 4816 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4817 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()"); |
| 4818 | return skip; |
| 4819 | } |
| 4820 | |
| 4821 | bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 4822 | const char *api_name, bool is_cmd) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4823 | bool skip = false; |
| 4824 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4825 | skip |= LogError(device, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 4826 | is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413" |
| 4827 | : "VUID-vkCopyMemoryToAccelerationStructureInfoKHR-mode-03413", |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4828 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name); |
| 4829 | } |
| 4830 | return skip; |
| 4831 | } |
| 4832 | |
| 4833 | bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR( |
| 4834 | VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 4835 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4836 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true); |
| 4837 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4838 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 4839 | skip |= |
| 4840 | LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444", |
| 4841 | "vkCopyMemoryToAccelerationStructureKHR() :the " |
| 4842 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled."); |
| 4843 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4844 | return skip; |
| 4845 | } |
| 4846 | bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR( |
| 4847 | VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 4848 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4849 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false); |
| 4850 | return skip; |
| 4851 | } |
| 4852 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR( |
| 4853 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 4854 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 4855 | bool skip = false; |
| 4856 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 4857 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 4858 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 4859 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 4860 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 4861 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 4862 | } |
| 4863 | return skip; |
| 4864 | } |
| 4865 | bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR( |
| 4866 | VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 4867 | VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const { |
| 4868 | bool skip = false; |
| 4869 | if (dataSize < accelerationStructureCount * stride) { |
| 4870 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452", |
| 4871 | "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to " |
| 4872 | "accelerationStructureCount (%d) *stride(%zu).", |
| 4873 | dataSize, accelerationStructureCount, stride); |
| 4874 | } |
| 4875 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 4876 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 4877 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 4878 | "vkWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 4879 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 4880 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 4881 | } |
| 4882 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) { |
| 4883 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 4884 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448", |
| 4885 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 4886 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR," |
| 4887 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 4888 | stride); |
| 4889 | } |
| 4890 | } |
| 4891 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) { |
| 4892 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 4893 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450", |
| 4894 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 4895 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR," |
| 4896 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 4897 | stride); |
| 4898 | } |
| 4899 | } |
| 4900 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4901 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 4902 | skip |= |
| 4903 | LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454", |
| 4904 | "vkWriteAccelerationStructuresPropertiesKHR: the " |
| 4905 | "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands" |
| 4906 | "feature must be enabled "); |
| 4907 | } |
| 4908 | return skip; |
| 4909 | } |
| 4910 | bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR( |
| 4911 | VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const { |
| 4912 | bool skip = false; |
| 4913 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4914 | if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) { |
| 4915 | skip |= LogError(device, |
| 4916 | "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485", |
| 4917 | "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: " |
| 4918 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay" |
| 4919 | "must be enabled to call this function."); |
| 4920 | } |
| 4921 | return skip; |
| 4922 | } |
| 4923 | |
| 4924 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
| 4925 | const VkStridedBufferRegionKHR *pRaygenShaderBindingTable, |
| 4926 | const VkStridedBufferRegionKHR *pMissShaderBindingTable, |
| 4927 | const VkStridedBufferRegionKHR *pHitShaderBindingTable, |
| 4928 | const VkStridedBufferRegionKHR *pCallableShaderBindingTable, |
| 4929 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 4930 | bool skip = false; |
| 4931 | if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 4932 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038", |
| 4933 | "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable" |
| 4934 | "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 4935 | } |
| 4936 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 4937 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040", |
| 4938 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple" |
| 4939 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 4940 | } |
| 4941 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 4942 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041", |
| 4943 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be" |
| 4944 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 4945 | } |
| 4946 | // hitShader |
| 4947 | if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 4948 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032", |
| 4949 | "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple" |
| 4950 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 4951 | } |
| 4952 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 4953 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034", |
| 4954 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple" |
| 4955 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 4956 | } |
| 4957 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 4958 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035", |
| 4959 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be" |
| 4960 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 4961 | } |
| 4962 | |
| 4963 | // missShader |
| 4964 | if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 4965 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026", |
| 4966 | "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple" |
| 4967 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 4968 | } |
| 4969 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 4970 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028", |
| 4971 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple" |
| 4972 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 4973 | } |
| 4974 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 4975 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029", |
| 4976 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be" |
| 4977 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 4978 | } |
| 4979 | |
| 4980 | // raygenShader |
| 4981 | if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 4982 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021", |
| 4983 | "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple" |
| 4984 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 4985 | } |
| 4986 | return skip; |
| 4987 | } |
| 4988 | |
| 4989 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, |
| 4990 | const VkStridedBufferRegionKHR *pRaygenShaderBindingTable, |
| 4991 | const VkStridedBufferRegionKHR *pMissShaderBindingTable, |
| 4992 | const VkStridedBufferRegionKHR *pHitShaderBindingTable, |
| 4993 | const VkStridedBufferRegionKHR *pCallableShaderBindingTable, |
| 4994 | VkBuffer buffer, VkDeviceSize offset) const { |
| 4995 | bool skip = false; |
| 4996 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 4997 | if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) { |
| 4998 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518", |
| 4999 | "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays " |
| 5000 | "feature must be enabled."); |
| 5001 | } |
| 5002 | if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5003 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038", |
| 5004 | "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable" |
| 5005 | "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5006 | } |
| 5007 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5008 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040", |
| 5009 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple" |
| 5010 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5011 | } |
| 5012 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5013 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041", |
| 5014 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be" |
| 5015 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5016 | } |
| 5017 | // hitShader |
| 5018 | if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5019 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032", |
| 5020 | "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple" |
| 5021 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5022 | } |
| 5023 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5024 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034", |
| 5025 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple" |
| 5026 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5027 | } |
| 5028 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5029 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035", |
| 5030 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be" |
| 5031 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5032 | } |
| 5033 | |
| 5034 | // missShader |
| 5035 | if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5036 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026", |
| 5037 | "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple" |
| 5038 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5039 | } |
| 5040 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) { |
| 5041 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028", |
| 5042 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple" |
| 5043 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize."); |
| 5044 | } |
| 5045 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5046 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029", |
| 5047 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be" |
| 5048 | "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride."); |
| 5049 | } |
| 5050 | |
| 5051 | // raygenShader |
| 5052 | if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5053 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021", |
| 5054 | "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple" |
| 5055 | "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment."); |
| 5056 | } |
| 5057 | return skip; |
| 5058 | } |
| 5059 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV( |
| 5060 | VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, |
| 5061 | VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 5062 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, |
| 5063 | VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 5064 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 5065 | bool skip = false; |
| 5066 | if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5067 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462", |
| 5068 | "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of " |
| 5069 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5070 | } |
| 5071 | if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5072 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465", |
| 5073 | "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of " |
| 5074 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5075 | } |
| 5076 | if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5077 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468", |
| 5078 | "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to " |
| 5079 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. "); |
| 5080 | } |
| 5081 | |
| 5082 | // hitShader |
| 5083 | if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5084 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460", |
| 5085 | "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of " |
| 5086 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5087 | } |
| 5088 | if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5089 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464", |
| 5090 | "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of " |
| 5091 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5092 | } |
| 5093 | if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5094 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467", |
| 5095 | "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to " |
| 5096 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5097 | } |
| 5098 | |
| 5099 | // missShader |
| 5100 | if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5101 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458", |
| 5102 | "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of " |
| 5103 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5104 | } |
| 5105 | if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5106 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463", |
| 5107 | "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of " |
| 5108 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5109 | } |
| 5110 | if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5111 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466", |
| 5112 | "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to " |
| 5113 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5114 | } |
| 5115 | |
| 5116 | // raygenShader |
| 5117 | if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5118 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456", |
| 5119 | "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of " |
| 5120 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment ."); |
| 5121 | } |
| 5122 | return skip; |
| 5123 | } |
| 5124 | |
| 5125 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR( |
| 5126 | VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer, |
| 5127 | VkDeviceSize indirectOffset, uint32_t indirectStride) const { |
| 5128 | bool skip = false; |
| 5129 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5130 | if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) { |
| 5131 | skip |= LogError( |
| 5132 | device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535", |
| 5133 | "vkCmdBuildAccelerationStructureIndirectKHR: The " |
| 5134 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled."); |
| 5135 | } |
| 5136 | const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext); |
| 5137 | if (pNext_struct) { |
| 5138 | skip |= |
| 5139 | LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536", |
| 5140 | "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in " |
| 5141 | "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures."); |
| 5142 | } |
| 5143 | return false; |
| 5144 | } |
| 5145 | |
| 5146 | bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR( |
| 5147 | VkDevice device, const VkAccelerationStructureVersionKHR *version) const { |
| 5148 | bool skip = false; |
| 5149 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5150 | if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) { |
| 5151 | skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565", |
| 5152 | "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled."); |
| 5153 | } |
| 5154 | return skip; |
| 5155 | } |
| 5156 | |
| 5157 | bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR( |
| 5158 | VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 5159 | const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const { |
| 5160 | bool skip = false; |
| 5161 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext); |
| 5162 | if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) { |
| 5163 | skip |= LogError( |
| 5164 | device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439", |
| 5165 | "vkBuildAccelerationStructureKHR: The " |
| 5166 | "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled ."); |
| 5167 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5168 | return skip; |
| 5169 | } |