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 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 88 | template <typename ExtensionState> |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 89 | ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) { |
| 90 | if (!extension_name) return kNotEnabled; // null strings specify nothing |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 91 | auto info = ExtensionState::get_info(extension_name); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 92 | ExtEnabled state = |
| 93 | 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] | 94 | return state; |
| 95 | } |
| 96 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 97 | bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 98 | const VkAllocationCallbacks *pAllocator, |
| 99 | VkInstance *pInstance) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 100 | bool skip = false; |
| 101 | // Note: From the spec-- |
| 102 | // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing |
| 103 | // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0) |
| 104 | uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion) |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 105 | ? pCreateInfo->pApplicationInfo->apiVersion |
| 106 | : VK_API_VERSION_1_0; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 107 | skip |= validate_api_version(local_api_version, api_version); |
| 108 | skip |= validate_instance_extensions(pCreateInfo); |
| 109 | return skip; |
| 110 | } |
| 111 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 112 | void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 113 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, |
| 114 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 115 | auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 116 | // Copy extension data into local object |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 117 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 118 | this->instance_extensions = instance_data->instance_extensions; |
| 119 | } |
| 120 | |
| 121 | void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 122 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 123 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 124 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 125 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); |
| 126 | StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 127 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 128 | // Parmeter validation also uses extension data |
| 129 | stateless_validation->device_extensions = this->device_extensions; |
| 130 | |
| 131 | VkPhysicalDeviceProperties device_properties = {}; |
| 132 | // Need to get instance and do a getlayerdata call... |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 133 | DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 134 | memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 135 | |
| 136 | if (device_extensions.vk_nv_shading_rate_image) { |
| 137 | // Get the needed shading rate image limits |
| 138 | auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); |
| 139 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 140 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 141 | phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; |
| 142 | } |
| 143 | |
| 144 | if (device_extensions.vk_nv_mesh_shader) { |
| 145 | // Get the needed mesh shader limits |
| 146 | auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>(); |
| 147 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 148 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 149 | phys_dev_ext_props.mesh_shader_props = mesh_shader_props; |
| 150 | } |
| 151 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 152 | if (device_extensions.vk_nv_ray_tracing) { |
| 153 | // Get the needed ray tracing limits |
| 154 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>(); |
| 155 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props); |
| 156 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 157 | phys_dev_ext_props.ray_tracing_props = ray_tracing_props; |
| 158 | } |
| 159 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 160 | if (device_extensions.vk_ext_transform_feedback) { |
| 161 | // Get the needed transform feedback limits |
| 162 | auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
| 163 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props); |
| 164 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 165 | phys_dev_ext_props.transform_feedback_props = transform_feedback_props; |
| 166 | } |
| 167 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 168 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 169 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 170 | // Save app-enabled features in this device's validation object |
| 171 | // 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] | 172 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
| 173 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 174 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 175 | if (features2) { |
| 176 | tmp_features2_state.features = features2->features; |
| 177 | } else if (pCreateInfo->pEnabledFeatures) { |
| 178 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 179 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 180 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 181 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 182 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 183 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 184 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 187 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 188 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 189 | bool skip = false; |
| 190 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 191 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 192 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 193 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 194 | } |
| 195 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 196 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 197 | skip |= |
| 198 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 199 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 200 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 201 | pCreateInfo->ppEnabledExtensionNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 202 | } |
| 203 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 204 | { |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 205 | bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME)); |
| 206 | bool negative_viewport = |
| 207 | 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] | 208 | if (maint1 && negative_viewport) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 209 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 210 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
| 211 | "VK_AMD_negative_viewport_height."); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 212 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 213 | } |
| 214 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 215 | { |
| 216 | bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 217 | bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 218 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 219 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 220 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 221 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 225 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 226 | // Check for get_physical_device_properties2 struct |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 227 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext); |
| 228 | if (features2) { |
| 229 | // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 230 | skip |= LogError(device, kVUID_PVError_InvalidUsage, |
| 231 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when " |
| 232 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 236 | auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
| 237 | if (features2) { |
| 238 | if (!instance_extensions.vk_khr_get_physical_device_properties_2) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 239 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 240 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, " |
| 241 | "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] | 242 | } |
| 243 | } |
| 244 | |
| 245 | auto vertex_attribute_divisor_features = |
| 246 | lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
| 247 | if (vertex_attribute_divisor_features) { |
| 248 | bool extension_found = false; |
| 249 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) { |
| 250 | if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME, |
| 251 | VK_MAX_EXTENSION_NAME_SIZE)) { |
| 252 | extension_found = true; |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | if (!extension_found) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 257 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 258 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 259 | "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] | 260 | } |
| 261 | } |
| 262 | |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 263 | const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
| 264 | if (vulkan_11_features) { |
| 265 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 266 | while (current) { |
| 267 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 268 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 269 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 270 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 271 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 272 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 273 | skip |= LogError( |
| 274 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 275 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 276 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 277 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 278 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 279 | break; |
| 280 | } |
| 281 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
| 286 | if (vulkan_12_features) { |
| 287 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 288 | while (current) { |
| 289 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 290 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 291 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 292 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 293 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 294 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 295 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 296 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 297 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 298 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 299 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 300 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 301 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 302 | skip |= LogError( |
| 303 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 304 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 305 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 306 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 307 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 308 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 309 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 310 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 311 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 312 | break; |
| 313 | } |
| 314 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 315 | } |
| 316 | } |
| 317 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 318 | // Validate pCreateInfo->pQueueCreateInfos |
| 319 | if (pCreateInfo->pQueueCreateInfos) { |
| 320 | std::unordered_set<uint32_t> set; |
| 321 | |
| 322 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
| 323 | const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex; |
| 324 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 325 | skip |= |
| 326 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 327 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 328 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 329 | "index value.", |
| 330 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 331 | } else if (set.count(requested_queue_family)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 332 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372", |
| 333 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 |
| 334 | ") is not unique within pCreateInfo->pQueueCreateInfos array.", |
| 335 | i, requested_queue_family); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 336 | } else { |
| 337 | set.insert(requested_queue_family); |
| 338 | } |
| 339 | |
| 340 | if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) { |
| 341 | for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) { |
| 342 | const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j]; |
| 343 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 344 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 345 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 346 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 347 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | return skip; |
| 355 | } |
| 356 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 357 | 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] | 358 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 359 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 360 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 361 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 362 | } |
| 363 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 364 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 365 | } |
| 366 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 367 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 368 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 369 | bool skip = false; |
| 370 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 371 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 372 | skip |= |
| 373 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 374 | |
| 375 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 376 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 377 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 378 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 379 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 380 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 381 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 385 | // queueFamilyIndexCount uint32_t values |
| 386 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 387 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 388 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 389 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 390 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 391 | } |
| 392 | } |
| 393 | |
| 394 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 395 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 396 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 397 | ((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] | 398 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 399 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 400 | "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] | 401 | } |
| 402 | } |
| 403 | |
| 404 | return skip; |
| 405 | } |
| 406 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 407 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 408 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 409 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 410 | |
| 411 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 412 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 413 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 414 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 415 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 416 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942", |
| 417 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 418 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 422 | // queueFamilyIndexCount uint32_t values |
| 423 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 424 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941", |
| 425 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 426 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 427 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 431 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 432 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 433 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 434 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 435 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 436 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 437 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 438 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 439 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 440 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 441 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 442 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 443 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 444 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 445 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 446 | skip |= LogError( |
| 447 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 448 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 449 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 450 | } |
| 451 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 452 | // 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] | 453 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 454 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 455 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 456 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 457 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 461 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 462 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 463 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 464 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 465 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 466 | ") are not equal.", |
| 467 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 471 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 472 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 473 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 474 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 475 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 479 | skip |= LogError( |
| 480 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 481 | "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] | 482 | } |
| 483 | } |
| 484 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 485 | // 3D image may have only 1 layer |
| 486 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 487 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 488 | "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] | 489 | } |
| 490 | |
| 491 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 492 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
| 493 | ((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] | 494 | (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 495 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 496 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 500 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 501 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 502 | // At least one of the legal attachment bits must be set |
| 503 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 504 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 505 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 506 | } |
| 507 | // No flags other than the legal attachment bits may be set |
| 508 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 509 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 510 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 511 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 512 | } |
| 513 | } |
| 514 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 515 | // 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] | 516 | 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] | 517 | // Max mip levels is different for corner-sampled images vs normal images. |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 518 | uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim))) |
| 519 | : (uint32_t)(floor(log2(maxDim)) + 1); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 520 | if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 521 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 522 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 523 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 524 | "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] | 525 | } |
| 526 | |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 527 | 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] | 528 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 529 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 530 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 531 | } |
| 532 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 533 | 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] | 534 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 535 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 536 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 537 | } |
| 538 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 539 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 540 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
| 541 | if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 542 | ((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] | 543 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 544 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 545 | "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] | 546 | } |
| 547 | |
| 548 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
| 549 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
| 550 | // Linear tiling is unsupported |
| 551 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 552 | skip |= LogError(device, kVUID_PVError_InvalidUsage, |
| 553 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 554 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | // Sparse 1D image isn't valid |
| 558 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 559 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 560 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 564 | 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] | 565 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 566 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 567 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 571 | 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] | 572 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 573 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 574 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | // Multi-sample 2D image when device doesn't support it |
| 578 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 579 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 580 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 581 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 582 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 583 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 584 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 585 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 586 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 587 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 588 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 589 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 590 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 591 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 592 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 593 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 594 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 595 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 596 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 597 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 598 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 599 | } |
| 600 | } |
| 601 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 602 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 603 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 604 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 605 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 606 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 607 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 608 | } |
| 609 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 610 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 611 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 612 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 613 | } |
| 614 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 615 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 616 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 617 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 618 | } |
| 619 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 620 | |
| 621 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 622 | 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] | 623 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 624 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 625 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 626 | } |
| 627 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 628 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 629 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 630 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 631 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must " |
| 632 | "not be a depth/stencil format."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 633 | } |
| 634 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 635 | 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] | 636 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 637 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 638 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 639 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 640 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 641 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 642 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 643 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 644 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 645 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 646 | } |
| 647 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 648 | |
| 649 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext); |
| 650 | if (image_stencil_struct != nullptr) { |
| 651 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 652 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 653 | // No flags other than the legal attachment bits may be set |
| 654 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 655 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 656 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 657 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 658 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 659 | "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] | 660 | } |
| 661 | } |
| 662 | |
| 663 | if (FormatIsDepthOrStencil(pCreateInfo->format)) { |
| 664 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 665 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
| 666 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 667 | LogError(device, "VUID-VkImageCreateInfo-Format-02536", |
| 668 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 669 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device " |
| 670 | "maxFramebufferWidth"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
| 674 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 675 | LogError(device, "VUID-VkImageCreateInfo-format-02537", |
| 676 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 677 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device " |
| 678 | "maxFramebufferHeight"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 679 | } |
| 680 | } |
| 681 | |
| 682 | if (!physical_device_features.shaderStorageImageMultisample && |
| 683 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 684 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 685 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 686 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 687 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 688 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 689 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 693 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 694 | skip |= LogError( |
| 695 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 696 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 697 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 698 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 699 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 700 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 701 | skip |= LogError( |
| 702 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 703 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 704 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 705 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 706 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 707 | } |
| 708 | |
| 709 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 710 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 711 | skip |= LogError( |
| 712 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 713 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 714 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 715 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 716 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 717 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 718 | skip |= LogError( |
| 719 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 720 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 721 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 722 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 723 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 724 | } |
| 725 | } |
| 726 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 727 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 728 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 729 | return skip; |
| 730 | } |
| 731 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 732 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 733 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 734 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 735 | |
| 736 | // Note: for numerical correctness |
| 737 | // - float comparisons should expect NaN (comparison always false). |
| 738 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 739 | |
| 740 | 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] | 741 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 742 | if (v1_f <= 0.0f) return true; |
| 743 | |
| 744 | float intpart; |
| 745 | const float fract = modff(v1_f, &intpart); |
| 746 | |
| 747 | assert(std::numeric_limits<float>::radix == 2); |
| 748 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 749 | if (intpart >= u32_max_plus1) return false; |
| 750 | |
| 751 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
| 752 | if (v1_u32 < v2_u32) |
| 753 | return true; |
| 754 | else if (v1_u32 == v2_u32 && fract == 0.0f) |
| 755 | return true; |
| 756 | else |
| 757 | return false; |
| 758 | }; |
| 759 | |
| 760 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 761 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 762 | return (v1_f <= v2_f); |
| 763 | }; |
| 764 | |
| 765 | // width |
| 766 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 767 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 768 | |
| 769 | if (!(viewport.width > 0.0f)) { |
| 770 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 771 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 772 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 773 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 774 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 775 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 776 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 777 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 778 | } 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] | 779 | skip |= LogWarning(object, kVUID_PVError_NONE, |
| 780 | "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 |
| 781 | "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.", |
| 782 | fn_name, parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | // height |
| 786 | bool height_healthy = true; |
Mark Lobodzinski | a09ab94 | 2020-02-20 11:01:59 -0700 | [diff] [blame] | 787 | 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] | 788 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 789 | |
| 790 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 791 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 792 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 793 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 794 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 795 | height_healthy = false; |
| 796 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 797 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 798 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 799 | ").", |
| 800 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 801 | } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) { |
| 802 | height_healthy = false; |
| 803 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 804 | skip |= LogWarning( |
| 805 | object, kVUID_PVError_NONE, |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 806 | "%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] | 807 | "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.", |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 808 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | // x |
| 812 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 813 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 814 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 815 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 816 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 817 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 818 | } |
| 819 | |
| 820 | // x + width |
| 821 | if (x_healthy && width_healthy) { |
| 822 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 823 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 824 | skip |= LogError( |
| 825 | object, "VUID-VkViewport-x-01232", |
| 826 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 827 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 828 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 829 | } |
| 830 | } |
| 831 | |
| 832 | // y |
| 833 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 834 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 835 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 836 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 837 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 838 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 839 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 840 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 841 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 842 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 843 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | // y + height |
| 847 | if (y_healthy && height_healthy) { |
| 848 | const float boundary = viewport.y + viewport.height; |
| 849 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 850 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 851 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 852 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 853 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 854 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 855 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 856 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 857 | LogError(object, "VUID-VkViewport-y-01777", |
| 858 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 859 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 860 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 861 | } |
| 862 | } |
| 863 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 864 | if (!device_extensions.vk_ext_depth_range_unrestricted) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 865 | // minDepth |
| 866 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 867 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 868 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 869 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 870 | "[0.0, 1.0] range.", |
| 871 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | // maxDepth |
| 875 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 876 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 877 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 878 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 879 | "[0.0, 1.0] range.", |
| 880 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 881 | } |
| 882 | } |
| 883 | |
| 884 | return skip; |
| 885 | } |
| 886 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 887 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 888 | VkShadingRatePaletteEntryNV shadingRate; |
| 889 | uint32_t width; |
| 890 | uint32_t height; |
| 891 | }; |
| 892 | |
| 893 | // All palette entries with more than one pixel per fragment |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 894 | static SampleOrderInfo sampleOrderInfos[] = { |
| 895 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 896 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 897 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 898 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 899 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 900 | {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] | 901 | }; |
| 902 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 903 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 904 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 905 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 906 | SampleOrderInfo *sampleOrderInfo; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 907 | uint32_t infoIdx = 0; |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 908 | for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 909 | if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) { |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 910 | sampleOrderInfo = &sampleOrderInfos[infoIdx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 911 | break; |
| 912 | } |
| 913 | } |
| 914 | |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 915 | if (sampleOrderInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 916 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 917 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 918 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 919 | return skip; |
| 920 | } |
| 921 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 922 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 923 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 924 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 925 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 926 | ") must " |
| 927 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 928 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 929 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 930 | } |
| 931 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 932 | if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 933 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 934 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 935 | ") must " |
| 936 | "be equal to the product of sampleCount (=%" PRIu32 |
| 937 | "), the fragment width for shadingRate " |
| 938 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
| 939 | order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 940 | } |
| 941 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 942 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 943 | skip |= LogError( |
| 944 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 945 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 946 | ") must " |
| 947 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 948 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 949 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 950 | |
| 951 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 952 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 953 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 954 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 955 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 956 | uint64_t sampleLocationsMask = 0; |
| 957 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
| 958 | const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i]; |
| 959 | if (sampleLoc->pixelX >= sampleOrderInfo->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 960 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 961 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 962 | } |
| 963 | if (sampleLoc->pixelY >= sampleOrderInfo->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 964 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 965 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 966 | } |
| 967 | if (sampleLoc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 968 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 969 | "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] | 970 | } |
| 971 | uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY); |
| 972 | sampleLocationsMask |= 1ULL << idx; |
| 973 | } |
| 974 | |
| 975 | uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 976 | if (sampleLocationsMask != expectedMask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 977 | skip |= LogError( |
| 978 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 979 | "The array pSampleLocations must contain exactly one entry for " |
| 980 | "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] | 981 | } |
| 982 | |
| 983 | return skip; |
| 984 | } |
| 985 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 986 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 987 | uint32_t createInfoCount, |
| 988 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 989 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 990 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 991 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 992 | |
| 993 | if (pCreateInfos != nullptr) { |
| 994 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 995 | bool has_dynamic_viewport = false; |
| 996 | bool has_dynamic_scissor = false; |
| 997 | bool has_dynamic_line_width = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 998 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 999 | bool has_dynamic_discard_rectangle_ext = false; |
| 1000 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1001 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1002 | bool has_dynamic_shading_rate_palette_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1003 | bool has_dynamic_line_stipple = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1004 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1005 | const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState; |
| 1006 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1007 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
| 1008 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true; |
| 1009 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true; |
| 1010 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) has_dynamic_line_width = true; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1011 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) has_dynamic_viewport_w_scaling_nv = true; |
| 1012 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) has_dynamic_discard_rectangle_ext = true; |
| 1013 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) has_dynamic_sample_locations_ext = true; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1014 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) has_dynamic_exclusive_scissor_nv = true; |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1015 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) |
| 1016 | has_dynamic_shading_rate_palette_nv = true; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1017 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) has_dynamic_line_stipple = true; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1018 | } |
| 1019 | } |
| 1020 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1021 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 1022 | if ((feedback_struct != nullptr) && |
| 1023 | (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1024 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668", |
| 1025 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 1026 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 1027 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
| 1028 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1029 | } |
| 1030 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1031 | // 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] | 1032 | |
| 1033 | // Collect active stages |
| 1034 | uint32_t active_shaders = 0; |
| 1035 | for (uint32_t stages = 0; stages < pCreateInfos[i].stageCount; stages++) { |
Spencer Fricke | d84808f | 2020-01-20 06:08:01 -0800 | [diff] [blame] | 1036 | active_shaders |= pCreateInfos[i].pStages[stages].stage; |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
| 1040 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) { |
| 1041 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 1042 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 1043 | pCreateInfos[i].pTessellationState, |
| 1044 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1045 | "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
| 1046 | |
| 1047 | const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = { |
| 1048 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 1049 | |
| 1050 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
| 1051 | "VkPipelineTessellationDomainOriginStateCreateInfo", |
| 1052 | pCreateInfos[i].pTessellationState->pNext, |
| 1053 | ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo), |
| 1054 | allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1055 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 1056 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1057 | |
| 1058 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
| 1059 | pCreateInfos[i].pTessellationState->flags, |
| 1060 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 1061 | } |
| 1062 | |
| 1063 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) { |
| 1064 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 1065 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
| 1066 | pCreateInfos[i].pInputAssemblyState, |
| 1067 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1068 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 1069 | |
| 1070 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
| 1071 | pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1072 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1073 | |
| 1074 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
| 1075 | pCreateInfos[i].pInputAssemblyState->flags, |
| 1076 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 1077 | |
| 1078 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 1079 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
| 1080 | pCreateInfos[i].pInputAssemblyState->topology, |
| 1081 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 1082 | |
| 1083 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
| 1084 | pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable); |
| 1085 | } |
| 1086 | |
| 1087 | 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] | 1088 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1089 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1090 | if (pCreateInfos[i].pVertexInputState->flags != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1091 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 1092 | "vkCreateGraphicsPipelines: pararameter " |
| 1093 | "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.", |
| 1094 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1095 | } |
| 1096 | |
| 1097 | const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = { |
| 1098 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
| 1099 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 1100 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", |
| 1101 | pCreateInfos[i].pVertexInputState->pNext, 1, |
| 1102 | allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1103 | "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
| 1104 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1105 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 1106 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 1107 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1108 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 1109 | skip |= |
| 1110 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 1111 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
| 1112 | pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount, |
| 1113 | &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
| 1114 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 1115 | |
| 1116 | skip |= validate_array( |
| 1117 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 1118 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 1119 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 1120 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 1121 | |
| 1122 | if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) { |
| 1123 | for (uint32_t vertexBindingDescriptionIndex = 0; |
| 1124 | vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount; |
| 1125 | ++vertexBindingDescriptionIndex) { |
| 1126 | skip |= validate_ranged_enum( |
| 1127 | "vkCreateGraphicsPipelines", |
| 1128 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 1129 | AllVkVertexInputRateEnums, |
| 1130 | pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate, |
| 1131 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) { |
| 1136 | for (uint32_t vertexAttributeDescriptionIndex = 0; |
| 1137 | vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount; |
| 1138 | ++vertexAttributeDescriptionIndex) { |
| 1139 | skip |= validate_ranged_enum( |
| 1140 | "vkCreateGraphicsPipelines", |
| 1141 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 1142 | AllVkFormatEnums, |
| 1143 | pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format, |
| 1144 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
| 1145 | } |
| 1146 | } |
| 1147 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1148 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1149 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 1150 | "vkCreateGraphicsPipelines: pararameter " |
| 1151 | "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is " |
| 1152 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1153 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1154 | } |
| 1155 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1156 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1157 | skip |= |
| 1158 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 1159 | "vkCreateGraphicsPipelines: pararameter " |
| 1160 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is " |
| 1161 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1162 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1163 | } |
| 1164 | |
| 1165 | std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1166 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 1167 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1168 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 1169 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1170 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 1171 | "vkCreateGraphicsPipelines: parameter " |
| 1172 | "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding " |
| 1173 | "(%" PRIu32 ") is not distinct.", |
| 1174 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1175 | } |
| 1176 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 1177 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1178 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1179 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 1180 | "vkCreateGraphicsPipelines: parameter " |
| 1181 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
| 1182 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1183 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1184 | } |
| 1185 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1186 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1187 | skip |= |
| 1188 | LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 1189 | "vkCreateGraphicsPipelines: parameter " |
| 1190 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
| 1191 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).", |
| 1192 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1193 | } |
| 1194 | } |
| 1195 | |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1196 | std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1197 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 1198 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1199 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 1200 | if (location_it != attribute_locations.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1201 | skip |= LogError( |
| 1202 | device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1203 | "vkCreateGraphicsPipelines: parameter " |
| 1204 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.", |
| 1205 | i, d, vertex_attrib_desc.location); |
| 1206 | } |
| 1207 | attribute_locations.insert(vertex_attrib_desc.location); |
| 1208 | |
| 1209 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 1210 | if (binding_it == vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1211 | skip |= LogError( |
| 1212 | device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1213 | "vkCreateGraphicsPipelines: parameter " |
| 1214 | " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist " |
| 1215 | "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.", |
| 1216 | i, d, vertex_attrib_desc.binding, i); |
| 1217 | } |
| 1218 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1219 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1220 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 1221 | "vkCreateGraphicsPipelines: parameter " |
| 1222 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
| 1223 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1224 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1225 | } |
| 1226 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1227 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1228 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 1229 | "vkCreateGraphicsPipelines: parameter " |
| 1230 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
| 1231 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1232 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1233 | } |
| 1234 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1235 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1236 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 1237 | "vkCreateGraphicsPipelines: parameter " |
| 1238 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 1239 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).", |
| 1240 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1241 | } |
| 1242 | } |
| 1243 | } |
| 1244 | |
| 1245 | if (pCreateInfos[i].pStages != nullptr) { |
| 1246 | bool has_control = false; |
| 1247 | bool has_eval = false; |
| 1248 | |
| 1249 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 1250 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 1251 | has_control = true; |
| 1252 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 1253 | has_eval = true; |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 1258 | if (has_control && has_eval) { |
| 1259 | if (pCreateInfos[i].pTessellationState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1260 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
| 1261 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 1262 | "shader stage and a tessellation evaluation shader stage, " |
| 1263 | "pCreateInfos[%d].pTessellationState must not be NULL.", |
| 1264 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1265 | } else { |
Locke | e04009e | 2019-03-08 12:22:35 -0700 | [diff] [blame] | 1266 | const VkStructureType allowed_type = |
| 1267 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1268 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1269 | "vkCreateGraphicsPipelines", |
Locke | e04009e | 2019-03-08 12:22:35 -0700 | [diff] [blame] | 1270 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
| 1271 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1272 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 1273 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1274 | |
| 1275 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1276 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1277 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1278 | pCreateInfos[i].pTessellationState->flags, |
| 1279 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1280 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1281 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1282 | pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1283 | skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 1284 | "vkCreateGraphicsPipelines: invalid parameter " |
| 1285 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
| 1286 | "should be >0 and <=%u.", |
| 1287 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
| 1288 | device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1289 | } |
| 1290 | } |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 1295 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 1296 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 1297 | if (pCreateInfos[i].pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1298 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 1299 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 1300 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 1301 | "].pViewportState (=NULL) is not a valid pointer.", |
| 1302 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1303 | } else { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1304 | const auto &viewport_state = *pCreateInfos[i].pViewportState; |
| 1305 | |
| 1306 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1307 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 1308 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1309 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 1310 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1311 | } |
| 1312 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1313 | const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = { |
| 1314 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1315 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 1316 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1317 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 1318 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1319 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1320 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1321 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1322 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1323 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1324 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
| 1325 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1326 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo), |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1327 | allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
| 1328 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1329 | |
| 1330 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1331 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1332 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1333 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1334 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1335 | auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>( |
| 1336 | pCreateInfos[i].pViewportState->pNext); |
| 1337 | auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>( |
| 1338 | pCreateInfos[i].pViewportState->pNext); |
| 1339 | auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>( |
| 1340 | pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 1341 | const auto vp_swizzle_struct = |
| 1342 | lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1343 | const auto vp_w_scaling_struct = |
| 1344 | lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1345 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1346 | if (!physical_device_features.multiViewport) { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1347 | if (viewport_state.viewportCount != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1348 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 1349 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1350 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 1351 | ") is not 1.", |
| 1352 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1353 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1354 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1355 | if (viewport_state.scissorCount != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1356 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 1357 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1358 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 1359 | ") is not 1.", |
| 1360 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1361 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1362 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1363 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 1364 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1365 | skip |= LogError( |
| 1366 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 1367 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1368 | "disabled, but pCreateInfos[%" PRIu32 |
| 1369 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 1370 | ") is not 1.", |
| 1371 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1372 | } |
| 1373 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1374 | if (shading_rate_image_struct && |
| 1375 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1376 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 1377 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 1378 | "disabled, but pCreateInfos[%" PRIu32 |
| 1379 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 1380 | ") is neither 0 nor 1.", |
| 1381 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1382 | } |
| 1383 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1384 | } else { // multiViewport enabled |
| 1385 | if (viewport_state.viewportCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1386 | skip |= LogError( |
| 1387 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1388 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1389 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1390 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 1391 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1392 | "].pViewportState->viewportCount (=%" PRIu32 |
| 1393 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1394 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1395 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1396 | |
| 1397 | if (viewport_state.scissorCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1398 | skip |= LogError( |
| 1399 | device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1400 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1401 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1402 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 1403 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1404 | "].pViewportState->scissorCount (=%" PRIu32 |
| 1405 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1406 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1407 | } |
| 1408 | } |
| 1409 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1410 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1411 | skip |= |
| 1412 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 1413 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 1414 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1415 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1416 | } |
| 1417 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1418 | 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] | 1419 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 1420 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1421 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 1422 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 1423 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1424 | } |
| 1425 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1426 | if (viewport_state.scissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1427 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220", |
| 1428 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1429 | "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32 |
| 1430 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 1431 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1432 | } |
| 1433 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1434 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1435 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1436 | skip |= |
| 1437 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 1438 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 1439 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 1440 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 1441 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1442 | } |
| 1443 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1444 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1445 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1446 | skip |= LogError( |
| 1447 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1448 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 1449 | "] " |
| 1450 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 1451 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 1452 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1453 | } |
| 1454 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1455 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1456 | skip |= LogError( |
| 1457 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1458 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 1459 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1460 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 1461 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1462 | } |
| 1463 | |
| 1464 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1465 | skip |= LogError( |
| 1466 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1467 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 1468 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1469 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 1470 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 1471 | } |
| 1472 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1473 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1474 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 1475 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 1476 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1477 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030", |
| 1478 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 1479 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 1480 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 1481 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1482 | } |
| 1483 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1484 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1485 | shading_rate_image_struct->viewportCount > 0 && |
| 1486 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1487 | skip |= LogError( |
| 1488 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1489 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1490 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 1491 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1492 | i, i); |
| 1493 | } |
| 1494 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 1495 | if (vp_swizzle_struct) { |
| 1496 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1497 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 1498 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 1499 | " does " |
| 1500 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 1501 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 1502 | } |
| 1503 | } |
| 1504 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1505 | // validate the VkViewports |
| 1506 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 1507 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 1508 | 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] | 1509 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 1510 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 1511 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 1512 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1513 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1514 | } |
| 1515 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1516 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1517 | 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] | 1518 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1519 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1520 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 1521 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 1522 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1523 | } |
| 1524 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1525 | if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1526 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1527 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1528 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 1529 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 1530 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1531 | } |
| 1532 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1533 | if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1534 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1535 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1536 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 1537 | "VK_EXT_sample_locations extension is not enabled.", |
| 1538 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1539 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1540 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1541 | if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1542 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 1543 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1544 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 1545 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 1546 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1547 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1548 | |
| 1549 | if (coarse_sample_order_struct && |
| 1550 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 1551 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1552 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 1553 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1554 | "] " |
| 1555 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 1556 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 1557 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1558 | } |
| 1559 | |
| 1560 | if (coarse_sample_order_struct) { |
| 1561 | 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] | 1562 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1563 | } |
| 1564 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1565 | |
| 1566 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 1567 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1568 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 1569 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1570 | "] " |
| 1571 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 1572 | ") " |
| 1573 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 1574 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1575 | } |
| 1576 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1577 | skip |= LogError( |
| 1578 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 1579 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 1580 | "] " |
| 1581 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 1582 | i); |
| 1583 | } |
| 1584 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1588 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
| 1589 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 1590 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.", |
| 1591 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1592 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 1593 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
| 1594 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 1595 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 1596 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1597 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 1598 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1599 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1600 | "vkCreateGraphicsPipelines", |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 1601 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1602 | valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1603 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 1604 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1605 | |
| 1606 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1607 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1608 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1609 | pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1610 | |
| 1611 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1612 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1613 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 1614 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 1615 | |
| 1616 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1617 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1618 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 1619 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 1620 | pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1621 | true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1622 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1623 | skip |= validate_flags( |
| 1624 | "vkCreateGraphicsPipelines", |
| 1625 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 1626 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 1627 | kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1628 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1629 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1630 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1631 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 1632 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 1633 | |
| 1634 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1635 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1636 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 1637 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 1638 | |
| 1639 | 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] | 1640 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 1641 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 1642 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 1643 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1644 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 1645 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1646 | if (!physical_device_features.sampleRateShading) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1647 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 1648 | "vkCreateGraphicsPipelines(): parameter " |
| 1649 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.", |
| 1650 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 1651 | } |
| 1652 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 1653 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
| 1654 | if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1655 | skip |= LogError( |
| 1656 | device, |
| 1657 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1658 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1659 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 1660 | } |
| 1661 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1662 | |
| 1663 | const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>( |
| 1664 | pCreateInfos[i].pRasterizationState->pNext); |
| 1665 | |
| 1666 | if (line_state) { |
| 1667 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 1668 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
| 1669 | if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) { |
| 1670 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1671 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 1672 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 1673 | "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
| 1674 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1675 | } |
| 1676 | if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) { |
| 1677 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1678 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 1679 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 1680 | "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
| 1681 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1682 | } |
| 1683 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) { |
| 1684 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1685 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 1686 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 1687 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
| 1688 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1689 | } |
| 1690 | } |
| 1691 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 1692 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 1693 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1694 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
| 1695 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the " |
| 1696 | "range [1,256].", |
| 1697 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1698 | } |
| 1699 | } |
| 1700 | const auto *line_features = |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 1701 | lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1702 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 1703 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1704 | skip |= |
| 1705 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
| 1706 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 1707 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 1708 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1709 | } |
| 1710 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 1711 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1712 | skip |= |
| 1713 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
| 1714 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 1715 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 1716 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1717 | } |
| 1718 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 1719 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1720 | skip |= |
| 1721 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
| 1722 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 1723 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 1724 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1725 | } |
| 1726 | if (line_state->stippledLineEnable) { |
| 1727 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 1728 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1729 | skip |= |
| 1730 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
| 1731 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 1732 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 1733 | "stippledRectangularLines feature.", |
| 1734 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1735 | } |
| 1736 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 1737 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1738 | skip |= |
| 1739 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
| 1740 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 1741 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 1742 | "stippledBresenhamLines feature.", |
| 1743 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1744 | } |
| 1745 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 1746 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1747 | skip |= |
| 1748 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
| 1749 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 1750 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 1751 | "stippledSmoothLines feature.", |
| 1752 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1753 | } |
| 1754 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
| 1755 | (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1756 | skip |= |
| 1757 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
| 1758 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 1759 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 1760 | "stippledRectangularLines and strictLines features.", |
| 1761 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1762 | } |
| 1763 | } |
| 1764 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1765 | } |
| 1766 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 1767 | bool uses_color_attachment = false; |
| 1768 | bool uses_depthstencil_attachment = false; |
| 1769 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 1770 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1771 | const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass); |
| 1772 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 1773 | const auto &subpasses_uses = subpasses_uses_it->second; |
| 1774 | if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) |
| 1775 | uses_color_attachment = true; |
| 1776 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) |
| 1777 | uses_depthstencil_attachment = true; |
| 1778 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 1779 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 1780 | } |
| 1781 | |
| 1782 | if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1783 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1784 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1785 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1786 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1787 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1788 | |
| 1789 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1790 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1791 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1792 | pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1793 | |
| 1794 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1795 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1796 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 1797 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 1798 | |
| 1799 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1800 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1801 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 1802 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 1803 | |
| 1804 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1805 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1806 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 1807 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1808 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1809 | |
| 1810 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1811 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1812 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 1813 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 1814 | |
| 1815 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1816 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1817 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 1818 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 1819 | |
| 1820 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1821 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1822 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 1823 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1824 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1825 | |
| 1826 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1827 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1828 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 1829 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1830 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1831 | |
| 1832 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1833 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1834 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 1835 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1836 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1837 | |
| 1838 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1839 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1840 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 1841 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1842 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1843 | |
| 1844 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1845 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1846 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
| 1847 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1848 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1849 | |
| 1850 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1851 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1852 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
| 1853 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1854 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1855 | |
| 1856 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1857 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1858 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 1859 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1860 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1861 | |
| 1862 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1863 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1864 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 1865 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1866 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1867 | |
| 1868 | 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] | 1869 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 1870 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 1871 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 1872 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1873 | } |
| 1874 | } |
| 1875 | |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 1876 | const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = { |
| 1877 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT}; |
| 1878 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 1879 | if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1880 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 1881 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 1882 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 1883 | pCreateInfos[i].pColorBlendState, |
| 1884 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1885 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
| 1886 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1887 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1888 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 1889 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
| 1890 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext, |
| 1891 | ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo), |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1892 | allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1893 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 1894 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1895 | |
| 1896 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1897 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1898 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1899 | pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1900 | |
| 1901 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1902 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1903 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 1904 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 1905 | |
| 1906 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1907 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1908 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 1909 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 1910 | pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1911 | true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1912 | |
| 1913 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
| 1914 | for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 1915 | ++attachmentIndex) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1916 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1917 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
| 1918 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1919 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable); |
| 1920 | |
| 1921 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1922 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1923 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
| 1924 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1925 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1926 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1927 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1928 | |
| 1929 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1930 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1931 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
| 1932 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1933 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1934 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1935 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1936 | |
| 1937 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1938 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1939 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
| 1940 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1941 | "VkBlendOp", AllVkBlendOpEnums, |
| 1942 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1943 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1944 | |
| 1945 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1946 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1947 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
| 1948 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1949 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1950 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1951 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1952 | |
| 1953 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1954 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1955 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
| 1956 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1957 | "VkBlendFactor", AllVkBlendFactorEnums, |
| 1958 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1959 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1960 | |
| 1961 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1962 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1963 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
| 1964 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1965 | "VkBlendOp", AllVkBlendOpEnums, |
| 1966 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1967 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1968 | |
| 1969 | skip |= |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1970 | validate_flags("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1971 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
| 1972 | ParameterName::IndexVector{i, attachmentIndex}), |
| 1973 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
| 1974 | pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 1975 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1976 | } |
| 1977 | } |
| 1978 | |
| 1979 | 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] | 1980 | skip |= LogError(device, kVUID_PVError_InvalidStructSType, |
| 1981 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 1982 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 1983 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1984 | } |
| 1985 | |
| 1986 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 1987 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 1988 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1989 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1990 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 1991 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, |
| 1992 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1993 | } |
| 1994 | } |
| 1995 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1996 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 1997 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 1998 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 1999 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2000 | skip |= |
| 2001 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
| 2002 | "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be " |
| 2003 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 2004 | "and pCreateInfos->basePipelineIndex is not -1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2005 | } |
| 2006 | } |
| 2007 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2008 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 2009 | if (pCreateInfos[i].basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2010 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
| 2011 | "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if " |
| 2012 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
| 2013 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2014 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2015 | } else { |
| 2016 | if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2017 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
| 2018 | "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid" |
| 2019 | "index into the pCreateInfos array, of size %d.", |
| 2020 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2021 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2022 | } |
| 2023 | } |
| 2024 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2025 | if (pCreateInfos[i].pRasterizationState) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2026 | if (!device_extensions.vk_nv_fill_rectangle) { |
| 2027 | if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
| 2028 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2029 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 2030 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 2031 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 2032 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2033 | } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2034 | (physical_device_features.fillModeNonSolid == false)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2035 | skip |= LogError(device, kVUID_PVError_DeviceFeature, |
| 2036 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 2037 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
| 2038 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2039 | } |
| 2040 | } else { |
| 2041 | if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2042 | (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
| 2043 | (physical_device_features.fillModeNonSolid == false)) { |
| 2044 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2045 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 2046 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 2047 | "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
| 2048 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2049 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2050 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2051 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2052 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2053 | (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2054 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 2055 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 2056 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 2057 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 2058 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
| 2059 | i, i, pCreateInfos[i].pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2060 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2061 | } |
| 2062 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2063 | for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2064 | skip |= validate_string("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2065 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 2066 | "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[j].pName); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2067 | } |
| 2068 | } |
| 2069 | } |
| 2070 | |
| 2071 | return skip; |
| 2072 | } |
| 2073 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2074 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 2075 | uint32_t createInfoCount, |
| 2076 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 2077 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2078 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2079 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2080 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2081 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2082 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 2083 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2084 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 2085 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2086 | skip |= |
| 2087 | LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669", |
| 2088 | "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32 |
| 2089 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".", |
| 2090 | i, feedback_struct->pipelineStageCreationFeedbackCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2091 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2092 | |
| 2093 | // Make sure compute stage is selected |
| 2094 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2095 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
| 2096 | "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
| 2097 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2098 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2099 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2100 | return skip; |
| 2101 | } |
| 2102 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2103 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2104 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2105 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2106 | |
| 2107 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2108 | const auto &features = physical_device_features; |
| 2109 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2110 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2111 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 2112 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2113 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 2114 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 2115 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 2116 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2117 | } |
| 2118 | |
| 2119 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 2120 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2121 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 2122 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 2123 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2124 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2125 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2126 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2127 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 2128 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2129 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 2130 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2131 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2132 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2133 | } |
| 2134 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2135 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 2136 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2137 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 2138 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2139 | } |
| 2140 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2141 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 2142 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2143 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 2144 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2145 | } |
| 2146 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2147 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2148 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2149 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2150 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 2151 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2152 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 2153 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 2154 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 2155 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2156 | } |
| 2157 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2158 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 2159 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2160 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2161 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2162 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2163 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 2164 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2165 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2166 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2167 | } |
| 2168 | |
| 2169 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 2170 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2171 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 2172 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2173 | } |
| 2174 | |
| 2175 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 2176 | // valid VkBorderColor value |
| 2177 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2178 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2179 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2180 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 2181 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2182 | } |
| 2183 | |
| 2184 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the |
| 2185 | // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2186 | if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2187 | ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2188 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2189 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2190 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2191 | LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079", |
| 2192 | "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE " |
| 2193 | "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] | 2194 | } |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2195 | |
| 2196 | // Checks for the IMG cubic filtering extension |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2197 | if (device_extensions.vk_img_filter_cubic) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2198 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 2199 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2200 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 2201 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 2202 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2203 | } |
| 2204 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2205 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2206 | // Check for valid Lod range |
| 2207 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2208 | skip |= |
| 2209 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 2210 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2211 | } |
| 2212 | |
| 2213 | // Check mipLodBias to device limit |
| 2214 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2215 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 2216 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 2217 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2218 | } |
| 2219 | |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2220 | const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
| 2221 | if (sampler_conversion != nullptr) { |
| 2222 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2223 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2224 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2225 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2226 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2227 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2228 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 2229 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 2230 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 2231 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 2232 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 2233 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 2234 | } |
| 2235 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2236 | } |
| 2237 | |
| 2238 | return skip; |
| 2239 | } |
| 2240 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2241 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 2242 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 2243 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2244 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2245 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2246 | |
| 2247 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2248 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 2249 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 2250 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
| 2251 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount |
| 2252 | // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount |
| 2253 | // valid VkSampler handles |
| 2254 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 2255 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 2256 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 2257 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 2258 | ++descriptor_index) { |
| 2259 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2260 | skip |= LogError(device, kVUID_PVError_RequiredParameter, |
| 2261 | "vkCreateDescriptorSetLayout: required parameter " |
| 2262 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE", |
| 2263 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2264 | } |
| 2265 | } |
| 2266 | } |
| 2267 | |
| 2268 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 2269 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 2270 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2271 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
| 2272 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 2273 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits " |
| 2274 | "values.", |
| 2275 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2276 | } |
| 2277 | } |
| 2278 | } |
| 2279 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2280 | return skip; |
| 2281 | } |
| 2282 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2283 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 2284 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2285 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2286 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2287 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 2288 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2289 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 2290 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2291 | } |
| 2292 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2293 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 2294 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 2295 | const bool validateDstSet) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2296 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2297 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2298 | if (pDescriptorWrites != NULL) { |
| 2299 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 2300 | // descriptorCount must be greater than 0 |
| 2301 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 2302 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2303 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 2304 | "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2305 | } |
| 2306 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2307 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
| 2308 | if (validateDstSet) { |
| 2309 | // dstSet must be a valid VkDescriptorSet handle |
| 2310 | skip |= validate_required_handle(vkCallingFunction, |
| 2311 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 2312 | pDescriptorWrites[i].dstSet); |
| 2313 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2314 | |
| 2315 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 2316 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 2317 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 2318 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 2319 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 2320 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 2321 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, |
| 2322 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures |
| 2323 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2324 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322", |
| 2325 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 2326 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 2327 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 2328 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.", |
| 2329 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2330 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 2331 | // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, |
| 2332 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout |
| 2333 | // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively |
| 2334 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 2335 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2336 | skip |= validate_required_handle(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2337 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView", |
| 2338 | ParameterName::IndexVector{i, descriptor_index}), |
| 2339 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageView); |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2340 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2341 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 2342 | ParameterName::IndexVector{i, descriptor_index}), |
| 2343 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2344 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2345 | } |
| 2346 | } |
| 2347 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 2348 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 2349 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 2350 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 2351 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 2352 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 2353 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
| 2354 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2355 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
| 2356 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 2357 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 2358 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
| 2359 | "pDescriptorWrites[%d].pBufferInfo must not be NULL.", |
| 2360 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2361 | } else { |
| 2362 | for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2363 | skip |= validate_required_handle(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2364 | ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer", |
| 2365 | ParameterName::IndexVector{i, descriptorIndex}), |
| 2366 | pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer); |
| 2367 | } |
| 2368 | } |
| 2369 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 2370 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
| 2371 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, |
| 2372 | // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles |
| 2373 | if (pDescriptorWrites[i].pTexelBufferView == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2374 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323", |
| 2375 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 2376 | "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, " |
| 2377 | "pDescriptorWrites[%d].pTexelBufferView must not be NULL.", |
| 2378 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2379 | } else { |
| 2380 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 2381 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2382 | skip |= validate_required_handle(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2383 | ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]", |
| 2384 | ParameterName::IndexVector{i, descriptor_index}), |
| 2385 | pDescriptorWrites[i].pTexelBufferView[descriptor_index]); |
| 2386 | } |
| 2387 | } |
| 2388 | } |
| 2389 | |
| 2390 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 2391 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2392 | VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2393 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 2394 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 2395 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2396 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2397 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
| 2398 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 2399 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 2400 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2401 | } |
| 2402 | } |
| 2403 | } |
| 2404 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 2405 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2406 | VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2407 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 2408 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
| 2409 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2410 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2411 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
| 2412 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 2413 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
| 2414 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2415 | } |
| 2416 | } |
| 2417 | } |
| 2418 | } |
| 2419 | } |
| 2420 | } |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2421 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2422 | return skip; |
| 2423 | } |
| 2424 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 2425 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 2426 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 2427 | uint32_t descriptorCopyCount, |
| 2428 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
| 2429 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites); |
| 2430 | } |
| 2431 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2432 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2433 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2434 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2435 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 2436 | } |
| 2437 | |
| 2438 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2439 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2440 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2441 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 2442 | } |
| 2443 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2444 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 2445 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2446 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2447 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2448 | |
| 2449 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2450 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 2451 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2452 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 2453 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2454 | return skip; |
| 2455 | } |
| 2456 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2457 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2458 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2459 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2460 | |
| 2461 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 2462 | const char *cmd_name = "vkBeginCommandBuffer"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2463 | const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo; |
| 2464 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2465 | // Implicit VUs |
| 2466 | // validate only sType here; pointer has to be validated in core_validation |
| 2467 | const bool kNotRequired = false; |
| 2468 | const char *kNoVUID = nullptr; |
| 2469 | skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", |
| 2470 | pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID, |
| 2471 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2472 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2473 | if (pInfo) { |
| 2474 | const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = { |
| 2475 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT}; |
| 2476 | skip |= validate_struct_pnext( |
| 2477 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext, |
| 2478 | ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2479 | GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", |
| 2480 | "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2481 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2482 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2483 | |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2484 | // Explicit VUs |
| 2485 | if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2486 | skip |= LogError( |
| 2487 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2488 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 2489 | cmd_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2490 | } |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2491 | |
| 2492 | if (physical_device_features.inheritedQueries) { |
| 2493 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2494 | AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2495 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2496 | } else { // !inheritedQueries |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2497 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags, |
Petr Kraus | 43aed2c | 2019-08-18 13:59:16 +0200 | [diff] [blame] | 2498 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2499 | } |
| 2500 | |
| 2501 | if (physical_device_features.pipelineStatisticsQuery) { |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2502 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2503 | AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags, |
Petr Kraus | 43aed2c | 2019-08-18 13:59:16 +0200 | [diff] [blame] | 2504 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 2505 | } else { // !pipelineStatisticsQuery |
| 2506 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics, |
| 2507 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2508 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 2509 | |
| 2510 | const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext); |
| 2511 | if (conditional_rendering) { |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 2512 | const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 2513 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 2514 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2515 | skip |= LogError( |
| 2516 | commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 2517 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 2518 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 2519 | } |
| 2520 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2521 | } |
| 2522 | |
| 2523 | return skip; |
| 2524 | } |
| 2525 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2526 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2527 | uint32_t viewportCount, const VkViewport *pViewports) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2528 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2529 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2530 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 2531 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2532 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 2533 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 2534 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 2535 | } |
| 2536 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2537 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 2538 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 2539 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 2540 | } |
| 2541 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 2542 | 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] | 2543 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2544 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 2545 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 2546 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2547 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2548 | } |
| 2549 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2550 | |
| 2551 | if (pViewports) { |
| 2552 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 2553 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 2554 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2555 | skip |= manual_PreCallValidateViewport( |
| 2556 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2557 | } |
| 2558 | } |
| 2559 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2560 | return skip; |
| 2561 | } |
| 2562 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2563 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2564 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2565 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2566 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2567 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2568 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2569 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 2570 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 2571 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2572 | } |
| 2573 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2574 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 2575 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 2576 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2577 | } |
| 2578 | } else { // multiViewport enabled |
| 2579 | 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] | 2580 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2581 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 2582 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 2583 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2584 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2585 | } |
| 2586 | } |
| 2587 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2588 | if (pScissors) { |
| 2589 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 2590 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2591 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2592 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2593 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 2594 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 2595 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2596 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2597 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2598 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2599 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 2600 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 2601 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2602 | } |
| 2603 | |
| 2604 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 2605 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2606 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 2607 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 2608 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 2609 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2610 | } |
| 2611 | |
| 2612 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 2613 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2614 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 2615 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 2616 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 2617 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2618 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2619 | } |
| 2620 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 2621 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2622 | return skip; |
| 2623 | } |
| 2624 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2625 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2626 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2627 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2628 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2629 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 2630 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2631 | } |
| 2632 | |
| 2633 | return skip; |
| 2634 | } |
| 2635 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2636 | bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2637 | uint32_t firstVertex, uint32_t firstInstance) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2638 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2639 | if (vertexCount == 0) { |
| 2640 | // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make |
| 2641 | // this an error or leave as is. |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2642 | 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] | 2643 | } |
| 2644 | |
| 2645 | if (instanceCount == 0) { |
| 2646 | // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make |
| 2647 | // this an error or leave as is. |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2648 | 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] | 2649 | } |
| 2650 | return skip; |
| 2651 | } |
| 2652 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2653 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2654 | uint32_t count, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2655 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2656 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2657 | if (!physical_device_features.multiDrawIndirect && ((count > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2658 | skip |= LogError(device, kVUID_PVError_DeviceFeature, |
| 2659 | "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] | 2660 | } |
| 2661 | return skip; |
| 2662 | } |
| 2663 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2664 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2665 | VkDeviceSize offset, uint32_t count, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2666 | bool skip = false; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2667 | if (!physical_device_features.multiDrawIndirect && ((count > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2668 | skip |= |
| 2669 | LogError(device, kVUID_PVError_DeviceFeature, |
| 2670 | "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] | 2671 | } |
| 2672 | return skip; |
| 2673 | } |
| 2674 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 2675 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 2676 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2677 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 2678 | bool skip = false; |
| 2679 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 2680 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2681 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
| 2682 | "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 2683 | } |
| 2684 | } |
| 2685 | return skip; |
| 2686 | } |
| 2687 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 2688 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 2689 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 2690 | VkImageFormatProperties2 *pImageFormatProperties, |
| 2691 | const char *apiName) const { |
| 2692 | bool skip = false; |
| 2693 | |
| 2694 | if (pImageFormatInfo != nullptr) { |
| 2695 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext); |
| 2696 | if (image_stencil_struct != nullptr) { |
| 2697 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 2698 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 2699 | // No flags other than the legal attachment bits may be set |
| 2700 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 2701 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2702 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 2703 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 2704 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 2705 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 2706 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 2707 | } |
| 2708 | } |
| 2709 | } |
| 2710 | } |
| 2711 | |
| 2712 | return skip; |
| 2713 | } |
| 2714 | |
| 2715 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 2716 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 2717 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 2718 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 2719 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 2720 | } |
| 2721 | |
| 2722 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 2723 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 2724 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 2725 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 2726 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 2727 | } |
| 2728 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2729 | bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 2730 | VkImageLayout srcImageLayout, VkImage dstImage, |
| 2731 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2732 | const VkImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2733 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2734 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2735 | VkImageAspectFlags legal_aspect_flags = |
| 2736 | 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] | 2737 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2738 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2739 | } |
| 2740 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2741 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2742 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2743 | skip |= LogError( |
| 2744 | device, "VUID-VkImageSubresourceLayers-aspectMask-parameter", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2745 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2746 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2747 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2748 | skip |= LogError( |
| 2749 | device, "VUID-VkImageSubresourceLayers-aspectMask-parameter", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2750 | "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2751 | } |
| 2752 | } |
| 2753 | return skip; |
| 2754 | } |
| 2755 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2756 | bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 2757 | VkImageLayout srcImageLayout, VkImage dstImage, |
| 2758 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2759 | const VkImageBlit *pRegions, VkFilter filter) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2760 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2761 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2762 | VkImageAspectFlags legal_aspect_flags = |
| 2763 | 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] | 2764 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2765 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2766 | } |
| 2767 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2768 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2769 | if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2770 | skip |= LogError( |
| 2771 | device, kVUID_PVError_UnrecognizedValue, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2772 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator"); |
| 2773 | } |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2774 | if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2775 | skip |= LogError( |
| 2776 | device, kVUID_PVError_UnrecognizedValue, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2777 | "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator"); |
| 2778 | } |
| 2779 | } |
| 2780 | return skip; |
| 2781 | } |
| 2782 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 2783 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 2784 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 2785 | bool skip = false; |
| 2786 | |
| 2787 | if (pRegions != nullptr) { |
| 2788 | for (uint32_t i = 0; i < regionCount; i++) { |
| 2789 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2790 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
| 2791 | "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 2792 | } |
| 2793 | } |
| 2794 | } |
| 2795 | return skip; |
| 2796 | } |
| 2797 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2798 | bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, |
| 2799 | VkImage dstImage, VkImageLayout dstImageLayout, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2800 | uint32_t regionCount, |
| 2801 | const VkBufferImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2802 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2803 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2804 | VkImageAspectFlags legal_aspect_flags = |
| 2805 | 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] | 2806 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2807 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2808 | } |
| 2809 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2810 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2811 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2812 | skip |= LogError(device, kVUID_PVError_UnrecognizedValue, |
| 2813 | "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an " |
| 2814 | "unrecognized enumerator"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2815 | } |
| 2816 | } |
| 2817 | return skip; |
| 2818 | } |
| 2819 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2820 | bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 2821 | VkImageLayout srcImageLayout, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2822 | uint32_t regionCount, |
| 2823 | const VkBufferImageCopy *pRegions) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2824 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2825 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2826 | VkImageAspectFlags legal_aspect_flags = |
| 2827 | 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] | 2828 | if (device_extensions.vk_khr_sampler_ycbcr_conversion) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2829 | legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 2830 | } |
| 2831 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2832 | if (pRegions != nullptr) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2833 | if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2834 | LogError(device, kVUID_PVError_UnrecognizedValue, |
| 2835 | "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized " |
| 2836 | "enumerator"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2837 | } |
| 2838 | } |
| 2839 | return skip; |
| 2840 | } |
| 2841 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2842 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2843 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 2844 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2845 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2846 | |
| 2847 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2848 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 2849 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 2850 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2851 | } |
| 2852 | |
| 2853 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2854 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 2855 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 2856 | "), must be greater than zero and less than or equal to 65536.", |
| 2857 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2858 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2859 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 2860 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 2861 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2862 | } |
| 2863 | return skip; |
| 2864 | } |
| 2865 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2866 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2867 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2868 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2869 | |
| 2870 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2871 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 2872 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 2873 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2874 | } |
| 2875 | |
| 2876 | if (size != VK_WHOLE_SIZE) { |
| 2877 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2878 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2879 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 2880 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2881 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2882 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 2883 | "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] | 2884 | } |
| 2885 | } |
| 2886 | return skip; |
| 2887 | } |
| 2888 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2889 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2890 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2891 | VkSwapchainKHR *pSwapchain) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2892 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2893 | |
| 2894 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2895 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 2896 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 2897 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 2898 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2899 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
| 2900 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 2901 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2902 | } |
| 2903 | |
| 2904 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 2905 | // queueFamilyIndexCount uint32_t values |
| 2906 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2907 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
| 2908 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 2909 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 2910 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2911 | } |
| 2912 | } |
| 2913 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2914 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2915 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2916 | } |
| 2917 | |
| 2918 | return skip; |
| 2919 | } |
| 2920 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2921 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2922 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2923 | |
| 2924 | if (pPresentInfo && pPresentInfo->pNext) { |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 2925 | const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
| 2926 | if (present_regions) { |
| 2927 | // 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] | 2928 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 2929 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 2930 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2931 | skip |= LogError(device, kVUID_PVError_InvalidUsage, |
| 2932 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 2933 | "extension swapchainCount is %i. These values must be equal.", |
| 2934 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 2935 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2936 | 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] | 2937 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 2938 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2939 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 2940 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 2941 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 2942 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2943 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2944 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2945 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2946 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2947 | } |
| 2948 | } |
| 2949 | |
| 2950 | return skip; |
| 2951 | } |
| 2952 | |
| 2953 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2954 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 2955 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 2956 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2957 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2958 | bool skip = false; |
| 2959 | |
| 2960 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2961 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 2962 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2963 | } |
| 2964 | |
| 2965 | return skip; |
| 2966 | } |
| 2967 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 2968 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2969 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2970 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2971 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2972 | bool skip = false; |
| 2973 | |
| 2974 | if (pCreateInfo) { |
| 2975 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2976 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 2977 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2978 | } |
| 2979 | |
| 2980 | if (pCreateInfo->pPoolSizes) { |
| 2981 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 2982 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2983 | skip |= LogError( |
| 2984 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2985 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2986 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 2987 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 2988 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2989 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 2990 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 2991 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 2992 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 2993 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 2994 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 2995 | } |
| 2996 | } |
| 2997 | } |
| 2998 | |
| 2999 | return skip; |
| 3000 | } |
| 3001 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3002 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3003 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3004 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3005 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3006 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3007 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3008 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 3009 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3010 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3011 | } |
| 3012 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3013 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3014 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3015 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 3016 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3017 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3018 | } |
| 3019 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3020 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3021 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3022 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 3023 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3024 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3025 | } |
| 3026 | |
| 3027 | return skip; |
| 3028 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3029 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3030 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3031 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3032 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3033 | |
| 3034 | if ((offset % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3035 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
| 3036 | "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3037 | } |
| 3038 | return skip; |
| 3039 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3040 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3041 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 3042 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3043 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3044 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3045 | |
| 3046 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3047 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3048 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3049 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 3050 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 3051 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3052 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3053 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3054 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 3055 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 3056 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3057 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3058 | } |
| 3059 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3060 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3061 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3062 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 3063 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 3064 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3065 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3066 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3067 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 3068 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 3069 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3070 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3071 | } |
| 3072 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3073 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3074 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3075 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 3076 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 3077 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3078 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3079 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3080 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 3081 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 3082 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3083 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3084 | } |
| 3085 | |
| 3086 | return skip; |
| 3087 | } |
| 3088 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3089 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 3090 | VkPipelineBindPoint pipelineBindPoint, |
| 3091 | VkPipelineLayout layout, uint32_t set, |
| 3092 | uint32_t descriptorWriteCount, |
| 3093 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
| 3094 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false); |
| 3095 | } |
| 3096 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3097 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 3098 | uint32_t firstExclusiveScissor, |
| 3099 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3100 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3101 | bool skip = false; |
| 3102 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3103 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3104 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3105 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3106 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 3107 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 3108 | ") is not 0.", |
| 3109 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3110 | } |
| 3111 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3112 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3113 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 3114 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 3115 | ") is not 1.", |
| 3116 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3117 | } |
| 3118 | } else { // multiViewport enabled |
| 3119 | 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] | 3120 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3121 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 3122 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 3123 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3124 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3125 | } |
| 3126 | } |
| 3127 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3128 | if (firstExclusiveScissor >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3129 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033", |
| 3130 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32 |
| 3131 | ") must be less than maxViewports (=%" PRIu32 ").", |
| 3132 | firstExclusiveScissor, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3133 | } |
| 3134 | |
| 3135 | if (pExclusiveScissors) { |
| 3136 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 3137 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 3138 | |
| 3139 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3140 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 3141 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 3142 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3143 | } |
| 3144 | |
| 3145 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3146 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 3147 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 3148 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3149 | } |
| 3150 | |
| 3151 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 3152 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3153 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 3154 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3155 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3156 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3157 | } |
| 3158 | |
| 3159 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 3160 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3161 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 3162 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3163 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3164 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 3165 | } |
| 3166 | } |
| 3167 | } |
| 3168 | |
| 3169 | return skip; |
| 3170 | } |
| 3171 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3172 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 3173 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3174 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3175 | bool skip = false; |
| 3176 | if (firstViewport >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3177 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323", |
| 3178 | "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").", |
| 3179 | firstViewport, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3180 | } else { |
| 3181 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 3182 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3183 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 3184 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3185 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 3186 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 3187 | } |
| 3188 | } |
| 3189 | |
| 3190 | return skip; |
| 3191 | } |
| 3192 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3193 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 3194 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3195 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3196 | bool skip = false; |
| 3197 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3198 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3199 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3200 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3201 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 3202 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 3203 | ") is not 0.", |
| 3204 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3205 | } |
| 3206 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3207 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3208 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 3209 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 3210 | ") is not 1.", |
| 3211 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3212 | } |
| 3213 | } |
| 3214 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3215 | if (firstViewport >= device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3216 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066", |
| 3217 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32 |
| 3218 | ") must be less than maxViewports (=%" PRIu32 ").", |
| 3219 | firstViewport, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3220 | } |
| 3221 | |
| 3222 | 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] | 3223 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3224 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 3225 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 3226 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3227 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3228 | } |
| 3229 | |
| 3230 | return skip; |
| 3231 | } |
| 3232 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3233 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 3234 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 3235 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3236 | bool skip = false; |
| 3237 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3238 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3239 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 3240 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 3241 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3242 | } |
| 3243 | |
| 3244 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3245 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 3246 | } |
| 3247 | |
| 3248 | return skip; |
| 3249 | } |
| 3250 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3251 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3252 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3253 | bool skip = false; |
| 3254 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3255 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3256 | skip |= LogError( |
| 3257 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3258 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 3259 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3260 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3261 | } |
| 3262 | |
| 3263 | return skip; |
| 3264 | } |
| 3265 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3266 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3267 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3268 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3269 | bool skip = false; |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 3270 | static const int condition_multiples = 0b0011; |
| 3271 | if (offset & condition_multiples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3272 | skip |= LogError( |
| 3273 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 3274 | "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] | 3275 | } |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 3276 | if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3277 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 3278 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 3279 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 3280 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 3281 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3282 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3283 | skip |= LogError( |
| 3284 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
| 3285 | "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] | 3286 | } |
| 3287 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3288 | return skip; |
| 3289 | } |
| 3290 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3291 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3292 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3293 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3294 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3295 | bool skip = false; |
| 3296 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3297 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3298 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 3299 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 3300 | "), is not a multiple of 4.", |
| 3301 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3302 | } |
| 3303 | |
| 3304 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3305 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 3306 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 3307 | "), is not a multiple of 4.", |
| 3308 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3309 | } |
| 3310 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 3311 | return skip; |
| 3312 | } |
| 3313 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3314 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3315 | const VkAllocationCallbacks *pAllocator, |
| 3316 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3317 | bool skip = false; |
| 3318 | |
| 3319 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3320 | if (pCreateInfo != nullptr) { |
| 3321 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 3322 | // VkQueryPipelineStatisticFlagBits values |
| 3323 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 3324 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3325 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 3326 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 3327 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 3328 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3329 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 3330 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3331 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3332 | } |
| 3333 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3334 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 3335 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3336 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3337 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 3338 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3339 | } |
| 3340 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3341 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 3342 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 3343 | VkResult result) { |
| 3344 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3345 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3346 | } |
| 3347 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3348 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 3349 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 3350 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3351 | // 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] | 3352 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3353 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3354 | } |
| 3355 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3356 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 3357 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3358 | // 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] | 3359 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3360 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3361 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 3362 | |
| 3363 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3364 | const VkAllocationCallbacks *pAllocator, |
| 3365 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 3366 | bool skip = false; |
| 3367 | |
| 3368 | if (pAllocateInfo) { |
| 3369 | auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
| 3370 | 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] | 3371 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 3372 | "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] | 3373 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3374 | |
| 3375 | VkMemoryAllocateFlags flags = 0; |
| 3376 | auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
| 3377 | if (flags_info) { |
| 3378 | flags = flags_info->flags; |
| 3379 | } |
| 3380 | |
| 3381 | auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext); |
| 3382 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
| 3383 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3384 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 3385 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
| 3386 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3387 | } |
| 3388 | |
| 3389 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 3390 | auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
| 3391 | #endif |
| 3392 | auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 3393 | auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
| 3394 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 3395 | auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
| 3396 | #endif |
| 3397 | |
| 3398 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3399 | skip |= LogError( |
| 3400 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3401 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 3402 | } |
| 3403 | if ( |
| 3404 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 3405 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 3406 | #endif |
| 3407 | (import_memory_fd && import_memory_fd->handleType) || |
| 3408 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 3409 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 3410 | #endif |
| 3411 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3412 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 3413 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3414 | } |
| 3415 | } |
| 3416 | |
| 3417 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 3418 | VkBool32 capture_replay = false; |
| 3419 | VkBool32 buffer_device_address = false; |
| 3420 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
| 3421 | if (vulkan_12_features) { |
| 3422 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 3423 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 3424 | } else { |
| 3425 | const auto *bda_features = |
| 3426 | lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext); |
| 3427 | if (bda_features) { |
| 3428 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 3429 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 3430 | } |
| 3431 | } |
| 3432 | 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] | 3433 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
| 3434 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, " |
| 3435 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 3436 | } |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 3437 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3438 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
| 3439 | "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] | 3440 | } |
| 3441 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 3442 | } |
| 3443 | return skip; |
| 3444 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 3445 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3446 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3447 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3448 | bool skip = false; |
| 3449 | |
| 3450 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 3451 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 3452 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3453 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3454 | } else { |
| 3455 | uint32_t vertex_component_size = 0; |
| 3456 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 3457 | vertex_component_size = 4; |
| 3458 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 3459 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 3460 | vertex_component_size = 2; |
| 3461 | } |
| 3462 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3463 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3464 | } |
| 3465 | } |
| 3466 | |
| 3467 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 3468 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3469 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3470 | } else { |
| 3471 | uint32_t index_element_size = 0; |
| 3472 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 3473 | index_element_size = 4; |
| 3474 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 3475 | index_element_size = 2; |
| 3476 | } |
| 3477 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3478 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3479 | } |
| 3480 | } |
| 3481 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 3482 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3483 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3484 | } |
| 3485 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3486 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3487 | } |
| 3488 | } |
| 3489 | |
| 3490 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3491 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3492 | } |
| 3493 | |
| 3494 | return skip; |
| 3495 | } |
| 3496 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3497 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 3498 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3499 | bool skip = false; |
| 3500 | |
| 3501 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3502 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3503 | } |
| 3504 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3505 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3506 | } |
| 3507 | |
| 3508 | return skip; |
| 3509 | } |
| 3510 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3511 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 3512 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3513 | bool skip = false; |
| 3514 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3515 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3516 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3517 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3518 | } |
| 3519 | return skip; |
| 3520 | } |
| 3521 | |
| 3522 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3523 | VkAccelerationStructureNV object_handle, |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3524 | const char *func_name) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3525 | bool skip = false; |
| 3526 | 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] | 3527 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 3528 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 3529 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3530 | } |
| 3531 | 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] | 3532 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 3533 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 3534 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3535 | } |
| 3536 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 3537 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3538 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 3539 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 3540 | "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] | 3541 | } |
| 3542 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_props.maxGeometryCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3543 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
| 3544 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 3545 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3546 | } |
| 3547 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_props.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3548 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 3549 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 3550 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3551 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 3552 | 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] | 3553 | uint64_t total_triangle_count = 0; |
| 3554 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 3555 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3556 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3557 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3558 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3559 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 3560 | continue; |
| 3561 | } |
| 3562 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 3563 | } |
| 3564 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_props.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3565 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 3566 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 3567 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3568 | } |
| 3569 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 3570 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 3571 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 3572 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 3573 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 3574 | if (geometry.geometryType != first_geometry_type) { |
| 3575 | // TODO: update fake VUID below with the real one once it is generated. |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3576 | skip |= LogError(device, "UNASSIGNED-VkAccelerationStructureInfoNV-pGeometries-XXXX", |
| 3577 | "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match " |
| 3578 | "info.pGeometries[0].geometryType.", |
| 3579 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 3580 | } |
| 3581 | } |
| 3582 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3583 | return skip; |
| 3584 | } |
| 3585 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 3586 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 3587 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3588 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 3589 | bool skip = false; |
| 3590 | |
| 3591 | if (pCreateInfo) { |
| 3592 | if ((pCreateInfo->compactedSize != 0) && |
| 3593 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3594 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 3595 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 3596 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 3597 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 3598 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3599 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3600 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 3601 | "vkCreateAccelerationStructureNV()"); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 3602 | } |
| 3603 | |
| 3604 | return skip; |
| 3605 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 3606 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3607 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 3608 | const VkAccelerationStructureInfoNV *pInfo, |
| 3609 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 3610 | VkBool32 update, VkAccelerationStructureNV dst, |
| 3611 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 3612 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3613 | bool skip = false; |
| 3614 | |
| 3615 | if (pInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3616 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3617 | } |
| 3618 | |
| 3619 | return skip; |
| 3620 | } |
| 3621 | |
| 3622 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 3623 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3624 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3625 | bool skip = false; |
| 3626 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3627 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 3628 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 3629 | } |
| 3630 | return skip; |
| 3631 | } |
| 3632 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 3633 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 3634 | uint32_t createInfoCount, |
| 3635 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 3636 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3637 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 3638 | bool skip = false; |
| 3639 | |
| 3640 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 3641 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 3642 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3643 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670", |
| 3644 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 3645 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 3646 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 3647 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 3648 | } |
| 3649 | } |
| 3650 | |
| 3651 | return skip; |
| 3652 | } |
| 3653 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 3654 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 3655 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 3656 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3657 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 3658 | bool skip = false; |
| 3659 | if (!device_extensions.vk_khr_swapchain) |
| 3660 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 3661 | if (!device_extensions.vk_khr_get_surface_capabilities_2) |
| 3662 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
| 3663 | if (!device_extensions.vk_khr_surface) |
| 3664 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
| 3665 | if (!device_extensions.vk_khr_get_physical_device_properties_2) |
| 3666 | skip |= |
| 3667 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 3668 | if (!device_extensions.vk_ext_full_screen_exclusive) |
| 3669 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 3670 | skip |= validate_struct_type( |
| 3671 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 3672 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 3673 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 3674 | if (pSurfaceInfo != NULL) { |
| 3675 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 3676 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 3677 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 3678 | |
| 3679 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 3680 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 3681 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 3682 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 3683 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 3684 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 3685 | |
| 3686 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 3687 | } |
| 3688 | return skip; |
| 3689 | } |
| 3690 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 3691 | |
| 3692 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 3693 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3694 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 3695 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3696 | bool skip = false; |
| 3697 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) { |
| 3698 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 3699 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 3700 | } |
| 3701 | return skip; |
| 3702 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3703 | |
| 3704 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3705 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3706 | bool skip = false; |
| 3707 | |
| 3708 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3709 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
| 3710 | "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 3711 | } |
| 3712 | |
| 3713 | return skip; |
| 3714 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 3715 | |
| 3716 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3717 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 3718 | bool skip = false; |
| 3719 | |
| 3720 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3721 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 3722 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 3723 | } |
| 3724 | |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 3725 | const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 3726 | if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3727 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 3728 | "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] | 3729 | } |
| 3730 | |
| 3731 | return skip; |
| 3732 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 3733 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 3734 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 3735 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 3736 | const VkDeviceSize *pOffsets) const { |
| 3737 | bool skip = false; |
| 3738 | if (firstBinding > device_limits.maxVertexInputBindings) { |
| 3739 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 3740 | "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding, |
| 3741 | device_limits.maxVertexInputBindings); |
| 3742 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 3743 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
| 3744 | "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 3745 | "maxVertexInputBindings (%u)", |
| 3746 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 3747 | } |
| 3748 | |
| 3749 | return skip; |
| 3750 | } |
| 3751 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 3752 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3753 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 3754 | bool skip = false; |
| 3755 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3756 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 3757 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 3758 | } |
| 3759 | return skip; |
| 3760 | } |
| 3761 | |
| 3762 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3763 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 3764 | bool skip = false; |
| 3765 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3766 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 3767 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 3768 | } |
| 3769 | return skip; |
| 3770 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 3771 | |
| 3772 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 3773 | VkSemaphore semaphore, VkFence fence, |
| 3774 | uint32_t *pImageIndex) const { |
| 3775 | bool skip = false; |
| 3776 | |
| 3777 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3778 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 3779 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 3780 | } |
| 3781 | |
| 3782 | return skip; |
| 3783 | } |
| 3784 | |
| 3785 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 3786 | uint32_t *pImageIndex) const { |
| 3787 | bool skip = false; |
| 3788 | |
| 3789 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3790 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 3791 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 3792 | } |
| 3793 | |
| 3794 | return skip; |
| 3795 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 3796 | |
| 3797 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 3798 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 3799 | VkDeviceSize counterBufferOffset, |
| 3800 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 3801 | bool skip = false; |
| 3802 | |
| 3803 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3804 | skip |= LogError( |
| 3805 | counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 3806 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).", |
| 3807 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
| 3808 | } |
| 3809 | |
| 3810 | return skip; |
| 3811 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 3812 | |
| 3813 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 3814 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 3815 | const VkAllocationCallbacks *pAllocator, |
| 3816 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 3817 | const char *apiName) const { |
| 3818 | bool skip = false; |
| 3819 | |
| 3820 | // Check samplerYcbcrConversion feature is set |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 3821 | const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 3822 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3823 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
| 3824 | "samplerYcbcrConversion must be enabled to call %s.", apiName); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 3825 | } |
| 3826 | return skip; |
| 3827 | } |
| 3828 | |
| 3829 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 3830 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 3831 | const VkAllocationCallbacks *pAllocator, |
| 3832 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 3833 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 3834 | "vkCreateSamplerYcbcrConversion"); |
| 3835 | } |
| 3836 | |
| 3837 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 3838 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 3839 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 3840 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 3841 | "vkCreateSamplerYcbcrConversionKHR"); |
| 3842 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 3843 | |
| 3844 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR( |
| 3845 | VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const { |
| 3846 | bool skip = false; |
| 3847 | VkExternalSemaphoreHandleTypeFlags supported_handle_types = |
| 3848 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 3849 | |
| 3850 | if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3851 | skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", |
| 3852 | "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).", |
| 3853 | report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(), |
| 3854 | string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType), |
| 3855 | string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 3856 | } |
| 3857 | return skip; |
| 3858 | } |